如何隐藏Windows脚本宿主窗口?

时间:2016-02-27 19:44:25

标签: windows vbscript wsh

我今天开始使用一个名为" oblytile"的程序,它使您能够在Windows 8 / 8.1中向Metro UI添加自定义切片。该程序工作正常,但是当我打开创建的磁贴到文件夹,程序,文件等短时间内弹出一个小的黑色窗口(如CMD)时,我有一个大问题,就像这里:

http://i.imgur.com/ZDYBxBc.png

窗口消失后,我想要的程序打开。我观看了一些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

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

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

1 个答案:

答案 0 :(得分:0)

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

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

使用wscript执行脚本,不会弹出黑色窗口。

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

相关问题