sayyut Posted January 27, 2009 Posted January 27, 2009 @echo offTitle Check WMI Prosesse and StartTASKLIST | find /i "cleanmgr.exe"if errorlevel==1 goto :cleanmgrgoto :Rep:cleanmgr@echo Start Program cleanmgrstart cleanmgr.exegoto :END:ENDexit:Rep@echo Process on runningpauseexitBATCH FILE I Know.....BUT WSCRIPT I Don'Know..... Help me....-------------------------------------------------------------I wold like Wscript Script Check Processes cleanmgr.exe Running... Loop Every 20 MinBut Process cleanmgr.exe stop I wold like Script Start cleanmgr.exe Quote
Jonnyboy Posted February 13, 2009 Posted February 13, 2009 (edited) This will do the checking and start if necessary. It is better that you set the as a scheduled task instead of looping every 20 minutes. But, I have included a timer loop.Option Explicit Dim objWMIService, objProcess, colProcess Dim strComputer, strList, Running strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") Set colProcess = objWMIService.ExecQuery _ ("Select * from Win32_Process")Do For Each objProcess in colProcess Running = "" If objProcess.Name = "cleanmgr.exe" Then Exit For Running = "False" Next If Running = "False" Then Run "C:\program files\cleanmgr\cleanmgr.exe" wscript.sleep 120000000 Loop Sub Run(ByVal sFile) Dim shell Set shell = CreateObject("WScript.Shell") shell.Run Chr(34) & sFile & Chr(34), 1, false Set shell = Nothing End SubHope this helps.PS - Don't forget to edit the path to the program to run.~Jonnyboy Edited February 13, 2009 by Jonnyboy Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.