Re: run files by Fosco
Fosco
Wed Mar 15 21:19:18 CST 2006
"Fosco" <fake@fake.invalid>
> "Guillermo"
> > how can i run a command line from a vbs file
> set oShell = CreateObject("WScript.Shell")
> oShell.run"notepad.exe c:\test.txt"
Is the same as :
start run
notepad.exe c:\test.txt
(ENTER)
but with some optional parameter :
set oShell = CreateObject("WScript.Shell")
oShell.run"notepad.exe c:\test.txt" ,3, true
object.Run(strCommand, [intWindowStyle], [bWaitOnReturn])
Arguments
object
WshShell object.
strCommand
String value indicating the command line you want to run. You must include any parameters you want to pass to the
executable file.
intWindowStyle
Optional. Integer value indicating the appearance of the program's window. Note that not all programs make use of this
information.
bWaitOnReturn
Optional. Boolean value indicating whether the script should wait for the program to finish executing before continuing
to the next statement in your script. If set to true, script execution halts until the program finishes, and Run returns
any error code returned by the program. If set to false (the default), the Run method returns immediately after starting
the program, automatically returning 0 (not to be interpreted as an error code).
Example 2
The following VBScript code opens a command window, changes to the path to C:\ , and executes the DIR command.
Dim oShell
Set oShell = WScript.CreateObject ("WSCript.shell")
oShell.run "cmd /K CD C:\ & Dir"
Set oShell = Nothing
--
Fosco