tim.tub
tim.tub

Reputation: 89

How to pipe output of net use command to file

I am just getting a blank file with the following command:

net use \\computername password /user:username > log.txt

How can I get this to work?

Upvotes: 0

Views: 4420

Answers (2)

lit
lit

Reputation: 16256

Capture stderr output and check ERRORLEVEL. A sharename is also needed. See the output of the NET HELP USE command.

net use \\computername\sharename password /user:username >"log.txt" 2>&1
if NOT ERRORLEVEL 1 goto NetUsePassed
echo ERROR: NET USE failed.

:NetUsePassed

Upvotes: 1

Gwen
Gwen

Reputation: 23

On my PC, which I am currently logged in, I can execute...

net use \\localhost user:Gwen > C:\TEMP\output.txt

Which produces the following text in the output file...

The command completed successfully

Note that I did not pass the password to the command.

Upvotes: 0

Related Questions