Although this is a common task for IT administrators or developers, there are relatively few documents available on the web to find "Remote installation of an MSI package or EXE application." Even in the comments of some forums, it was not possible to achieve this. Actually, it's OK. I will provide two pieces of code in this article, responsible for the remote installation of the MSI package and EXE executable application.
First, install the MSI package
Using PowerShell to invoke the WMI object, you can execute the following script to install your MSI installation package:
Copy Code code as follows:
$box = "Deviis01" #this is the name of your server
$product = [WMIClass] "\ $box \root\cimv2:win32_product"
Write-host "Installing software on $box"
$product. Install ("C:\Setup \somesoftwarepackage.msi")
It can be installed silently, so it's no longer a concern to use command parameters.
Note: Some installation packages may require the user to select or set many options during the installation process.
Second, the installation of EXE application
Egg pain is the use of the above method can not successfully install EXE executable installation package, if there are children's shoes have Haiten, can message share under the idea or code, because I am also curious whether this is feasible. However, we can use another method to install the EXE.
Copy Code code as follows:
Write-host "Installing software on $box"
([WMIClass] "\ $box \root\cimv2:win32_process"). Create (
"Cmd.exe/c c:\setup\somesoftware.exe/s/V" "/qn")
The above script actually creates a new process on the remote machine, calls Cmd.exe, passes the executable package as a parameter, and then passes the parameters that the installer needs. This involves a lot of string escape, with the quotation mark conversion, you should be extra careful.
Article Source: http://www.pstips.net/install-application-remotely.html