【问题标题】:How to hide Windows Script Host window?如何隐藏 Windows 脚本宿主窗口?
【发布时间】:2016-02-27 19:44:24
【问题描述】:

我今天开始使用名为“oblytile”的程序,它使您能够在 Windows 8/8.1 中将自定义磁贴添加到 Metro UI。该程序运行良好,但是当我打开创建的 tile 到文件夹、程序、文件等时,我遇到了一个大问题。一小段时间会弹出一个黑色的小窗口(如 CMD),如下所示:

窗口消失后,我想要的程序打开。我看过一些 YouTube 视频,而其他人没有这样的东西。我检查了一个程序存储有关磁贴数据的文件夹,我发现每次在 Metro UI 中单击自定义磁贴时,都会启动 VBScript。

示例图块 VBScript:

On Error Resume Next
Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strApp = "C:\Users\bluea_000\OneDrive"

arrPath = Split(strApp, "\")

For i = 0 to Ubound(arrPath) - 1
    strAppPath = strAppPath & arrPath(i) & "\"
Next 

objShell.CurrentDirectory = strAppPath
objShell.Run """C:\Users\bluea_000\OneDrive""" & ""
If Err.Number <> 0 Then
    If InStr(1, strApp, "/") > 0 then
    Else
        If InStr(1, strApp, "www.") > 0 then
        Else
            If InStr(1, strApp, "shell:") > 0 then
            Else
                If objFSO.folderExists(strApp) Then
                Else
                    If objFSO.FileExists(strApp) Then
                    Else
                        MsgBox strApp & " not found", 16, "OblyTile"
                    End If
                End If
            End If
        End If
    End If
    Err.Clear
End If

谁能告诉我如何隐藏或修复这个黑色窗口?

我在论坛上询问了程序是在哪里发布的,但可能该项目已被放弃,没有人会回答我。

【问题讨论】:

    标签: windows vbscript wsh


    【解决方案1】:

    vbs 文件有两个解释器。 Wscript 和 cscript。

    Cscript 是基于命令行的脚本宿主,因此会打开黑色控制台窗口,wscript 是基于 Windows 的脚本宿主,不会打开命令行窗口。

    使用 wscript 执行你的脚本,不会弹出黑窗。

    https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/wsh_runfromwindowsbasedhost.mspx

    【讨论】:

    • 我像你说的那样将 wscript 设置为执行脚本的默认程序,但它没有锻炼,我尝试用 cscript 代替 wscript,它不会弹出窗口。如果有人遇到同样的问题,只需以管理员身份在 cmd 中输入:cscript //H:cscript //S
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-08
    • 1970-01-01
    • 1970-01-01
    • 2012-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多