VBScript错误问题:预期结束800A03F6

VBScript错误问题:预期结束800A03F6,vbscript,Vbscript,我试图使vbs工作,其想法是它将远程安装一个msi,到一个包含txt文件的机器列表 我遇到了多个错误,第一个是: 参数数量错误或属性分配无效:“WshShell.Exec”第27行,字符1 我似乎已经通过以下方式解决了这个问题: Set WshExec = WshShell.Exec...... 然后得到: 预计报表第27行结束cahr 29 添加和: Set WshExec = WshShell.Exec & "%COMSPEC%..... 现在我明白了: 语句行27字符110的预

我试图使vbs工作,其想法是它将远程安装一个msi,到一个包含txt文件的机器列表

我遇到了多个错误,第一个是:

参数数量错误或属性分配无效:“WshShell.Exec”第27行,字符1

我似乎已经通过以下方式解决了这个问题:

Set WshExec = WshShell.Exec......
然后得到:

预计报表第27行结束cahr 29

添加

Set WshExec = WshShell.Exec & "%COMSPEC%.....
现在我明白了:

语句行27字符110的预期结尾

哪一个是倒数第二个逗号

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

因此,我不确定在这一点上有什么问题,也不确定将整行更改为一组是否正确。

您正在混合.Run和.Exec。.Exec的原型:

object.Exec(strCommand)
表明您需要以下内容:

Set oExec = WshShell.Exec("%COMSPEC% /C COPY " & StrInstallFile & " \" & strComputer & "\C$\Windows\Temp")
如果需要,请改为运行,尝试以下操作:

Dim iRet : iRet = WshShell.Run(strCommand, [intWindowStyle], [bWaitOnReturn]) 
Dim iRet : iRet = WshShell.Run("%comspec% ...", 0, True) 

工作完美谢谢,下面是完整的脚本,以备使用。我还需要添加一些错误检查,以便检查msi是否已完成。嗯,看起来您已从中复制了此代码。
Dim iRet : iRet = WshShell.Run(strCommand, [intWindowStyle], [bWaitOnReturn]) 
Dim iRet : iRet = WshShell.Run("%comspec% ...", 0, True) 
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