vbscript语句不匹配字符串失败
我正在运行下面链接中列出的脚本 我已将Msgbox替换为以下内容:vbscript语句不匹配字符串失败,vbscript,hta,Vbscript,Hta,我正在运行下面链接中列出的脚本 我已将Msgbox替换为以下内容: if (daysLeft < warningDays) and (daysLeft > -1) then strCMD = "\\domain\netlogon\PwExpChk\PWReminder.hta" -13 Set wshShell = CreateObject("Wscript.Shell") RC = WshShell.run(strCMD , 0, False)
if (daysLeft < warningDays) and (daysLeft > -1) then
strCMD = "\\domain\netlogon\PwExpChk\PWReminder.hta" -13
Set wshShell = CreateObject("Wscript.Shell")
RC = WshShell.run(strCMD , 0, False)
End if
我使用mshta.exe手动运行该命令,该命令运行成功。如果我删除-13,它将成功运行
生成的错误是“类型不匹配:'[string”\\domain\netlogon\']'
…需要有-13,任何帮助都会很好
从下面编辑添加代码
我尝试了下面的一个,它调用了hta文件…现在hta文件出错了
if (daysLeft < warningDays) and (daysLeft > -1) then
strCMD = "\\domain\netlogon\PwExpChk\PWReminder.hta" & " -" & intDaysRemaining
Set wshShell = CreateObject("Wscript.Shell")
RC = WshShell.run(strCMD , 0, False)
End if
如果(daysLeft-1),则
strCMD=“\\domain\netlogon\pwepchk\pwemprementer.hta”&intDaysRemaining
设置wshShell=CreateObject(“Wscript.Shell”)
RC=WshShell.run(strCMD,0,False)
如果结束
这将解决您的语法错误
将有问题的行更改为
strCMD = "\\domain\netlogon\PwExpChk\PWReminder.hta -13"
编辑-如果需要引号,请使用双引号
strCMD = """\\domain\netlogon\PwExpChk\PWReminder.hta""" & " -13"
vbscript认为您想从字符串中减去13将其放在双引号内,并在.htaso后添加空格,使其类似于:strCMD=“”\domain\netlogon\pwepchk\pwemplementr.hta“-13“那是错的-什么是-13?它是一个参数吗?hta文件中有一个计算,因此-13I失败的原因,我在下面的链接中发布了两个脚本和更多细节,它应该有助于可视化我正在尝试做的事情。我像那样运行它,但它不起作用,即使我手动运行它也不会手动运行-所以不要那样尝试。你说你想让它从你的脚本运行-复制/粘贴我的代码-或更新你的代码以准确显示你正在使用的内容我尝试了,但没有成功,我尝试了下面的一个,它调用了hta文件。。。现在hta文件出错了。如果(daysLeft
Debug.Print strCMD
,则结束,在你调用它之前-并将这些结果复制/粘贴到你的问题中。然后成功地从命令行复制您手动调用它的映像。然后复制/粘贴调试结果。将结果打印到命令行并显示结果
strCMD = """\\domain\netlogon\PwExpChk\PWReminder.hta""" & " -13"