General discussion

Locked

Name a txt file with output of command

By cummins75904 ·
Hello,
I am trying to name a txt file with the output of this command:

wmic csproduct get identifyingnumber >> c:\users\%username%\desktop\(S.T.#Here).txt

which displays the Service tag number of machines and writes the service tag number into this text file. I have been beating my head in on this one, please help me.

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

What problems or errors are you getting?

by CharlieSpencer In reply to Name a txt file with outp ...

Troubleshoot it in steps:

Does the command itself work if you leave out the redirect and let it go to the screen?

I could be wrong or out of date, but I thought only a single 'greater than' was required to redirect the output to a file.

Also, the 'hash mark' may be a reserved character; have you tried leaving it out? It's probably a good practice to leave the parenthesis (and all punctuation marks) out of file name you expect to perform additional processing on.

Collapse -

Are you entering the service tag number yourself?

by NickNielsen In reply to Name a txt file with outp ...

If you want the script to insert the output from the csproduct utility into the filename position, try this command:

wmic csproduct get identifyingnumber >> c:\users\%username%\desktop\%%identifyingnumber.txt

I'm a little rusty, but something close to this should work.

Back to Software Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums