![]() |
PsExec and "net use" |
Post Reply
|
Page 12> |
| Author | |||
andyking-pit
Newbie
Joined: 18 December 2009 Location: Pittsburgh, PA Online Status: Offline Posts: 1 |
Post Options
Quote Reply
Topic: PsExec and "net use"Posted: 18 December 2009 at 7:24pm |
||
|
I accomplished what I needed with this as well. We use SMS 2003 to distribute and install software packages. Where the SMS client has failed, I was looking to use PSEXEC to remotely execute a software installs on a remote client, where it would run from the local/remote server. Ie sitting in Pittsburgh a would make a client PC in Denver install from the Denver server.
Because of how the packages are configured (using a HTA files that derive the path where there are executed from) they need to be executed from a mapped network drive. The share where the files are located have everyone read access so that the SYSTEM account which is what does the install can access it. The solution for me was to use the -s option to run the process in the SYSTEM context, and to have it execute a batch file. The batch file contains the remote/local UNC path to the install source. So PSEXEC copies the batch file to the remote host which then executes it as the SYSTEM account. Maps to the hidden SMS share, changes to the mapped drive and executes the HTA which displays to the user and the install works great. psexec.exe -s -c -i \\target \\mypc\g$\remoteinstall.bat where remoteinstall.bat = net use p: /delete net use p: \\remotelocalserver\share$\smsPkgIDFolder p: NameOfPackageToExecute.hta I also found that when using the -s (and -i) option, if I open an interactive command window, I can do this process interactively so long as the shares I am mapping to have everyone full control. |
|||
![]() |
|||
sanatogen
Newbie
Joined: 21 March 2009 Online Status: Offline Posts: 1 |
Post Options
Quote Reply
Posted: 21 March 2009 at 1:03am |
||
|
Hi Folks,
Just to say thanks to all who contributed to this thread. I was beating my head for 3 hours over this one and as a results of this thread my script now works. Rod
|
|||
![]() |
|||
molotov
Moderator Group
Joined: 04 October 2006 Online Status: Offline Posts: 17492 |
Post Options
Quote Reply
Posted: 29 October 2008 at 4:14pm |
||
|
Daily affirmation:
net helpmsg 4006 |
|||
![]() |
|||
molotov
Moderator Group
Joined: 04 October 2006 Online Status: Offline Posts: 17492 |
Post Options
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 |
|||
![]() |
|||
e-master
Newbie
Joined: 10 October 2008 Online Status: Offline Posts: 2 |
Post Options
Quote Reply
Posted: 10 October 2008 at 9:49pm |
||
![]() |
|||
e-master
Newbie
Joined: 10 October 2008 Online Status: Offline Posts: 2 |
Post Options
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 ;))
|
|||
![]() |
|||
mabino
Newbie
Joined: 30 January 2006 Online Status: Offline Posts: 2 |
Post Options
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 |
|||
![]() |
|||
mabino
Newbie
Joined: 30 January 2006 Online Status: Offline Posts: 2 |
Post Options
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. |
|||
![]() |
|||
Karlchen
Senior Member
Joined: 18 June 2005 Location: Germany Online Status: Offline Posts: 5121 |
Post Options
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 |
|||
![]() |
|||
ronaldknol
Newbie
Joined: 26 January 2006 Location: Canada Online Status: Offline Posts: 2 |
Post Options
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. |
|||
![]() |
|||
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 |