简体   繁体   English

如何通过批处理文件创建脚本,如果该程序安装在Windows 7 64位或32位系统上,该脚本将卸载程序

[英]How to Create a script via batch file that will uninstall a program if it was installed on windows 7 64-bit or 32-bit

I am in a small bind. 我处于困境中。 The program in question can be installed in the program files directory (64bit) or X86 path. 可以将有问题的程序安装在程序文件目录(64位)或X86路径中。 The program is already installed in over 200 machines. 该程序已经安装在200多台计算机中。 I am fairly certain the default install path was X86 as that's the default. 我相当确定默认安装路径是X86,因为这是默认安装路径。 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. 安装此文件的原始系统管理员未使用.msi,因此我只能找到“ C:\\ Program Files \\ InstallShield安装信息{78AC336D-25F6-4916-A711-2EA2F69E0319} \\ setup “ .exe”作为一个实用程序提供的命令,用于远程卸载我找到的所说应用程序。该命令无法正常工作,我无法尝试将其发布,希望它能正常工作。

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? 鉴于此问题,是否有一种方法可以通过脚本来卸载程序,该脚本将检查程序文件和X86路径并根据位置进行卸载? OR, is there a script that will just flat out uninstall the program regardless without the concern for the X86/program original install location. 或者,是否有一个脚本可以完全卸载该程序,而不用担心X86 /程序的原始安装位置。 I just need to uninstall it period across all of these machines. 我只需要在所有这些计算机上卸载它就可以了。 The install .bat is good to go. 安装.bat很好。 What I cannot do is just get window to uninstall X application via a script for 32 or 64 bit machines. 我不能做的就是通过32或64位计算机的脚本获取通过窗口卸载X应用程序的窗口。

I've tried MsiExec.exe /X{78AC336D-25F6-4916-A711-2EA2F69E0319} /quiet with no go. 我已经尝试了MsiExec.exe / X {78AC336D-25F6-4916-A711-2EA2F69E0319} / quiet。 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. 这次我可以尝试安装.msi,但是迷路了,我的知识受到脚本或任何卸载脚本的限制,这些脚本无法告诉“最终用户”,而使他们困惑,只需单击此处即可。 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? 如果不是原始的.msi,关于如何编写此卸载脚本的任何想法,我不确定如何使某些工作正常? 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 问候,布莱恩

wmic can call an uninstaller. wmic可以调用卸载程序。 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. 您也可以使用SQL类通配符进行卸载。

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". ...例如,将对*j2se*执行不区分大小写的搜索,然后卸载“ 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%% .) (请注意,在上面的示例中, %j2se%不是环境变量,而只是两端带有SQL ish通配符的单词“ j2se”。如果您的搜索字符串可能与环境或脚本变量冲突,请使用双百分数指定文字百分号,例如%%j2se%% 。)

If wmic prompts for y/n confirmation before completing the uninstall, try this: 如果WMIC提示y/n确认完成卸载之前,试试这个:

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. ...甚至在要求之前就将y传递给它。

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. 如果它在一台计算机上工作,则可以使用for循环遍历包含组织内所有计算机名称的文本文件,或将其放入域策略登录脚本中。

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 假设您使用的是Windows 7 x64,并且以前使用某种安装程序进行了安装,则可以打开regedit并在下面搜索密钥

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

(which references 32-bit programs) for part of the name of the program, or (引用32位程序)作为程序名称的一部分,或者

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

(if it actually was a 64-bit program). (如果它实际上是一个64位程序)。

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). 如果您在其中一个程序中找到与您的程序相匹配的内容,则该键中UninstallString的内容通常会为您提供您正在查找的确切命令(可以在脚本中运行)。

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 然后,您可以在.bat脚本中执行

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)

In my experience, to use wmic in a script, you need to get the nested quoting right: 以我的经验,要在脚本中使用wmic ,您需要正确获得嵌套引用:

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. 但是wmic只会卸载通过Windows Installer安装的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows 7,64位中卸载以前安装的OpenCV - How to uninstall previously installed OpenCV in Windows 7, 64-bit 将32位Windows驱动程序端口移植到64位Windows - Port 32-Bit Windows driver to 64-Bit Windows VBS脚本可在32位XP上运行,但不能在7 64位上运行 - VBS script works on XP 32-bit but not on 7 64-bit Solr - 在Windows 7 64位上使用64位Java,而不是32位Java - Solr - use 64-bit Java, not 32-bit Java on Windows 7 64-bit Windows XP 32位到Windows 7 64位上的PowerBuilder 10.5应用程序 - PowerBuilder 10.5 Application on Windows XP 32-bit to Windows 7 64-bit 如何在32位C#应用程序中读取注册表,以便注册表重定向在64位Windows 7上有效 - How do I read the registry in 32-bit c# app such that registry redirection works on 64-bit Windows 7 从32位升级到64位 - Going from 32-bit to 64-bit 使用MAC Parallels Windows 7在64位操作系统上安装IIS Express 32位 - Installing IIS Express 32-bit on a 64-bit operating system using MAC Parallels Windows 7 32位dll在64位os中不起作用 - 32-bit dll not working in 64-bit os Python在Windows 8.1 64位系统上错误地检测到32位系统 - Python incorrectly detects 32-bit system on Windows 8.1 64-bit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM