Microsoft
Software
Hardware
Network
Question : Batch file to "net use" and capture output to a text file
I'm running the following program on WinNT4 machine although I belive this also happens on w2k systems as well.
@ECHO OFF
ECHO Demapping drive ... >> COMMS.LOG
NET USE K: /DELETE /YES >> COMMS.LOG
but when I run this batch file I get a "1" add before the ">>" on lines 2 and 3, line 2 seems to run fine but line 3 dumps it's output to the screen rather than COMMS.LOG
when I run program with @ECHO off REM'ed out I get the follwoing output to the screen.
C:\STUFF>rem @ECHO OFF
C:\STUFF>ECHO Demapping drive ... 1>>COMMS.LOG
C:\STUFF>NET USE K: /DELETE /YES 1>>COMMS.LOG
What causes these the "1" to appear and how can I get round it/fix it ??
Answer : Batch file to "net use" and capture output to a text file
The 1 is the device number for the standard output device. The default STDOUT device is the console (CON). The NET USE command will output to that device if it successful. If it is unsuccessful it will generate output to the standard error device, device number 2. The default STDERR device is also the console. If you want to capture both output devices and append them to your log file you might try this:
C:\STUFF>NET USE K: /DELETE /YES 2>>1>>COMMS.LOG
Good Luck,
Steve
Random Solutions
Changing DNS address of Netowork interface Card using windows script.
Loop.sys
Changing a field type while using INTO
Error when assigning value to textbox in footer during runtime
XP display set to 4 bit color depth after Remote Desktop session
Textboxes in other Tabs in asp.net
Same form on different computers
RUNDLL error message "jyku.fjo" on computer start up
Access Pivot chart - need different scales on right and left axis
active directory, W2k8 R2 DC, Kerberos failures, Event ID: 3, 4771, 4769, 4768, 4776, 4625 source: Microsoft Windows security