Friday 15 April 2011

windows - Batch file - Stopping services except for listed -



windows - Batch file - Stopping services except for listed -

i remote computers , drop few files in repair computer. have batch file stops running programs except contained in batch file.

i go though each services , stop except few in batch file making virtual safe mode. skip service if isn't running. (and echo if running or not) have run few time stop dependencies manually needed. have similar programme uses external text files services leave running, have single files services contained within batch file the code below.

can scratch out me? appreciate it!

(thanks bharat) /f "skip=3 tokens=1" %%i in ('tasklist /fi "username eq %userdomain%\%username%" /fi "status eq running"') ( if not "%%i"=="svchost.exe" ( if not "%%i"=="explorer.exe" ( if not "%%i"=="cmd.exe" ( if not "%%i"=="tasklist.exe" ( echo. taskkill /f /im "%%i" echo. ) ) ) ) )

i completed script more research. know ugly allows me run on remote computer, plus room growth. has built in ignore list, deletes temp files , opens folders confirm other areas empty. why not powershell? know less windows command. wanted share , improvement.

@echo off title kill running apps color 0a :start cd c:\windows\system32 /f "skip=3 tokens=1" %%i in ('tasklist /fi "username eq %userdomain%\%username%" /fi "status eq running"') ( echo %%i if not "%%i"=="svchost.exe" ( if not "%%i"=="explorer.exe" ( if not "%%i"=="cmd.exe" ( if not "%%i"=="tasklist.exe" ( if not "%%i"=="notepad.exe" ( if not "%%i"=="dllhost.exe" ( if not "%%i"=="cis.exe" ( if not "%%i"=="cistray.exe" ( if not "%%i"=="cmd.exe" ( if not "%%i"=="taskmgr.exe" ( if not "%%i"=="conhost.exe" ( ::desktop windows manager if not "%%i"=="dwm.exe" ( if not "%%i"=="tv_w32.exe" ( if not "%%i"=="tv_x64.exe" ( if not "%%i"=="teamviewer.exe" ( if not "%%i"=="taskmgr.exe" ( if not "%%i"=="cmd.exe" ( if not "%%i"=="cmd.exe" ( if not "%%i"=="cmd.exe" ( if not "%%i"=="cmd.exe" ( if not "%%i"=="cmd.exe" ( if not "%%i"=="cmd.exe" ( if not "%%i"=="cmd.exe" ( echo. echo %%i ping -n 2 -w 1 127.0.0.1>nul taskkill /f /im "%%i" ping -n 2 -w 1 127.0.0.1>nul echo. ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) :open explorer.exe "%userprofile%\appdata\local\microsoft\windows\temporary net files\" explorer.exe "%userprofile%\appdata\local\temp\" explorer.exe %windir%\temp :delete echo.&echo.&echo empty temp files. ::=========delete temp files========= ::empty user temp folder cd /d %temp% echo.&echo.&echo deleting files....... /d %%d in (*) rd /s /q "%%d" del /f /q * ::empty admin temp folder echo.&echo.&echo empty windows temp file cd /d %windir%\temp\ ::dir /w echo.&echo.&echo deleting files....... /d %%d in (*) rd /s /q "%%d" del /f /q * goto folders :folders echo turn off processes taskmgr msconfig taskschd.msc ping -n 5 -w 1 127.0.0.1>nul :eof

windows batch-file service

No comments:

Post a Comment