PDA

View Full Version : Variables handling



JOSAN
10-07-2009, 05:00 PM
Start waving to the components of the forum in my first post and to clarify that English is not my native language.

The final aim is to let the user to be able to select several simple parameters from a double command, combine these variables of the command to the selected disk drive. I have read a lot, but I’m confused in my beginnings.

This example is without the use of these variables, that I want to select from input, listbox, combobox, etc. In blue chkdsk command example, in red the selection of the drive.

File.Run("C:\\WINDOWS\\SYSTEM32\\CMD.EXE", "/C chkdsk /I/C F: >exit.txt" , "C:\\TEMP", SW_SHOWNORMAL, true);
File.Open("C:\\TEMP\\exit.txt", "", SW_SHOWNORMAL);

Told me I look good, thanks.

IdeasVacuum
10-07-2009, 05:20 PM
The values are assigned to variables according to what the User picks via a ListBox, ComboBox etc. Sounds as though you understand how to do that.

The arguments for the exe to be run are passed as a string to the File.Run function, so you can simply concatenate your var values to make that string. For example:

The vars collected:

Var1 = "/C chkdsk";
Var2 = "/I";
Var3 = "/C";
Var4 = "F:";

Concatenate these into a string Var called 'Args':

Args = Var1 .. Var2 .. Var3 .. " " .. Var4 .. " >exit.txt";

So now the File.Run function looks like this:

File.Run("C:\\WINDOWS\\SYSTEM32\\CMD.EXE", Args, "C:\\TEMP", SW_SHOWNORMAL, true); ;)