0

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.
Santhosh Pai
  • 2,395
  • 6
  • 23
  • 46

1 Answers1

0

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.

Community
  • 1
  • 1
Sunny
  • 6,736
  • 10
  • 25
  • 47
  • The mapped drive only appears after reboot . but not after the command has been executed . Is there a fix for the same ? – Santhosh Pai Jan 02 '14 at 04:50