Using PSTools to remotely deploy software

Forum rules
READ: Project-W rules
Post Reply
User avatar
kinerity
Administrator
Administrator
Posts: 2
Joined: Sun May 20, 2018 9:57 pm
Location: {postrow.POSTER_FROM}
Name: Kailey Truscott

Using PSTools to remotely deploy software

Post by kinerity » Thu May 31, 2018 3:17 pm

The company I work for is not a large enterprise in the traditional sense. There is an AD domain but no deployment solution or GPO software installation policies. Users frequently call stating they need one of the basic software packages on their computer updated. Since they do not have rights to install/uninstall software and we have multiple sites across the globe, this must be done remotely.

Initially, we would remote into their computer and install each one individually. My manager tasked me with coming up with a solution and my answer was to turn to PSTools and use a batch file to process the deployment. Here's how I set it up:
  • On the source computer, I downloaded PSTools from Microsoft's website (link) and extracted the contents to C:\PSTools\.
  • I created a C:\temp\ folder and placed all the software installers in that directory (.exe and .msi).
  • In the C:\temp\ folder, I created a computers.txt file. Each line in the .txt file has an IP Address or a computer name.
  • In the C:\temp\ folder, I created an install.bat file with the following content:
    Warning: You will need to change the {USERNAME} and {PASSWORD} values to match an account that has Administrator permissions on the target computer. You will also need to change {COMPUTER} to the name of the source computer. Change the software installers as necessary.

    bash Code: Select all

    @echo off
    if exist C:\temp\computers.txt goto ping
    pause
    goto :eof
    
    :ping
    for /f %%a in (C:\temp\computers.txt) do (
        ping -n 1 %%a
        if not errorlevel 1 (
            cd C:\PSTools\
            psexec \\%%a -u {USERNAME} -p {PASSWORD} cmd /c "msiexec.exe /i "\\{COMPUTER}\c$\temp\install_flash_player_29_active_x.msi" /quiet /norestart"
            psexec \\%%a -u {USERNAME} -p {PASSWORD} cmd /c "msiexec.exe /i "\\{COMPUTER}\c$\temp\install_flash_player_29_plugin.msi" /quiet /norestart"
            psexec \\%%a -u {USERNAME} -p {PASSWORD} cmd /c "msiexec.exe /i "\\{COMPUTER}\c$\temp\install_flash_player_29_ppapi.msi" /quiet /norestart"
            md "\\%%a\c$\temp"
            wmic product where "name like 'Java%%'" call uninstall /nointeractive
            copy "\\{COMPUTER}\c$\temp\jre-8u171-windows-i586.exe" "\\%%a\c$\temp\jre-8u171-windows-i586.exe"
            psexec \\%%a -u {USERNAME} -p {PASSWORD} "\\%%a\c$\temp\jre-8u171-windows-i586.exe" /s
            copy "\\{COMPUTER}\c$\temp\jre-8u171-windows-x64.exe" "\\%%a\c$\temp\jre-8u171-windows-x64.exe"
            psexec \\%%a -u {USERNAME} -p {PASSWORD} "\\%%a\c$\temp\jre-8u171-windows-x64.exe" /s
            psexec \\%%a -u {USERNAME} -p {PASSWORD} cmd /c "msiexec.exe /i "\\{COMPUTER}\c$\temp\AcroRdrDC1500720033_en_US.msi" /quiet /norestart"
            psexec \\%%a -u {USERNAME} -p {PASSWORD} cmd /c "msiexec.exe /p "\\{COMPUTER}\c$\temp\AcroRdrDCUpd1801120040.msp" /qn /quiet /norestart REINSTALLMODE="ecmus" REINSTALL="ALL""
        )
        pause
    )

Post Reply