2016-04-04 50 views
1

我需要从所有分支机器(32bit & 64位)中删除一个程序,并使用所有机器的注册表修复软件重新安装和更新该软件的版本。似乎并不困难,但我试图使用批处理文件(可能是最简单的)来做到这一点,我坚持检查操作系统版本的一部分。软件删除/使用批处理文件的全新安装

我可以得到一些帮助吗?这里是批次; 几个指针;

  • 检查错误说法是因为我得到一个Windows安装程序错误
  • 的删除目录语句不工作不知道为什么,所以我可能只是倾倒。

代码:

echo off 

:CheckOS (this part not done) 
IF EXIST "%PROGRAMFILES(X86)%" (GOTO disconnect) ELSE (GOTO Fincentric check) 

if exist r:\ goto disconnect 

:disconnect 
net use r: /d 

net use r: \\a0363sfp06\rfsnt 
pause 

:check 
if exist c:\%programfiles%\Fincentric\CAMNet   goto remove01 else 
if exist c:\%programfiles%\Fincentric\BridgeNET v2.3.0 goto remove02 else 
if exist c:\%programfiles%\Fincentric\CAMPlugins  goto remove03 else 
if exist c:\%programfiles%\Fincentric\Canvas   goto remove04 else 
if exist c:\%programfiles%\Fincentric\Platform   goto remove05 else 
if exist c:\%programfiles%\Fincentric\SupportLibraries goto remove06 else 


:remove01 
start /wait msiexec /quiet /qr /uninstall R:\WBDK\WBCAMNet_CGI.msi 
if %ERRORLEVEL% EQU 1721 (
    echo Failure Reason Given is %errorlevel% 
    exit /b %errorlevel% 
) 
:remove02 
start /wait msiexec /quiet /qr /uninstall R:\WBDK\WBBridgeNET.msi 
if %ERRORLEVEL% EQU 1721 (
    echo Failure Reason Given is %errorlevel% 
    exit /b %errorlevel% 
) 
:remove03 
start /wait msiexec /quiet /qr /uninstall R:\WBDK\WBCAMPlugins.msi 
if %ERRORLEVEL% EQU 1721 (
    echo Failure Reason Given is %errorlevel% 
    exit /b %errorlevel% 
) 
:remove04 
start /wait msiexec /quiet /qr /uninstall R:\WBDK\WBCanvas.msi 
if %ERRORLEVEL% EQU 1721 (
    echo Failure Reason Given is %errorlevel% 
    exit /b %errorlevel% 
) 
:remove05 
start /wait msiexec /quiet /qr /uninstall R:\WBDK\WBPlatform.msi 
if %ERRORLEVEL% EQU 1721 (
    echo Failure Reason Given is %errorlevel% 
    exit /b %errorlevel% 
) 
:remove06 
start /wait msiexec /quiet /qr /uninstall R:\WBDK\WBSupportLibraries.msi 
if %ERRORLEVEL% EQU 1721 (
    echo Failure Reason Given is %errorlevel% 
    exit /b %errorlevel% 
) 

:Fincentric check 
cls 
echo Checking if Fincentric folder still exist.... 
if exist c:\%PROGRAMFILES(X86)%\Fincentric 
TIMEOUT /T 3 /NOBREAK 
del /S /Q "c:\Program Files"\fincentric goto alldone 
pause 

:alldone 
echo WDBK 5 has been remove... 
TIMEOUT /T 1 
exit 
rem :remove07 
rem :remove 
rem :remove 

回答

1

的问题是不是与:CheckOS部分,但与:Fincentric check部分。

if声明不完整,并且存在一些错误。这条线:

if exist c:\%PROGRAMFILES(X86)%\Fincentric 

将扩大到

if exist c:\C:\ProgramFiles (x86)\Fincentric 

删除前导c:并把路径名在引号,以确保它不会有空格的问题。它应该是这样的:

if exist "%PROGRAMFILES(X86)%\Fincentric" (
    echo do stuff 
    echo do more stuff 
) 

在你的路径不正确的报价也是你与你del线相同的问题的一部分。另一部分是,你的两个命令之间缺少串联符号&(符号):

del /S /Q "c:\Program Files\fincentric" & goto alldone 

此外,部分标签只认到一个空间,所以:Fincentric check实际上只是被认定为:Fincentric。这看起来不像是目前造成你的麻烦,但它可能在某些情况下。为了安全起见,我会重新命名并删除空间(行:Fincentric_Check:FincentricCheck