failure to map drive on remote machine through winexe

3.1k views Asked by At

I'm trying to map a network share on a remote windows xp machine using winexe program from ubuntu and the command fails with the errors as below .

Command:

./bin/winexe -U Domain1/Administrator%paswrd123 //192.168.4.38 'cmd /c net use Q: \\192.168.4.16\Mydrive pwd123 /USER:user /P:yes'

Error:

System error 1312 has occurred.

A specified logon session does not exist. It may already have been terminated.

i went to the remote system logged in and ran net use command locally and the share drive got mapped successfully .

Command used :

net use Q: \\192.168.4.16\Mydrive pwd123 /USER:user /P:yes

i have googled and people have given suggestions on checking the syntax of the command , the syntax of the command is fine and it works fine when run locally on the windows system. Help on this would be appreciated .

EDIT:I entered the domain name in the username section as below and the command worked successfully but i'm unable to find the share drive on the remote machine.

./bin/winexe -U Domain1/Administrator%paswrd123 //192.168.4.38 'cmd /c net use Q:\\192.168.4.16\Mydrive pwd123 /USER:MUM\user /P:yes`' 
The command completed successfully.
1

There are 1 answers

1
Sunny On BEST ANSWER

For your edited query, you can use this to let NET pick a free drive letter, then use NET to find out what letter it assigned:

net use * \\server\share
for /f "tokens=2" %%i in ('net use ^| find "\\server\share"') do set netdrive=%%i
echo %netdrive% has been mapped

For details on net use commands, see accepted answer for question Mapping a network drive without hardcoding a drive letter in a batch file.