General discussion


Name a txt file with output of command

By cummins75904 ·
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.

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.

Related Discussions

Related Forums