How to Run My Batch File from Windows 11 Run Box?

0
1
Asked By QuietFalcon123 On

I'm trying to simplify my screenshot process on Windows 11. I created a batch file called "printscreen.bat" to use the NIRCMD tool to mimic the Print Screen function on my keyboard, since my keyboard doesn't have a Print Screen button. The contents of the batch file are as follows:

"c:\Users\USER\Documents\KEEP - Executables, Batchfiles, etc\nircmd\nircmd.exe" sendkeypress rwin+printscreen

It works perfectly when I double-click it, but when I try to run "printscreen" or "printscreen.bat" from the Run box, I get an error saying Windows can't find the file. I've already tried adding the full path to the Environment Variables as well as copying the batch file into the System32 folder, but nothing seems to work. Any ideas?

2 Answers

Answered By TechSavvyNinja On

It sounds like a path issue! You should only add the directory of the batch file to your PATH variable, not the full file path. So, make sure you add just the folder:

C:UsersUSERDocumentsKEEP - Executables, Batchfiles, etcnircmd

Also, if you have any spaces in the folder names, you might need to put quotes around the full batch file path when you try to run it like this:
"C:UsersUSERDocumentsKEEP - Executables, Batchfiles, etcnircmdprintscreen.bat". Another thing to try is to restart the explorer.exe process after changing the PATH variable, just in case it's not recognizing the updates yet.

Answered By BatchWhisperer88 On

You're on the right track! Just a heads-up: in Windows, the Run box is a bit picky with batch files. It often does better with .exe or .cmd files. You can actually create a small .cmd launcher in a folder that's already in your PATH, like C:WindowsSystem32, which calls your batch file, or simply move your printscreen.bat to a different location that doesn’t have spaces in the path. Don't forget to restart your system or log out and back in after changing your PATH to make sure all updates take effect!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.