Link to home
Start Free TrialLog in
Avatar of bsharath
bsharathFlag for India

asked on

Uninstall Winrar remotely Via a script on a set of computer names in a txt file.

Hi,

Uninstall Winrar remotely Via a script on a set of computer names in a txt file.
I want help with a script that can uninstall Winrar on all machines in a txt file.

Regards
Sharath
Avatar of vikas_madhusudana
vikas_madhusudana
Flag of India image

Assuming that you have some bat script on all the machines that will uninstall winrar

you can use pstools to do so downloadlink(http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx)

psexec.exe @machines.txt -u username -p password -w c:\ -d -c batch_file.bat

*machines.txt has all the machine names or ip's of machines.
*username - domain adminuser so that he has permission on all machines
*password- password of adminuser
*-w is a used to set the current working directory(i.e where the batch file to be executed is placed the target machine)
*batch_file.bat is the batch file that needs to be run( here batch file to uninstall winrar)

~vikas



Avatar of bsharath

ASKER

Thanks but my main need is the batch file....
Oh i have a link that will give you information about uninstalling using command line probably that might help you

http://www.pcterritory.net/2009/04/uninstall-and-delete-program-with.html

~Vikas
Avatar of xxli79
xxli79

Use pstools as vikas_madhusudana mentioned, and I write the script to unintall winrar.
You may run it like: psexec.exe @machines.txt -u username -p password -w c:\ -d -c uninstall_winrar.js
var WshShell = WScript.CreateObject ("WScript.Shell");
 
var uninstallString = WshShell.RegRead("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\WinRAR archiver\\UninstallString");
 
WshShell.Run( '"'+uninstallString+'" /s', 0, true )

Open in new window

I get this

---------------------------
Windows Script Host
---------------------------
Script:      C:\uninstall_winrar.js
Line:      3
Char:      1
Error:      Invalid root in registry key "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\WinRAR archiver\UninstallString".
Code:      80070002
Source:       WshShell.RegRead

---------------------------
OK  
---------------------------

If the machine does not have the sting then move to next computer.
I am running from the Domain admin so will not be using the username and password
@bsharath: the msg means that computer does'nt install winrar, just ignore it.
Or if the winrar is not installed by installer, that will be a little complicated, you can try with this:
var WshShell = WScript.CreateObject ("WScript.Shell");
 
var uninstallString = "";
try {
    uninstallString = WshShell.RegRead("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\WinRAR archiver\\UninstallString");
} catch (e) {
    uninstallString = WshShell.RegRead("HKCR\\.rar\\ShellNew\\FileName");
    uninstallString = uninstallString.substr(0, uninstallString.lastIndexOf("\\")) + "\\Uninstall.exe";
}
 
WshShell.Run( '"'+uninstallString+'" /s', 0, true );

Open in new window

I get this

PsExec could not start uninstall_winrar.js on de163:
The system cannot find the file specified.
The -c argument of PsExec will copy uninstall_winrar.js to the remote system.
Does only computer "de163" throw this message?
What about other computers?
Ok i tried many more for all i get the same. I tried running on 1 machine directly and i get this

---------------------------
Windows Script Host
---------------------------
Script:      C:\uninstall_winrar.js
Line:      7
Char:      5
Error:      Invalid root in registry key "HKCR\.rar\ShellNew\FileName".
Code:      80070002
Source:       WshShell.RegRead

---------------------------
OK  
---------------------------
ASKER CERTIFIED SOLUTION
Avatar of xxli79
xxli79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi
The script works fine but it does not work when deplyed via psexec or for loop code \or any other
Is there any known reasone. Does the js extension code work via the startup script. if i use this code in the startup script in AD will it run and unistall winrar
How can i not get any boxes when done
jscript could work via start script: cscript.exe xxx.js
Ok thanks please take care
Sorry aove is on the wrong post...Shall check and get back
Thank U