Hi,
Can anyone help me how to run an exe file in the scripting task.
I was trying the below code but it's giving an error.
Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run "c:\Test\ABC.exe", 6, True
set wshshell = nothing
Thanks,
rkn
Here's one way. You may want to check out the MSDN for any security risks, etc.
Dim procID As Integer
procID = Shell("""C:\Program Files\Microsoft Office\OFFICE11\winword.exe"" c:\temp\test.doc")
Larry Pope|||
I would be inclined to choose .NET's Process.Start method as the more language-neutral approach...but it's possible that this is what the VB Shell command calls anyway.
-Doug
|||I believe the Process.Start method has the limitation of not being able
to add cmdline parameters, which was included in the original posters
code.
If I'm wrong about the Process.Start method not being able to use
cmdline parameters, please post some code. I would love to be
able to use that rather than Shell.
Larry|||
I think what you are looking for is something like this:
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(Setting.PostProcessor,commandLineArgs);
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.WorkingDirectory = "C:\\Test";
startInfo.UseShellExecute = false;
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = startInfo;
process.Start();
Hossein Riazi
|||The Start method also has other overloads suited for command line arguments, such as
Process.Start Method (String, String)
Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new Process component.
-Doug
No comments:
Post a Comment