ProcessStartInfo to execute vb script with certain user

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
 
D

Dave Sexton

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";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top