1

I'd like to use nircmd to take a screenshot with the full date and time as the file name. Here's what I'm doing:

nircmd.exe savescreenshot c:\screenshots\%date%-%time%.jpg

This creates a file called "Fri.jpg".

Sparky1
  • 2,945
  • 6
  • 22
  • 27

3 Answers3

2

Add quotations around the file path and name to keep spaces from separating the string. Also the date and time variables contain invalid file name characters which have to be removed or replaced.

nircmd.exe savescreenshot "c:\screenshots\%date:/=-%-%time::=-%.jpg"
David Ruhmann
  • 10,344
  • 2
  • 32
  • 46
1

In case someone googling comes upon this, following the answers of David Ruhmann and Proxyma, I added a bit of code to take screenshot of two Monitor/Screens in individuals files.

I added some coordinates to the options and modifiend the first line so that the box of CMD will be more smaller than before.

MODE CON COLS=18 LINES=1
cd /d %~dp0
md screenshots > nul
nircmd.exe savescreenshot  "screenshots\%date:/=-%-%time::=-%.jpg" -1920 0 1920 1080
nircmd.exe savescreenshot  "screenshots\%date:/=-%-%time::=-%.jpg" 0 0 1920 1080

The 4th line is for the left monitor and the 5th line is for the right monitor, I'm not sure but I think this would work with a setup of 3 monitors if you copy paste the last line and change the first "0" for 1920(or your resolution), but I'm not sure.

In my case, I'm using a program for HotKeys (HotKeyboard Trial) and using "F1" to execute the ".bat" file, this only works when I have "nircmd.exe" in the same root as the ".bat" file, dosen't work when I have it in C:\Windows\System32, but this only happen when I'm using that program.

The followings images are the result:

The UI of the program I mentioned above

The folder that contanis the .bat file

The folder that contains the images

Yaw
  • 11
  • 2
0

Following David Ruhmann's recommendation and also 1,2,and 3 I created a very useful for my purposes cmd tool (takeScreenshot.cmd)

MODE CON COLS=30 LINES=2
cd /d %~dp0
md screenshots > nul
nircmd.exe savescreenshot "screenshots\%date:/=-%-%time::=-%.jpg"

I run it using desktop shortcut from the same directory with nircmd.exe

enter image description here

Proxyma
  • 13
  • 5