Before this COVID-19 thing happened, the desktop sitting on my desk runs for ever. I usally run some expensive jobs over night and came back to check the results in the next morning. Nowaways, the PCs are very different from the old days machines that require a regular restart from time to time. However, while working on a laptop since the lockdown started it's impossible to keep the laptop running all the time. So I have to start all the applications at the beginning of my working days and close them in the afternoon. If your work is to surf the internet and gather data, it's absolutely fine to click one button and job's done. But if your work relates to multiple applications, it is a bit annoying. I need to find a way of doing that automatically. There are some nice software that you can rely on (someone recommends AutoHotKey although I didn't try it). I'd like to do it lightweightly, say using batch file (in command line). Here we go! The starting applications batch
@echo off :checkOutlook QPROCESS "outlook.exe" > NUL IF %ERRORLEVEL% EQU 0 GOTO outlookRun echo running outlook start "" /b /max "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE" goto checkOnenote :outlookRun echo outlook is already running :checkOnenote QPROCESS "onenote.exe" > NUL IF %ERRORLEVEL% EQU 0 GOTO onenoteRun echo running onenote start "" /b /max "C:\Program Files\Microsoft Office\root\Office16\ONENOTE.EXE" goto checkVS :onenoteRun echo onenote is already running :checkVS QPROCESS "devenv.exe" > NUL IF %ERRORLEVEL% EQU 0 GOTO vsRun echo running vs studio start "" /b /max "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe" goto checkEdge :vsRun echo visual studio is already running :checkEdge QPROCESS "msedge.exe" > NUL IF %ERRORLEVEL% EQU 0 GOTO edgeRun echo running edge start "" /b /max "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" goto checkTC :edgeRun echo edge is already running :checkTC QPROCESS "totalcmd64.exe" > NUL IF %ERRORLEVEL% EQU 0 GOTO tcRun echo running total command start "" /b "C:\totalcmd\TOTALCMD64.EXE" goto checkVSCode :tcRun echo tc is already running :checkVSCode QPROCESS "code.exe" > NUL IF %ERRORLEVEL% EQU 0 GOTO vscodeRun echo running vs code start "" /b /max "C:\Program Files\Microsoft VS Code\bin\code.cmd" goto checkMSteams :vscodeRun echo vs code is already running :checkMSteams QPROCESS "Teams.exe" > NUL IF %ERRORLEVEL% EQU 0 GOTO teamsRun echo running ms team start "" /b /max "C:\Users\xenos\AppData\Local\Microsoft\Teams\Update.exe" --processStart "Teams.exe" goto checkNPP :teamsRun echo ms team is already running :checkNPP QPROCESS "notepad++.exe" > NUL IF %ERRORLEVEL% EQU 0 GOTO nppRun echo running notepad++ start "" /b /max "C:\Program Files\Notepad++\notepad++.exe" goto theEnd :nppRun echo notepad++ is already running :theEnd exit 0And the closing applications batch:
@echo off :checkOutlook QPROCESS "outlook.exe" > NUL IF %ERRORLEVEL% NEQ 0 GOTO checkOnenote taskkill /F /IM outlook.exe :checkOnenote QPROCESS "onenote.exe" > NUL IF %ERRORLEVEL% NEQ 0 GOTO checkVS taskkill /F /IM onenote.exe :checkVS QPROCESS "devenv.exe" > NUL IF %ERRORLEVEL% NEQ 0 GOTO checkVSCode taskkill /F /IM devenv.exe :checkVSCode QPROCESS "code.exe" > NUL IF %ERRORLEVEL% NEQ 0 GOTO checkMSteams taskkill /F /IM code.exe :checkMSteams QPROCESS "Teams.exe" > NUL IF %ERRORLEVEL% NEQ 0 GOTO checkEdge taskkill /F /IM Teams.exe :checkEdge QPROCESS "msedge.exe" > NUL IF %ERRORLEVEL% NEQ 0 GOTO checkTC taskkill /F /IM msedge.exe :checkTC QPROCESS "totalcmd64.exe" > NUL IF %ERRORLEVEL% NEQ 0 GOTO checkNX taskkill /F /IM totalcmd64.exe :checkNX QPROCESS "ugraf.exe" > NUL IF %ERRORLEVEL% NEQ 0 GOTO checkNPP taskkill /F /IM ugraf.exe :checkNPP QPROCESS "notepad++.exe" > NUL IF %ERRORLEVEL% NEQ 0 GOTO theEnd taskkill /F /IM notepad++.exe :theEnd :exit
No comments :
Post a Comment