• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

VB.NET sending command line.

Elite Diviner
Joined
Mar 30, 2013
Messages
456
Reaction score
42
I know of process.start();, but I also have been taught that it is not entirely reliable/secure.

Was wondering if there was any other methods around this.

Simply wanting to send a MSG command to user ablakely with information from three text boxes. Text boxes names are txtName, txtUnit, and txtClass

Example output: MSG ablakely Zachary Mitchell, 3.2.10, English 12-1.

If someone knows why process.start(); isn't secure, that would also be great. I just know in my VB class, the prof always said to never use it, but that was several years ago, and have not used VB since.



Also for the sake of learning, if anyone has an answer, how would you do the same in C++/Java?

Thanks in advance!
 
Junior Spellweaver
Joined
Oct 27, 2008
Messages
165
Reaction score
89
It depends on what you want to do with the process, if you want to only start a process, use a simple function to start it, if you want to start it and get its handle, to have control over it, use a more complex one.

To start a process with arguments you can do it with Process.Start(), the process Class has a Member( ) of type " ", which you specify some properties for the process you want to start
PHP:
Dim process As New Process
process.StartInfo.Arguments = "arg1 arg2"
process.StartInfo.FileName = "path\\to\\file.exe"
process.StartInfo.WorkingDirectory = "path\\to\\working\\directory\\"
process.StartInfo.WindowStyle = ProcessWindowStyle.Normal
process.Start()

In C++ to start a process you can do it by 4 ways as far as I know( , , , )
PHP:
//system, available in linux too
system( "path\\to\\file.exe arg1 arg2" );

//CreateProcess
PROCESS_INFORMATION processInfo = {0};
STARTUPINFO startupInfo = {0};
startupInfo.cb = sizeof(STARTUPINFO );
CreateProcess(
    "path\\to\\file.exe",
    "arg1 arg2", 
    NULL, 
    NULL, 
    FALSE,
    0, 
    NULL, 
    "path\\to\\working\\directory\\", 
    &startupInfo, 
    &processInfo
);

//Shell Execute
ShellExecute(NULL, "open", "path\\to\\file.exe", "arg1 arg2", "path\\to\\working\\directory\\", SW_SHOWDEFAULT);

//ShellExecuteEx 
SHELLEXECUTEINFO shExInfo= {0};
shExInfo.cbSize = sizeof(SHELLEXECUTEINFO);
shExInfo.lpFile = "path\\to\\file.exe";
shExInfo.lpParameters = "arg1 arg2";
shExInfo.lpDirectory = "path\\to\\working\\directory\\";
shExInfo.nShow =  SW_SHOWDEFAULT;
ShellExecuteEx(&shExInfo);

In Java is the and
PHP:
ProcessBuilder pb = new ProcessBuilder( "path\\to\\file.exe", "arg1", "arg2");
Process p = pb.start();
 
Back
Top