0

I've got this project that needs to get finished in two days and I'm nearly done with it. Except there's a part of it that needs to start another app and run it as a different domain user.

So far I've got this in code:

Process proc = new Process();
System.Security.SecureString ssPwd = new System.Security.SecureString();

string password = "SomePassword";
for (int x = 0; x < password.Length; x++)
{
     ssPwd.AppendChar(password[x]);
}

ProcessStartInfo StartInfo = new ProcessStartInfo
{
   FileName = "Translink.exe",
   WorkingDirectory = @"C:\Program Files\Western Union\Universal-Release",
   UserName = "someuser",
   Domain = "somedomain",
   Password = ssPwd,
   UseShellExecute = false,
   RedirectStandardOutput = true,
   RedirectStandardError = true
};
proc = Process.Start(StartInfo);
proc.WaitForExit();

So when I make a call with and without user and password for example: C:\Windows\System32\notepad.exe it runs in both cases but everytime I try to run that particular app "Translink.exe" from either Program Files or Program Files (x86) it just won't run at all with or without runas.

And I've ran out of things to try, I think I've tried everything so far in stackoverflow as there were other similar articles but I think I must be going wrong somewhere specifically.

ProToCooL
  • 177
  • 1
  • 3
  • 13
  • Do you get any error messages? Does it work if you start it using the "RunAs" command from a command prompt? – David Mar 28 '16 at 20:24
  • A Google search for `Translink.exe` renders some shady results. Trojan alerts primarily... – fguchelaar Mar 28 '16 at 20:25
  • Yes I do get errors sorry for not putting them in there: Invalid directory is one of them And file cannot be found – ProToCooL Mar 28 '16 at 20:27
  • The translink.exe is not a trojan, it's an app that is installed in our company's select pc's by another firm who's services we offer. I work at the Postal Office and it's one of the apps that the post has an agreement with. – ProToCooL Mar 28 '16 at 20:30
  • 2
    Can you try passing in the complete path of the Translink.exe, like `FileName = "C:\Program Files\Western Union\Universal-Release\Translink.exe"` – Abhinav Galodha Mar 28 '16 at 20:30
  • Thank you, that worked but can you explain it to me why is that? Cuz I know that when you use a username and password you HAVE to set the working directory cuz if you don't it defaults to Windows\System32, but i've set the workingdirectory, so why do I have to set it yet again? – ProToCooL Mar 28 '16 at 20:41
  • In the past, I've found this Freely downloadable class useful for this type of thing: http://www.codeproject.com/Articles/10090/A-small-C-Class-for-impersonating-a-User – Davy C Mar 28 '16 at 20:46
  • Working directory is the current directory once the program's started. It doesn't help Windows find the program in the first place. Notepad works because it's in a directory included in your computer's PATH environment variable. – Peter Duniho Mar 29 '16 at 02:06

0 Answers0