Search code examples
c#processinstallationpsexec

How to install on remote PC with psexec with my c# code


I'm trying to install some software remotely from our domain server to all the PC's in the office. I know the code to install it silently on the local computer and have tried various things that I've found while searching to install it remotely when pressing a button in my app but I can't get it to work. This is my local code and it works:

Process SR = new Process();
SR.StartInfo.FileName = "X:\\Teklastructures\\Tekla Structures Releases\\18.0\\TeklaStructures180SR3x64Software.exe";
SR.StartInfo.Arguments = "/s /v\"/qn INSTALLDIR=C:\\TeklaStructures /lvoicewarmupx C:\\teklaSRinstall.log";
SR.Start();
SR.WaitForExit();
SR.Close();

I've been trying to use psexec because I've read that it should do what I want. I believe one problem is that the software is on mapped drive X. So how can I install it remotely? Maybe look at this instead? "\\server\\d\\Teklastructures\\Tekla Structures Releases\\18.0\\TeklaStructures180SR3x64Software.exe"

This is what I've tried with putting PsExec.exe on the C drive of the server:

Process p = new Process();
p.StartInfo.FileName = "C:\\PsExec.exe";
string args = "/s /v\"/qn INSTALLDIR=C:\\TeklaStructures /lvoicewarmupx C:\\teklaSRinstall.log";
p.StartInfo.Arguments = @"\\COMP14 -accepteula -i -s X:\Teklastructures\Tekla Structures Releases\18.0\TeklaStructures180SR3x64Software.exe " + args;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.Start();
p.WaitForExit();
p.Close();

Any help to install software remotely would be appreciated. Perhaps there's a better way?


Solution

  • You must copy the installer exe to the computer where you want to install it, and then use psexec to run it there. You cannot run the installer exe from a different machine that where you want it to be installed to.