Badradish
Badradish

Reputation: 304

I'm having an issue with appending the output of wmic to a text file

I have a batch file that runs when any user logs on to the domain. The batch file gets lots of diffrent information from the users PC and outputs it into a text file on a shared folder. In part of the batch file i use WMIC to get the Product Name and Serial Number of the PC.

My issue is when i output the Product Name and Serial Number using the below code the font size is massive.

Code

wmic bios get serialnumber >> A:\"%username%".txt
wmic csproduct get name >> A:\"%username%".txt

Output

S e r i a l N u m b e r     *********          N a m e    **********

and when i tried using the following it doesnt work for users with a space in there name even if i add quotes

EG:
%username% = "Joe blogs" doesnt work
%username% = jblogs works fine

Code

wmic /APPEND:A:\"%username%".txt bios get serialnumber >> nul
wmic /APPEND:A:\"%username%".txt csproduct get name >> nul

So in short i need a way of changing the font of the output or a way of making wmic /append work for users with a space in there name.

If anyone needs more info or needs me to clarify something let me know Thanks

Upvotes: 2

Views: 7140

Answers (1)

Noodles
Noodles

Reputation: 2011

wmic /APPEND:"A:\%username%.txt" bios get serialnumber >> nul

Your quotes are wrong. A: is reserved for floppy drives.

Upvotes: 4

Related Questions