执行VBS脚本后关闭控制台
问题描述:
我有一个多屏幕计算机系统。有一段时间,由于我不明白的原因,对话框显示在错误的显示器上。例如,我将在监视器A中运行一个程序,并在显示器D中打开一个OK框。这非常令人沮丧。执行VBS脚本后关闭控制台
我发现了一个VBS脚本称为“PositionDialogs.vbs”这里找到:https://www.realtimesoft.com/ultramon/scripts/
Const SNAP_TO_MONITOR = False 'set this to True to ensure dialogs aren't placed between two monitors
Const INTERVAL = 2 'number of seconds the script waits before enumerating open windows again
Set sys = CreateObject("UltraMon.System")
Set wnd = CreateObject("UltraMon.Window")
Set wndParent = CreateObject("UltraMon.Window")
'create the two maps used to store positioned windows
Set arrAdd = CreateObject("Scripting.Dictionary")
Set arrLookup = CreateObject("Scripting.Dictionary")
Do While True
'enumerate all application windows
For Each w In wnd.GetAppWindows(True)
If w.HWndParent <> 0 Then
wndParent.HWnd = w.HWndParent
move = True
If arrLookup.Exists(w.HWnd) = True Then move = False
arrAdd.Add w.HWnd, 0
If move = True Then
If SNAP_TO_MONITOR = False Then
If w.Monitor <> wndParent.Monitor Then
w.Monitor = wndParent.Monitor
w.ApplyChanges 1 + 2 'WNDCHANGE_RESIZE_TO_FIT + WNDCHANGE_CLIP_TO_WORKSPACE
End If
Else
Set parentMon = sys.Monitors(wndParent.Monitor - 1)
parentLeft = parentMon.WorkLeft
parentTop = parentMon.WorkTop
parentRight = parentLeft + parentMon.WorkWidth
parentBottom = parentTop + parentMon.WorkHeight
dlgLeft = w.Left
dlgTop = w.Top
dlgRight = dlgLeft + w.Width
dlgBottom = dlgTop + w.Height
If dlgLeft < parentLeft Then
w.Left = parentLeft
ElseIf dlgRight > parentRight Then
w.Left = parentRight - w.Width
End If
If dlgTop < parentTop Then
w.Top = parentTop
ElseIf dlgBottom > parentBottom Then
w.Top = parentBottom - w.Height
End If
w.ApplyChanges 0
End If
End If
End If
Next
'swap maps, then clear arrAdd. this way we don't have entries for windows which no longer exist
Set temp = arrLookup
Set arrLookup = arrAdd
Set arrAdd = temp
Set temp = Nothing
arrAdd.RemoveAll
WScript.Sleep INTERVAL * 1000
Loop
,将移动对话框到任何显示器的说法。 我使用批处理文件在Windows启动时运行它,并将其作为进程运行。我的问题是,显示的控制台窗口不会消失,除非我单击X关闭它。
浴文件看起来是这样的:
wscript PositionDialogs.vbs
exit
我以为有什么我可以添加到脚本,使其自身加载到内存中结束后?如果是这样,什么?
答
aschipf是正确的。 我做了批处理文件
start PositionDialogs.vbs
exit
(使用START代替WScript的),并将其关闭如预期,而过程中仍然在任务管理器中运行
尝试使用'cscript'而不是'wscript' .. 。 – aschipfl
它连续运行。 – 2016-04-25 22:52:15
并在开始 - 运行对话框(Winkey + R)中输入它 – 2016-04-26 00:36:44