因此,對我的業務和員工至關重要的應用程序是我們的時鐘。它是多年前設計的一個更大的RMS系統的exe部分。當您進入或退出時,應用程序會自動關閉。我創建了一個桌面快捷方式,以便更快地打開,但我想知道是否有辦法用Windows腳本來完成此操作。Windows腳本(VBS)總是使應用程序保持開放
基本參數:
在計算機啓動時,腳本運行和clock.exe應用程序打開
如果在任何時候,clock.exe關閉或停止; clock.exe將被腳本重新打開。
我自己搞砸了腳本,並設法讓腳本打開應用程序,但我試圖用一個循環來監視導致許多時鐘應用程序打開的過程,並最終由於過載而關閉了計算機。
option explicit
DIM strComputer,strProcess
strComputer = "." ' local computer
strProcess = "clock.exe"
' Check if Calculator is running on specified computer (. = local computer)
if isProcessRunning(strComputer,strProcess) then
CreateObject("WScript.Shell").Run("""C:\Users\FrontDesk1\Documents\alwaysClock.vbs""")
else
CreateObject("WScript.Shell").Run("""C:\RMS\pos\clock.exe""")
end if
' Function to check if a process is running
function isProcessRunning(byval strComputer,byval strProcessName)
Dim objWMIService, strWMIQuery
strWMIQuery = "Select * from Win32_Process where name like '" & strProcessName & "'"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
if objWMIService.ExecQuery(strWMIQuery).Count > 0 then
isProcessRunning = true
else
isProcessRunning = false
end if
end function
CreateObject("WScript.Shell").Run("""C:\Users\FrontDesk1\Documents\alwaysClock.vbs""")
此運行'Program.exe'在infinte洛op ??? – Hackoo
程序退出時,腳本會重新啓動它。 – 2016-07-29 07:58:26
啊好吧,我現在看到它!聰明的想法! – Hackoo