0

一部のアプリケーションをアンインストールするスクリプトを作成しようとしています。スクリプトは機能していますが、すべてのプログラムを実行するとプロンプトが表示されます。

アプリケーションが「/S」パラメーターをサポートしているため、サイレント アンインストールを実行できることがわかっています。コマンド プロンプトから uninstall /s コマンドを実行すると、正常に動作します。プロンプトは表示されず、アンインストールされるだけです。

私の問題は、スクリプトで /S パラメータを呼び出すことです。どうやっても、構文エラーが発生し続けます。これは私だけであり、引用符と括弧を理解していないことはわかっていますが、それを機能させるのにうんざりしています。問題は、すべてのパスにスペースが含まれているという事実によって悪化します。これにより、これらのダンクォートがさらに必要になります。うまくいけば、誰かが私が間違っていることを教えてくれます。

また、私は VBS で何をしているのか本当にわからないので、スクリプトの醜さを見逃していただければ幸いです。:-)

「true」パラメーターについても質問があります。これは、次の操作に進む前に現在の操作を完了する必要があることを示していると理解しています。しかし、アンインストールはすべて同時に実行されているようです。「true」パラメータを正しく理解していますか?

サイレント アンインストールのコマンドは次のとおりです。

C:\Program Files\Juniper Networks\Network Connect 7.1.9\uninstall.exe /S

「/S」パラメーターを使用しないスクリプトを次に示します。

'Uninstall Juniper Networks Network Connect 7.1.9

Wscript.Echo "Uninstalling 'Juniper Networks Network Connect 7.1.9'"

Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run ("""C:\Program Files\Juniper Networks\Network Connect 7.1.9\uninstall.exe"""), 1, True
Set objShell = nothing
4

1 に答える 1

0

これが私の自己説明的な解決策です:

' VB Script Document
'http://stackoverflow.com/questions/23569022/trying-to-script-a-silent-uninstall-with-vbscript
option explicit
Dim strResult
strResult = Wscript.ScriptName _
    & vbTab & "Uninstalling 'Juniper Networks Network Connect 7.1.9'"
Dim strCommand, intWindowStyle, bWaitOnReturn, intRetCode
' strCommand 
'   String value indicating the command line you want to run. 
'   You must include any parameters you want to pass to the executable file.
strCommand = """C:\Program Files\Juniper Networks\Network Connect 7.1.9\uninstall.exe"" /S"
'for test only strCommand = """C:\Program Files\Mozilla Firefox\firefox.exe"" -safe-mode"

' intWindowStyle
'   Optional. Integer value indicating the appearance of the program's window. 
'   Note that not all programs make use of this information.
intWindowStyle = 1
' bWaitOnReturn
'   Optional. Boolean value indicating whether the script should wait 
'   for the program to finish executing before continuing 
'   to the next statement in your script. 
'   If set to true, script execution halts until the program finishes, 
'   and Run returns any error code returned by the program. 
'   If set to false (the default), the Run method returns 0 immediately 
'   after starting the program (not to be interpreted as an error code).
bWaitOnReturn = True
strResult = strResult & vbNewLine & strCommand _
  & vbNewLine & CStr( intWindowStyle) _
  & vbNewLine & CStr( bWaitOnReturn)
Wscript.Echo strResult
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
' intRetCode
' The Run method returns an integer
intRetCode = objShell.Run( strCommand, intWindowStyle, bWaitOnReturn)
Set objShell = nothing

Wscript.Echo strResult & vbNewLine & "result=" & CStr( intRetCode)
Wscript.Quit
于 2014-05-09T20:04:38.773 に答える