I have tried the below link sample code :
http://www.pinvoke.net/default.aspx/advapi32.CreateProcessWithLogonW
The below code are the parameters that I'm using to launch my exe.
String applicationName = @"C:\Windows\System32\cmd.exe";
String command = "MyExeName.exe";
String user = "admin";
String domain = System.Environment.MachineName;
String password = "Password!";
String currentDirectory = @"C:\Program Files\My AppFolder\";
try
{
if(CreateProcessWithLogonW(
user,
domain,
password,
(UInt32)1,
applicationName,
command,
(UInt32)0,
(UInt32)0,
currentDirectory,
ref startupInfo,
out processInfo))
{
Console.WriteLine("pass");
}
else
{
Console.WriteLine("fail");
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
I am able to launch cmd, but not able to open MyNameExe.exe from the cmd. How do I pass MyNameExe.exe as parameter to cmd on creating new process.
Can someone please help?
Thank you.
Comments
Post a Comment