我只是用以下命令得到一个空白文件:
net use \\computername password /user:username > log.txt
我怎样才能让它工作?
捕获 stderr 输出并检查 ERRORLEVEL。sharename
也需要A。查看NET HELP USE
命令的输出。
net use \\computername\sharename password /user:username >"log.txt" 2>&1
if NOT ERRORLEVEL 1 goto NetUsePassed
echo ERROR: NET USE failed.
:NetUsePassed
在我当前登录的 PC 上,我可以执行...
net use \\localhost user:Gwen > C:\TEMP\output.txt
这会在输出文件中生成以下文本...
The command completed successfully
请注意,我没有将密码传递给命令。