ProcessStartInfo to execute vb script with certain user

  • Thread starter Thread starter Bishoy George
  • Start date Start date
B

Bishoy George

I tried to use ProcessStartInfo to execute a vb script with certain user
name.

My Code:
---------
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = fileName;
psi.UserName = userName;
psi.Password = password;
psi.Domain = domain;
psi.UseShellExecute = true;

Process.Start(psi);


The Problem:
----------------

When I set UseShellExecute to true --> the error is "The Process object must
have the UseShellExecute property set to false in order to start a process
as a user."

When I set UseShellExecute to false --> the error is "The specified
executable is not a valid Win32 application."


Any Help please????

Bishoy
 
Hi Bishoy,

You must specify the program that runs scripts, "WScript.exe" and pass the script to be executed as an argument.
Do not set UseShellExecute and try the following:

psi.FileName = "wscript.exe \"" + fileName + "\" /nologo";
 
Back
Top