0

私はvbsを機能させようとしています。アイデアは、txtファイルに含まれているマシンのリストにmsiをリモートでインストールすることです。

複数のエラーが発生します。最初のエラーは次のとおりです。

引数の数が間違っているか、プロパティの割り当てが無効です: "WshShell.Exec"行27、文字1

WshShell.Exec "%COMSPEC% /C COPY " & StrInstallFile & " \\" & strComputer _
  & "\C$\Windows\Temp", 0, TRUE 

私はこれを次のように回避したようです:

Set WshExec = WshShell.Exec......

その後、得た:

ステートメント行の予想される終了27cahr29

を追加する&

Set WshExec = WshShell.Exec & "%COMSPEC%.....

今私を取得します:

ステートメント行27文字110の予想される終わり

最後から2番目のコンマです

Set WshExec = WshShell.Exec & "%COMSPEC% /C COPY" & StrInstallFile _
  & " \\" & strComputer & "\C$\Windows\Temp", 0, TRUE

ですから、この時点で何が悪いのか、そして行全体をセットに変更することが正しいことであったかどうかはわかりません。

4

2 に答える 2

0

.Runと.Execを混在させています。.Execのプロトタイプ:

object.Exec(strCommand)

次のようなものが必要であることを示しています。

Set oExec = WshShell.Exec("%COMSPEC% /C COPY " & StrInstallFile & " \" & strComputer & "\C$\Windows\Temp")

代わりに.Runが必要な場合は、次のようにしてみてください。

Dim iRet : iRet = WshShell.Run(strCommand, [intWindowStyle], [bWaitOnReturn]) 
Dim iRet : iRet = WshShell.Run("%comspec% ...", 0, True) 
于 2013-02-19T11:06:52.803 に答える
0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("MachineList.Txt", 1)
StrInstallFile="install_flash_player_11_active_x.msi"
StrNoUpdateFile="mms.cfg"
StrInstallCMD="msiexec.exe /qn /i "

Do Until objFile.AtEndOfStream

strComputer = objFile.ReadLine

' --------- Check If PC is on -------------
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshExec = WshShell.Exec("ping -n 1 -w 1000 " & strComputer) 'send 3 echo requests, waiting 2secs each
strPingResults = LCase(WshExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then

' ---------- Successful ping - run remote commands  ----------------

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")


' --------- Copy msi to windows temp folder
Set oExec = WshShell.Exec("%COMSPEC% /C COPY " & StrInstallFile & " \\" & strComputer & "\C$\Windows\Temp")

' --------- execute msi file on remote machine
Set oExec = WshShell.Exec("%COMSPEC% /C psexec  \\" & StrComputer & " " & strInstallCMD & "c:\Windows\Temp\" & StrInstallFile)

' --------- Copy no "no update" file to remote machine, first line is for win7, second for xp
Set oExec = WshShell.Exec("%COMSPEC% /C COPY " & StrNoUpdateFile & " \\" & strComputer & "\C$\Windows\SysWOW64\Macromed\Flash")
Set oExec = WshShell.Exec("%COMSPEC% /C COPY " & StrNoUpdateFile & " \\" & strComputer & "\C$\Windows\system32\macromed\flash")

Else

' ---------- Unsuccessful ping - Leave computer name in MachineList.txt and continue ----------------

strNewContents = strNewContents & strComputer & vbCrLf

End If
Loop

objFile.Close

Set objFile = objFSO.OpenTextFile("MachineList.txt", 2)
objFile.Write strNewContents
objFile.Close
于 2013-02-20T09:21:18.710 に答える