How to remove software remotely using PsExec

Sometimes you may need to remove software remotely for some cases. Some software may allow you to uninstall software remotely or help you install it, but you may have to pay for it. Uninstalling software is a simple process and you do not have to pay anything if you follow this article. We are going to use one of the sysinternal tools which is called PsExec. I have been using the PsExec for years and it is a really helpful tool for IT staff. I recommend you send the executive files into System32 because each time when it is needed just type PsExec commands on your terminal.

Download the PsExec x86 version by clicking here, for x64 is here. I assume that you downloaded two files and sent them to the System32 folder. In my environment, there is an active directory and all computers are members of this domain controller. I use an Administrator account and have the privilege to run a process on the client. You will get a notification popup showing you the SYSINTERNALS SOFTWARE LICENSE TERMS you must accept before using the software.

The following command is simple I just type PsExec and let the terminal that I will use PsExec software then type the IP address of the client or name then cmd because I want to run the necessary commands on the client.

psexec \\computernameoripaddress cmd

You will get something like below due to your environment if you really connected to the remote computer. I wanted to check what is the computer’s name as an example.

C:\Users\hasana>psexec \\mrtvdidemo-003 cmd

PsExec v2.34 - Execute processes remotely
Copyright (C) 2001-2021 Mark Russinovich
Sysinternals - www.sysinternals.com

Microsoft Windows [Version 10.0.19045.3208]
(c) Microsoft Corporation. All rights reserved.
C:\Windows\system32>
C:\Windows\system32>hostname
MRTVDIDEMO-003

We are connected to the remote controller and we can do whatever we want. In our case, as you see in the title we would like to know which software is installed on the computer and how can we remove them remotely. Let’s list which software is installed on the remote computer by typing the following command in the terminal.

wmic product get name

My output is given below and I know what is installed on the remote computer, and I know what to remove.

C:\Windows\system32>wmic product get name
Name
Office 16 Click-to-Run Extensibility Component
Office 16 Click-to-Run Localization Component
Office 16 Click-to-Run Extensibility Component 64-bit Registration
Office 16 Click-to-Run Licensing Component
Microsoft Visual C++ 2022 X64 Minimum Runtime - 14.32.31332
SOLIDWORKS Composer Player 2022 SP05
Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.4148
Microsoft.NET.Sdk.Maui.Manifest-6.0.300
Microsoft.NET.Workload.Emscripten.Manifest
Microsoft Visual C++ 2010  x64 Redistributable - 10.0.40219
Microsoft Visual Basic for Applications 7.1 (x64) English
Microsoft Visual C++ 2010  x86 Redistributable - 10.0.40219
Microsoft Windows Desktop Runtime - 6.0.20 (x64)
Microsoft .NET AppHost Pack - 6.0.20 (x64_x86)
Microsoft Visual C++ 2013 x86 Minimum Runtime - 12.0.21005
Microsoft Visual C++ 2013 x86 Additional Runtime - 12.0.21005
Microsoft Windows Desktop Targeting Pack - 6.0.20 (x64)
Bonjour
Microsoft.NET.Sdk.Android.Manifest-6.0.300
Microsoft Update Health Tools
Microsoft ASP.NET Core 6.0.20 Targeting Pack (x64)
Microsoft Visual C++ 2022 X64 Additional Runtime - 14.32.31332
Microsoft .NET Targeting Pack - 6.0.20 (x64)
Java 8 Update 321 (64-bit)
Microsoft Visual C++ 2022 X86 Additional Runtime - 14.32.31332
Microsoft .NET Host - 6.0.20 (x64)
Microsoft Visual Basic for Applications 7.1 (x64)
Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.21005
SOLIDWORKS 2022 SP05
SOLIDWORKS 2022 Turkish Resources
SOLIDWORKS eDrawings 2022 SP05
Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.21005
Autodesk Advanced Material Library Image Library 2018
Microsoft .NET Toolset 6.0.412 (x64)
Microsoft Visual Studio Tools for Applications 2015 x64 Hosting Support
Microsoft.NET.Workload.Mono.Toolchain.Manifest
Microsoft Visual C++ 2012 x64 Additional Runtime - 11.0.61030
Microsoft Visual C++ 2022 X86 Minimum Runtime - 14.32.31332
SOLIDWORKS CAM 2022 SP05
Microsoft.NET.Sdk.MacCatalyst.Manifest-6.0.300
Autodesk Material Library Base Resolution Image Library 2018
Microsoft.NET.Sdk.macOS.Manifest-6.0.300
VMware Tools
Microsoft .NET AppHost Pack - 6.0.20 (x64)
SOLIDWORKS PDM Client 2022 SP05
Autodesk License Service (x64) - 5.1.4
ESET Management Agent
Microsoft .NET AppHost Pack - 6.0.20 (x64_arm64)
ESET Endpoint Security
WPTx64
Microsoft .NET Standard Targeting Pack - 2.1.0 (x64)
Microsoft Visual C++ 2012 x86 Additional Runtime - 11.0.61030
3DEXPERIENCE Marketplace for SOLIDWORKS
Microsoft Visual C++ 2012 x64 Minimum Runtime - 11.0.61030
Microsoft ASP.NET Core 6.0.20 Shared Framework (x64)
Microsoft .NET AppHost Pack - 6.0.20 (x64_arm)
Microsoft .NET Runtime - 6.0.20 (x64)
Microsoft .NET 6.0 Templates 6.0.412 (x64)
Microsoft ODBC Driver 17 for SQL Server
Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.4148
Microsoft.NET.Sdk.iOS.Manifest-6.0.300
Microsoft Visual Studio Tools for Applications 2015 Finalizer
Microsoft Visual C++ 2012 x86 Minimum Runtime - 11.0.61030
SOLIDWORKS File Utilities 2022 SP05
Autodesk Material Library 2018
Microsoft Visual Studio Tools for Applications 2015 x86 Hosting Support
VMware Dynamic Environment Manager Standard
VMware Horizon Agent
A360 Desktop
Microsoft.NET.Sdk.tvOS.Manifest-6.0.300
Java Auto Updater
AutoCAD 2018 Help - English
AutoCAD LT 2018 - English
AutoCAD LT 2018 Language Pack - English
AutoCAD LT 2018 - English
Microsoft .NET Host FX Resolver - 6.0.20 (x64)


