WScript.Shell 错误“方法”~“对象的“~”失败”

发布于 2024-08-21 15:31:04 字数 373 浏览 4 评论 0原文

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......但是程序崩溃了,

Runtime error '-2147024894 (80070002)' :
method '~' of object '~' failed

基本上我需要schedule.exe安静地运行而不打扰用户。

public sub Main()

Set objShell = CreateObject("WScript.Shell")
strCommand = "C:/Program Files/s/schedule.exe"
objShell.Run strCommand, vbHide, True
Unload Me

end sub

it's supposed to run schedule.exe hidden....but program crashes with

Runtime error '-2147024894 (80070002)' :
method '~' of object '~' failed

basically i need schedule.exe to run silently without interrupting the user.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

星星的軌跡 2024-08-28 15:31:04

如果您引用了 Windows 脚本宿主对象模型,您将收到此更具描述性的错误消息:

Automation error
The system cannot find the file specified. 

这可能会提示您,如果可执行文件名包含如下空格,则必须引用它:

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

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
老旧海报 2024-08-28 15:31:04

您不需要使用 WScript:只需使用 Shell带有 vbHide 参数的 函数。

Shell "C:\Program Files\s\schedule.exe", vbHide

You don't need to use WScript: just use the Shell function with the vbHide argument.

Shell "C:\Program Files\s\schedule.exe", vbHide
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文