WScript.Shell 错误“对象 '~' 的方法 '~' 失败" [英] WScript.Shell error "method '~' of object '~' failed"
本文介绍了WScript.Shell 错误“对象 '~' 的方法 '~' 失败"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public sub Main()
Set objShell = CreateObject("WScript.Shell")
strCommand = "C:/Program Files/s/schedule.exe"
objShell.Run strCommand, vbHide, True
Unload Me
end sub
它应该运行 schedule.exe 隐藏....但是程序崩溃了
it's supposed to run schedule.exe hidden....but program crashes with
Runtime error '-2147024894 (80070002)' :
method '~' of object '~' failed
基本上我需要 schedule.exe 在不打扰用户的情况下静默运行.
basically i need schedule.exe to run silently without interrupting the user.
推荐答案
如果您有对 Windows Script Host Object Model
的引用,您将收到以下更具描述性的错误消息:
If you had a reference to Windows Script Host Object Model
you would get this more descriptive error message:
Automation error
The system cannot find the file specified.
这可能会提示您,如果可执行文件名包含这样的空格,您必须引用它:
This might clue you that you had to quote the executable filename if it contains spaces like this:
Public Sub Main()
Dim objShell As Object ' WshShell
Dim strCommand As String
Set objShell = CreateObject("WScript.Shell")
strCommand = "C:/Program Files/7-zip/7z.exe"
objShell.Run """" & strCommand & """", vbHide, True ' WshHide
End Sub
这篇关于WScript.Shell 错误“对象 '~' 的方法 '~' 失败"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文