Reputation: 89
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
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
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