I've been trying to get this working all morning.
These answers have not helped me at all..
- error-in-process-start-the-system-cannot-find-the-file-specified
- the-system-cannot-find-the-file-specified-error-on-process-start
And like 10 more similar to those. I've tried the answers in all of these posts and none of them work for me.
I am trying to develop an executable that runs a program on a remote machine with admin credentials.
I'm not using Visual Studio, I'm just compiling with the .Net version 4.0.30319 csc.exe.
Process process = new Process();
string pw = "pass";
SecureString password = new SecureString();
for (int i = 0; i < pw.Length; i++){
password.AppendChar(pw.ToCharArray()[i]);
}
password.MakeReadOnly();
var processInfo = new ProcessStartInfo(@"my_program.exe");
// not working
// processInfo.WorkingDirectory = @"C:\Users\myuser\Desktop";
// not working
processInfo.WorkingDirectory = @"\\remote\Apps";
// credentials
processInfo.UserName = "admin_username";
processInfo.Password = password;
processInfo.Domain = "WORK_DOMAIN";
processInfo.UseShellExecute = false;
//
try{
Process.Start(processInfo);
}catch (Exception ex){
MessageBox.Show(ex.Message.ToString(),"Error");
}
Running this as is throws 'the system cannot find the file specified
But when I comment out the credentials the program opens successfully.
The "admin_user" has all access rights to the share.