How exactly using VB6 can I can call any Windows shell command as you would from the command-line?
For example, something as trivial as:
echo foo
How exactly using VB6 can I can call any Windows shell command as you would from the command-line?
For example, something as trivial as:
echo foo
Only use double quotes:
""...""
Example - send confirmation pass to make a task:
because the first
"
are closed in"C:\...
and the string would stop.Ahora explico en Español
Solo usa doble comillas:
""...""
Ejemplo - mando un pass para confirmar la creacion de la tarea:
la causa es que la primera comillas
"
se cierra con las comillas de la ruta"C:\...
y se pierde la cadena String.:) Espero sirva y buena suerte
I've always used the Run method of the wshShell object, which is available after you reference the Windows Script Host Object Model in your project:
You get the same functionality as the normal Shell statement, but the final parameter lets you decide whether to run the shelled program synchronously. The above call, with vbTrue, is synchronous. Using vbFalse starts the program asynchronously.
And, as noted in previous answers, you need to run the command shell with the "/c" switch to execute internal commands, like the "echo foo" from your question. You'd send "cmd /c echo foo" to the Run method.
a combination of all
you should think in expanding COMSPEC environment variable if you wish to support earlier systems like windows 9x or me.
You can also obtain the process id using
Here's how you do it :
Shell and ShellExecute?
http://msdn.microsoft.com/en-us/library/aa242087.aspx