Liza
Liza

Reputation: 19

Create A Batch File from a Notepad to CMD

I want to create a batch file that automatically runs the code in cmd see the picture below

The 1st cmd is a batch file that got error while the 2nd cmd is a manually type in cmd and executes the codes.

This is the code in notepad/batch file

cmd /K "cd C:\Program Files\Nvidia Corporation\NVSMI>nvidia-smi --query-gpu=index,timestamp,power.draw,clocks.sm,clocks.mem,clocks.gr --format=csv -l 1"

Edit: I want to run this batch file in desktop because I don't want to manually go to the folder of the .exe and paste the code (waste of time) so that's why I like to create a batch file that i'll run in desktop

This Picture

Upvotes: 0

Views: 672

Answers (1)

Stephan
Stephan

Reputation: 56180

cmd /K "cd C:\Program Files\Nvidia Corporation\NVSMI>nvidia-smi --query-gpu=index,timestamp,power.draw,clocks.sm,clocks.mem,clocks.gr --format=csv -l 1"

you misinterpreted the first part C:\Program Files\Nvidia Corporation\NVSMI> (which is the prompt) with a part of the command.

Either call the program with it's full path:

    cmd /K "C:\Program Files\Nvidia Corporation\NVSMI\nvidia-smi --query-gpu=index,timestamp,power.draw,clocks.sm,clocks.mem,clocks.gr --format=csv -l 1"

or cd to the correct folder and & execute the program from there:

    cmd /K "cd /d C:\Program Files\Nvidia Corporation\NVSMI & nvidia-smi --query-gpu=index,timestamp,power.draw,clocks.sm,clocks.mem,clocks.gr --format=csv -l 1"

In both cases, look what Ive done with the>`

Upvotes: 1

Related Questions