2

I am in a small bind. The program in question can be installed in the program files directory (64bit) or X86 path. The program is already installed in over 200 machines. I am fairly certain the default install path was X86 as that's the default. I am not certain and must cover both scenarios. The original sys admin that installed this didn't use an .msi so I'm left with what I've found as ""C:\Program Files\InstallShield Installation Information{78AC336D-25F6-4916-A711-2EA2F69E0319}\setup.exe" as the command provided by one utility to remotely uninstall said application I found. Didn't work and I cannot attempt to push this out in hopes it'll work.

Given this problem, is there a way to uninstall this program via a script that would check both program files and X86 paths and uninstall depending on location? OR, is there a script that will just flat out uninstall the program regardless without the concern for the X86/program original install location. I just need to uninstall it period across all of these machines. The install .bat is good to go. What I cannot do is just get window to uninstall X application via a script for 32 or 64 bit machines.

I've tried MsiExec.exe /X{78AC336D-25F6-4916-A711-2EA2F69E0319} /quiet with no go. I can try to install the .msi this time around but am lost and my knowledge is limited with scripting or any uninstall scripts for telling "end users" without confusing them to just click here. I could tell them to go to control panel, etc..but they'll be lost....typical.

Any ideas on how to script this uninstall given it wasn't an original .msi and I am not sure how to get something working? I'm open to anything. I have two days to get this fixed and I'm in panic mode...

Any ideas or help on code would be greatly appreciated.

Regards, Brian

Hakan Fıstık
  • 16,800
  • 14
  • 110
  • 131
Brian
  • 21
  • 1
  • 1
  • 2

3 Answers3

4

wmic can call an uninstaller. I haven't tried this, but I think it might work.

wmic /node:computername /user:adminuser /password:password product where name="name of application" call uninstall

If you don't know exactly what the program calls itself, do

wmic product get name | sort

and look for it. You can also uninstall using SQL-ish wildcards.

wmic /node:computername /user:adminuser /password:password product where "name like '%j2se%'" call uninstall

... for example would perform a case-insensitive search for *j2se* and uninstall "J2SE Runtime Environment 5.0 Update 12". (Note that in the example above, %j2se% is not an environment variable, but simply the word "j2se" with a SQL-ish wildcard on each end. If your search string could conflict with an environment or script variable, use double percents to specify literal percent signs, like %%j2se%%.)

If wmic prompts for y/n confirmation before completing the uninstall, try this:

echo y | wmic /node:computername /user:adminuser /password:password product where name="whatever" call uninstall

... to pass a y to it before it even asks.

I haven't tested this, but it's worth a shot anyway. If it works on one computer, then you can just loop through a text file containing all the computer names within your organization using a for loop, or put it in a domain policy logon script.

rojo
  • 24,000
  • 5
  • 55
  • 101
  • Hi Rojo - Thank you. I will try this in the AM. I suppose I could use it and apply it via GP. I can't thank you enough. I will see what gives and post my results. Thank you again. Keep everyone posted. – Brian Feb 14 '13 at 04:32
  • Rojo - Tried to enter wmic product get name | sort in a txt file to run as .bat in win7/64 - not working but I'd imagine it's a ID 10 T error (me)....what am I missing? Thx. – Brian Feb 14 '13 at 18:07
  • @Brian - Just run it from a cmd prompt. No need to use a batch file. If you're querying the local machine, the syntax is as I have above. If you're asking a remote machine what it has installed, then you'll have to add a few switches: `wmic /node:computername /user:adminuser /password:password product get name | sort`. If you need more information than name, such as vendor, install location, version, etc, then do `wmic /node:computername /user:adminuser /password:password /output:"path\to\index.html" product list /format:HTABLE` then look at `path\to\index.html` as you ran the command. – rojo Feb 14 '13 at 18:16
  • Thanks. I tried using that command to query the local machine for the program name. I see the program in the uninstall menu but wmic doesn't list it. I do know it's there so I may have to guide users to just run C:\Windows\System32\rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl via a .bat and ask them to uninstall the program manually. Not sure if this program that I need uninstalled failed to register in Windows correctly but the new version does report correctly via wmic's product get name correctly. Seems as if I'm limited with how I can "tell Windows to uninstall". – Brian Feb 17 '13 at 17:59
  • @Rojo-I know the new application product get name is the exact except for the year(i.e. programname 2010 vs. programname 2011). Note the programname 2011 is being queried correctly via vmic get name so I wonder if I just sub out the 2010 and see what gives. All users are local admins. I'd rather do all of this via one .bat at a time but if all else fails, I'll have to just use screenshots, etc...and let it go.I must do this tonight.:-(Maybe I can look at a good installer .exe package utility that'll do all of this automatically...(InstallShield)?Any other tricks I can try? Appreciate the help! – Brian Feb 17 '13 at 18:06
  • @Brian - You can uninstall stuff with wildcard matching using `wmic product where (name like '%program name%') call uninstall`. But if the program doesn't appear in a `wmic product get name` or `wmic product list brief`, I doubt the wildcard matching will work either. Damn. – rojo Feb 18 '13 at 13:51
  • If you have not disallowed remote registry access on your domain, you can use `psinfo` from the [PsTools suite](http://technet.microsoft.com/en-us/sysinternals/bb897550) to query what software is installed, but I'm not sure how you'd uninstall it. Maybe by using the output of `psinfo` to [compose the uninstall string](http://forum.sysinternals.com/remote-uninstall-using-psexec_topic26722.html) for `psexec`? I can't test this, as remote registry access is disallowed on my domain. – rojo Feb 18 '13 at 13:52
  • Well, I had to create a dummies guide for this one. I used a .bat that called the uninstall program menu. Gave step by step for that one part. Once that was done, I could script the rest for silent installs. Was not fun but I made it. I'll look into PSToools Suite. We allow remote registry...But, I think I'm good for now. We have a complex set of apps that all need to work or it's broken firm-wide. I had no option but will see what I can find out for .exe installers, etc.The problem with this program isn't the last. Doesn't seem to create a valid install ref. I cannot thank you enough! – Brian Feb 19 '13 at 19:48
  • If I find out any more cool tricks or tools, I'll let you know. I'll continue my search. I have one year until the next update....:-) Maybe sooner if it wasn't so difficult... – Brian Feb 19 '13 at 19:49
2

Assuming you're dealing with Windows 7 x64 and something that was previously installed with some sort of an installer, you can open regedit and search the keys under

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

(which references 32-bit programs) for part of the name of the program, or

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

(if it actually was a 64-bit program).

If you find something that matches your program in one of those, the contents of UninstallString in that key usually give you the exact command you are looking for (that you can run in a script).

If you don't find anything relevant in those registry locations, then it may have been "installed" by unzipping a file. Because you mentioned removing it by the Control Panel, I gather this likely isn't then case; if it's in the list of programs there, it should be in one of the registry keys I mentioned.

Then in a .bat script you can do

if exist "c:\program files\whatever\program.exe" (place UninstallString contents here)
if exist "c:\program files (x86)\whatever\program.exe" (place UninstallString contents here)
Visruth
  • 3,430
  • 35
  • 48
uniquegeek
  • 21
  • 4
0

In my experience, to use wmic in a script, you need to get the nested quoting right:

wmic product where "name = 'Windows Azure Authoring Tools - v2.3'" call uninstall /nointeractive 

quoting both the query and the name. But wmic will only uninstall things installed via windows installer.

Chris F Carroll
  • 11,146
  • 3
  • 53
  • 61