Page 1 of 1

Batch file output to network path truncates first character.

Posted: 04 Mar 2013 20:34
by fuleo
Hi guys, I have a batch file problem in here. Trying to save an output log into a networkpathed text file, but the front letter is missing... e.g "myname" becomes "yname" -> http://pastebin.com/GSWMhwm6

Code: Select all

SET destpath="\\networklogs\measure_sw_usage\extractinfo_%COMPUTERNAME%.txt"
for /f "skip=2 tokens=1,* delims=," %%A IN ('wmic computersystem get username /format:csv') DO (echo %%B >>%destpath%)


what the output should be
testdomain\username

what the output in the text file shows
estdomain\username

Re: Batch file output to network path truncates first charac

Posted: 04 Mar 2013 20:49
by fuleo
Ok error resolved.

I did this.

Code: Select all

for /f "skip=2 tokens=1,* delims=," %%A IN ('wmic computersystem get username /format:csv') DO (echo %%B >>%destpath%)


Code: Select all

echo %%B>>%destpath%


can't have the spacing before >>

very strict... ~.~

Re: Batch file output to network path truncates first charac

Posted: 04 Mar 2013 23:59
by foxidrive
The space after %%b will merely be included in the file. It's not the reason why the first character was removed.

FWIW WMIC outputs text with odd line endings and trailing spaces - you need to use a workaround to parse the output correctly in some cases.