Jump to content

I want to create a basic program

Dunkan77
Go to solution Solved by mariushm,

The program is nvidia-smi.exe and what comes after are called parameters or arguments

 

so you enter something like this in your .bat file:


 

C:

CD "C:\Program Files\NVIDIA Corporation\NVSMI"

nvidia-smi.exe -i 0 --loop-ms=1000 --format=csv,noheader --query-gpu=power.draw > output.txt

first line moves the "action" to the c: partition if the .bat file is started from another partition

2nd line sets the working folder to that one

3rd line starts a program called nvidia-smi.exe with the parameters that follow and the output is redirected from screen to file called output.txt

 

if the full path is omitted, the file is created in the current folder, set with the cd command , so output.txt will be created in the same folder where nvidia-smi.exe is located

 

You can work around having to set the folder by always entering the full paths:

 

"C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi.exe" -i 0 --loop-ms=1000 --format=csv,noheader --query-gpu=power.draw > "c:\temp\output.txt"

 

Hello guys,

I wanted to create a basic program like a batch file that opens a Command prompt window in a specific location and runs a command. Then I would like it to log everything it outputs. If you wanna know, I'm trying to run a command that displays power usage for Nvidia GPU's in actual watts and not a TDP percentage. The latter has been rendered useless with my custom BIOS since the max TDP isn't the same anymore.

It has to run a command prompt in a specific location and type in a command. This will make it output every second, the power consumption and I want it to log the values. How can I create such a program? It's very basic but I know nothing about programming :( . Any help is appreciated

Link to comment
Share on other sites

Link to post
Share on other sites

cd c:\folder_location
run command here >> c:\locationForLog.txt

save as something.batch note the >> is to append the file else you're only get the very last output.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

So I create a text file with the command in it then I put its location after run command here > (location)   ?

Link to comment
Share on other sites

Link to post
Share on other sites

in notepad  . file > save as ... file type : any , then type  [file name here].bat

.bat is the file extension for BATCH files.

 

 > character redirects the output of an application from the console window (the text mode window with black background usually) to something.. the most common something is the name of a file.

 

so if you say

application_name.exe > c:\path\filename.txt  the output of application_name.exe will be saved in that text file.

 

Note that the text file is overwritten every time you launch the batch file

Also note that applications may not be allowed to create files directly the root of a drive  ex c:\file.txt 

You can sometimes force that to happen by running the batch file in administrator mode ..  right click on the batch file and select run as administrator. If you don't get the option, keep SHIFT key pressed and right click on the batch file, you'll get more options including "run as administrator"

 

ps.  If you have spaces in paths, you need to put the name between "  "    ex.  CD "C:\Program Files (x86)\nVidia"

 

by the way... windows has a thing called Task Scheduler ... where you can schedule something to run every minute or every few minutes and you can type the command to run

click start and type "task scheduler" in the run box then click on "Create basic task" or "create task" to create something.

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, mariushm said:

so if you say

application_name.exe > c:\path\filename.txt  the output of application_name.exe will be saved in that text file.

I think you misunderstood. There is no program that I want to run. The command that I put in the cmd window will output values, it's not in the nvidia folder. sorry if it's me who's not getting it here :-/ 

I need to type this line in a command prompt window that runs in this location:
Line: nvidia-smi.exe -i 0 --loop-ms=1000 --format=csv,noheader --query-gpu=power.draw
Location to open cmd in: "C:\Program Files\NVIDIA Corporation\NVSMI"

And I want it to log the values. It's okay if the file gets overwritten.

Link to comment
Share on other sites

Link to post
Share on other sites

The program is nvidia-smi.exe and what comes after are called parameters or arguments

 

so you enter something like this in your .bat file:


 

C:

CD "C:\Program Files\NVIDIA Corporation\NVSMI"

nvidia-smi.exe -i 0 --loop-ms=1000 --format=csv,noheader --query-gpu=power.draw > output.txt

first line moves the "action" to the c: partition if the .bat file is started from another partition

2nd line sets the working folder to that one

3rd line starts a program called nvidia-smi.exe with the parameters that follow and the output is redirected from screen to file called output.txt

 

if the full path is omitted, the file is created in the current folder, set with the cd command , so output.txt will be created in the same folder where nvidia-smi.exe is located

 

You can work around having to set the folder by always entering the full paths:

 

"C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi.exe" -i 0 --loop-ms=1000 --format=csv,noheader --query-gpu=power.draw > "c:\temp\output.txt"

 

Link to comment
Share on other sites

Link to post
Share on other sites

Thank you so much ^.^ I needed this for benchmarks it's working like a charm :) 

Link to comment
Share on other sites

Link to post
Share on other sites

Actually no xD I can't see the output file even if I set the location elsewhere. It created one the first time I ran it then no, it's not doing it anymore o.O

Link to comment
Share on other sites

Link to post
Share on other sites

The folder must exist and the application must have rights to create files in that folder. Windows may not let programs create files in some folders. Also remember if path has spaces, you need to use " ".

Run the file as Administrator and create the folder where you want the output to be, if not already made.

Link to comment
Share on other sites

Link to post
Share on other sites

I set it to another drive to try, and it still dones't work. Here's what's in it

 

C:

CD "C:\Program Files\NVIDIA Corporation\NVSMI"

nvidia-smi.exe -i 0 --loop-ms=1000 --format=csv,noheader --query-gpu=power.draw

"C:\Program Files\NVIDIA Corporation\NVSMI\nvidia-smi.exe" -i 0 --loop-ms=1000 --format=csv,noheader --query-gpu=power.draw > "D:\output\gpu_power.txt"

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×