C:\Windows\system32>

Let’s use the following command to remove Java software as an example. The only thing that you need to change is the name of the software that you got printed out in your terminal after running the second command.

wmic product where name="Java 8 Update 321 (64-bit)" call uninstall /nointeractive

I got the following output when the uninstallation progress is done. As you see return value is 0 and the method execution is successful.

C:\Windows\system32>wmic product where name="Java 8 Update 321 (64-bit)" call uninstall /nointeractive
Executing (\\MRTVDIDEMO-003\ROOT\CIMV2:Win32_Product.IdentifyingNumber="{26A24AE4-039D-4CA4-87B4-2F64180321F0}",Name="Java 8 Update 321 (64-bit)",Version="8.0.3210.7")->Uninstall()
Method execution successful.

Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 0;
};

C:\Windows\system32>

Now when you run the second command again, you will see that the software is removed on the remote computer that you wanted to uninstall. Sometimes some software reboots the computer to complete the uninstallation progress.

Let’s assume that the computer needs to restart itself to complete the uninstallation progress. The ReturnValue will be 1641 and the method execution will be successful. There is an example below the computer rebooted itself and we got an error (Error communicating with PsExec service on mrtvdidemo-003: An unexpected network error occurred.) at the end of the output because we disconnected from the remote computer.

C:\Windows\system32>wmic product where name="ESET Endpoint Security" call uninstall
Executing (\\MRTVDIDEMO-003\ROOT\CIMV2:Win32_Product.IdentifyingNumber="{42DB9CDB-F51B-4A8C-B88B-7BA0225B4329}",Name="ESET Endpoint Security",Version="10.0.2045.0")->Uninstall()
Method execution successful.

Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 1641;
};

Error communicating with PsExec service on mrtvdidemo-003:
An unexpected network error occurred.

C:\Users\hasana>

This article was a small example and you need to investigate more because there are lots of information on the internet and you have to dig the find the right information. Maybe you can use PowerShell instead of WMI. I put some reference links below while writing this article.

https://learn.microsoft.com/en-us/sysinternals/downloads/psexec

https://learn.microsoft.com/en-us/previous-versions/windows/desktop/msiprov/install-method-in-class-win32-product

https://learn.microsoft.com/en-us/answers/questions/253555/software-list-inventory-wmic-product

https://learn.microsoft.com/enus/windows/win32/wmisdk/wmi-start-page

Thanks for your time reading my article. Have a good and successful day.

Hasan Altin

Published by Hasan Altin

I don't see any difference between the one who doesn't share its knowledge or the one who doesn't share its bread.

Leave a Reply

Your email address will not be published. Required fields are marked *