否则如果是批处理文件

时间:2013-10-14 12:23:31

标签: windows batch-file

我需要自动静音使用本机安装程序更新空中应用程序,因此我制作了这个批处理文件:

IF EXIST "%PROGRAMFILES(X86)%" (
taskkill /IM Application.exe
taskkill /IM adl.exe
wmic product where name="Application" call uninstall /nointeractive
"%HOMEPATH%\AppData\Roaming\com.application\Local Store\Application.exe" -silent -eulaAccepted -location "\%PROGRAMFILES(x86)%\" -desktopShortcut
"%PROGRAMFILES(x86)%\Applicaion\Application.exe"
taskkill /F /IM cmd.exe 
) ELSE (
taskkill /IM Application.exe 
taskkill /IM adl.exe
wmic product where name="Application" call uninstall /nointeractive
"%HOMEPATH%\AppData\Roaming\com.Application\Local Store\Application.exe" -silent -eulaAccepted -location "\%PROGRAMFILES%\" -desktopShortcut
"%PROGRAMFILES%\Application\Application.exe"
taskkill /F /IM cmd.exe ) 

我在64位Windows上测试了它,所以%PROGRAMFILES(x86)%“确实存在,它卸载了软件,但没有安装新的软件,它在Windows 32bit上根本不起作用

1 个答案:

答案 0 :(得分:2)

@ECHO OFF &SETLOCAL
IF DEFINED PROGRAMFILES(X86) (SET "PROGRAMFOLDER=%PROGRAMFILES(X86)%") ELSE SET "PROGRAMFOLDER=%PROGRAMFILES%"
taskkill /IM Application.exe
taskkill /IM adl.exe
wmic product where name="Application" call uninstall /nointeractive
"%HOMEPATH%\AppData\Roaming\com.application\Local Store\Application.exe" -silent -eulaAccepted -location "\%PROGRAMFOLDER%\" -desktopShortcut
"%PROGRAMFOLDER%\Application\Application.exe"
taskkill /F /IM cmd.exe