![]() |
PsExec and "net use" |
Post Reply
|
Page 12> |
| Author | |||
ronaldknol
Newbie
Joined: 26 January 2006 Location: Canada Online Status: Offline Posts: 2 |
Quote Reply
Topic: PsExec and "net use"Posted: 26 January 2006 at 4:15pm |
||
|
Having searched this forum and on the internet I still have not been able to get my problem answered, so hence this new post. Using psexec v1.70, my PC is Windows 2000 Professional SP4, the remote machine is also Windows 2000 Professional SP4. No firewalls involved, both machines are part of a (Windows 2003) domain. The remote machine automatically logs on with a known username and password (account and passwd), I am logged on to my PC with my own credentials (myaccount and mypasswd). The remote machine (account) automatically maps a network drive when it logs on (done through Windows Explorer with Reconnect At Logon). I am trying do remotely change that mapped drive to another server. On the remote machine locally I can do this (works): net use W: /delete But, from my PC using PsExec this does not work and I get strange results. Here's what I did: psexec \\remote -u domain\account -p passwd -i net use W: /delete This fails with error: The network connection could not be found. If I try to map a new drive psexec \\remote -u domain\account -p passwd -i net use K: \\server\share This works, and the K: drive shows up on the remote machine in Windows Explorer (but with a red X indicating disconnected) and I can access it. So then I want to disconnect it: psexec \\remote -u domain\account -p passwd -i net use K: /delete And again I get the error: The network connection could not be found. But now even though I got this error, Windows on the remote machine is confused. Windows Explorer still shows the K: drive, but running "net use" on that remote machine shows no K: drive. Windows Explorer "Disconnect Network Drive" also does not show K:. I have tried this over and over, but I get the same results. PsExec with "net use K: \\server\share" works, but after that the machine does not indicate that the drive is mapped, and cannot be unmapped, even though Windows Explorer sees the newly mapped drive and can access it. Thoughts?
|
|||
|
Cheers, Ronald. |
|||
![]() |
|||
Karlchen
Senior Member
Joined: 18 June 2005 Location: Germany Online Status: Offline Posts: 5121 |
Quote Reply
Posted: 26 January 2006 at 4:49pm |
||
|
Good evening, Ronald.
Minor thing: in this case the -i switch is not needed. (I.e. you do not need it here, but it is unrelated to your issue.) Major thing: the -e switch is needed! Reason: psexec without the -e switch will logon user domain\account on \\remote. Yet, it will not load account's profile, but the profile of LOCAL SYSTEM on \\remote. LOCAL SYSTEM will not have the drive mapping W:, hence the correct, but unexpected error message. psexec with the -e switch will logon user domain\account on \\remote. And it will load account's profile. The drive W: should be assigned, and "net use w: /delete" should work. So your psexec command should read like this:
Let us know if it really works. (I cannot test this scenario at this moment, because I am not connected to any usable network, except the internet obviously. I remember though that in ancient PSTools thread(s) the same problem has been discussed before, I do not remember the essence. I do suspect, however, that drive (un)assignement using psexec may not be "sticky". This would correspond to what you wrote in the second half of your message.) Karl Edited by Karlchen |
|||
![]() |
|||
ronaldknol
Newbie
Joined: 26 January 2006 Location: Canada Online Status: Offline Posts: 2 |
Quote Reply
Posted: 26 January 2006 at 6:13pm |
||
|
Hi Karl, thanks for the quick response. So I tried again, this time with -e. But I still get the same result.
Right after this I look on the remote machine (VNC) and N: does show up in Windows Explorer, and I can access it. But, "net use" does not show N: and I cannot psexec delete it:
I was unsure about the -e option since the proper account is already loaded (and active) on the machine; the account is already logged on (on the console). |
|||
|
Cheers, Ronald. |
|||
![]() |
|||
Karlchen
Senior Member
Joined: 18 June 2005 Location: Germany Online Status: Offline Posts: 5121 |
Quote Reply
Posted: 27 January 2006 at 3:26am |
||
|
Hi, Ronald.
The "-e" option is meaningful for the psexec session on \\remote. To see the difference yourself, try
I am sure you will notice the difference. About the drive (un)assignements not being sticky: As soon as find the time I will try to locate the ancient threads where this problem was discussed (as a side issue). If they are still on the server and if I find them, I will give the links here. Not sure though if the essence was not: do not (un)assign drives using psexec.
Karl |
|||
![]() |
|||
mabino
Newbie
Joined: 30 January 2006 Online Status: Offline Posts: 2 |
Quote Reply
Posted: 30 January 2006 at 9:50am |
||
I am unable to get as far as you have in mapping the drive to begin with. I've set up a test scenario where I'm trying to give the command via psexec to map a share that has few restrictions on it (shared to Everyone, perms are read-only). I issue the command as you have above and get "command completed successfully... error code 0". With the account logged in on the target machine I inspect both Windows Explorer and net use and neither report the existence of a mapped drive. I've also tried:
This pops up a DOS box for a moment on the target's desktop which then immediately closes. This resembles the behavior of typing the cmd.exe... bit into Start > Run. However, when sent via psexec it fails, typed into Start > Run and its successful. I'm struggling to find this out as I do not want to have to copy the scripts I wish to run locally. |
|||
![]() |
|||
mabino
Newbie
Joined: 30 January 2006 Online Status: Offline Posts: 2 |
Quote Reply
Posted: 30 January 2006 at 12:19pm |
||
I was able to both add and remove mappings via psexec with the following commands, however after initially mapping the drive it is reported as being unavailable.
As a result of its unavailability I cannot run any scripts located there. Running these same commands locally however successfully mounts the drive so it is usuable. Edited by mabino |
|||
![]() |
|||
e-master
Newbie
Joined: 10 October 2008 Online Status: Offline Posts: 2 |
Quote Reply
Posted: 10 October 2008 at 9:16pm |
||
|
let me explain what's the real root-cause of this problem. when you start a process remotely with PSExec (with or without -e, depends on the version) the remote process can't access any network drive. But, it can access the network. Thus the script above really works, because first you attach the network drive, and being in the same process-environment you are able to detach it.
one way of solution i'm looking for is to create batch files on the clients which will have the "net use x: \\zzz" command at first, and the "start yyyy.exe" command after. so, by executing remotely this batch file, i'll have attached the network drive, and in the same context of execution i'll start the executable i need.
another solution could be to use the "cmd" as a remote command to start the executable in the same way by joining the commands with &. I should start it like "cmd net use x: \\client & start process.exe". I'm going to test it right now, and let you know the results(i hope this post is relevant for someone yet, since it is 2 years old ;))
|
|||
![]() |
|||
e-master
Newbie
Joined: 10 October 2008 Online Status: Offline Posts: 2 |
Quote Reply
Posted: 10 October 2008 at 9:49pm |
||
![]() |
|||
molotov
Moderator Group
Joined: 04 October 2006 Online Status: Offline Posts: 17287 |
Quote Reply
Posted: 11 October 2008 at 3:35am |
||
|
When dealing with PsExec, mapped drives, and a remote system, the situation may frequently be described in these articles:
Services and Redirected Drives INFO: Services and Redirected Drives |
|||
|
Daily affirmation:
net helpmsg 4006 |
|||
![]() |
|||
molotov
Moderator Group
Joined: 04 October 2006 Online Status: Offline Posts: 17287 |
Quote Reply
Posted: 29 October 2008 at 4:14pm |
||
|
Daily affirmation:
net helpmsg 4006 |
|||
![]() |
|||
Post Reply
|
Page 12> |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |