This is how to do it with a batch file:
- Locate the EXE file or shortcut of the application. I am using MsOffice Excel in this example, in my system the program EXE file is called EXCEL.EXE and it is located in C:\Program Files\Microsoft Office\Office15\ folder
- Open Notepad
- Type these two lines to a new text document, replacing the program or shortcut path with your program or shortcut. If using shortcut, the extension is .lnk:
"C:\Program Files\Microsoft Office\Office15\Excel.exe"
rundll32.exe user32.dll, LockWorkStation
- Save the file to desktop selecting Save as type as All Files, remember to end your chosen filename with extension .bat:
(Click to enlarge.)
That's it. To run the program, Excel in this example, user now double clicks the icon of this batch file on desktop. This opens the program. As soon as user exits the program, Excel in this example, computer is locked.