Solved

How do I correctly run psexec to get an application, msi, or exe to run on a local machine

Posted on 2011-09-03
15
1,141 Views
Last Modified: 2012-05-12
I previously awarded Johnb6767 points from:
07/08/11 10:27 PM, ID: 36157236

He introduced me to a utility called psexec. It would be the perfect tool for me to run application on a remote machine, but I just cant seem to get it right. I will summarize the two machines that I am working with to accomplish task such as running a .vbs file with psexec.

1. Both machines are Windows 7 64 bit
2. They are both part of a the samw "WORKGROUP"
3. They are both part of the same  "HOMENETWORK"
4. The advanced sharing options are the same on each machine
5. Windows Firewall is turned off on both machines
6. Scanned both machines for viruses and root kits
7. Ran a registry edit to see the $ shares on each machine
8. I am not interested in using any other tool like cpau, etc...
9. I want to use psexec to do what it is supposed to do.

I have started out with a simple program like calc.exe and this is what I get:

F:\VBS\BGCMC\HomeScripts>PSEXEC \\WKS-WNXP-01902  /u administrator /p 12345678 calc.exe

PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

*******************************************************************

I have to "ctrl break" to get out of the command window. I would like to start fresh and see if I can simply get the command to work on Windows 7. Let's begin....






0
Comment
Question by:BLACK THANOS
15 Comments
 
LVL 12

Expert Comment

by:prashanthd
Comment Utility
Can you try running with elevated priveleges?

What is the version of psexec?
0
 

Author Comment

by:BLACK THANOS
Comment Utility
prashanthd, I am running version v1.98

When  you say run with elevated priveleges, do you mean run as administrator from the command line? If that is the case then that is what I am doing. If not , please elaborate on your comments.
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
Comment Utility
As said before, calc is nothing you should use for testing - or if you do, either use the -d switch of psexec to detach, or spawn the process remotely with start. In the way you use it psexec waits for termination of calc.exe.

  psexec \\WKS-WNXP-01902  -d -u administrator -p 12345678 calc.exe
will detach psexec. psexec is hence not waiting, but you can't interact with the called program (e.g. with a cmd prompt).

  psexec \\WKS-WNXP-01902 -u administrator -p 12345678 cmd /c start "" calc.exe
will start a command prompt, which starts calc without waiting for termination, terminates, and you are done - calc is running, psexec is terminated.
0
 

Author Comment

by:BLACK THANOS
Comment Utility
Good morning Qlemo,

Does psexec have to be installed on both machines?

I just tried your first example above with the vbscript that I want. It simply maps a drives. The following is what I get:

C:\Windows\system32>psexec \\wks-wnxp-01905 -d -u administrator -p 12345678  \\REAPERSGALE\scripts\MappingADrive.vbs

PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

Could not start PsExec service on wks-wnxp-01905:
Access is denied.
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
PsExec installs a service itself. It needs access to admin$ on the remote machine, and the appropriate privileges to install and start a service.
You didn't have that issue with your original test?
0
 

Author Comment

by:BLACK THANOS
Comment Utility
the machine I was working with \\wks-wnxp-01902 has the psexec service installed, but the new machine \\wks-wnxp-01905 does not. For completeness I dont recall ever installing psexec as a service on \\wks-wnxp-01902. I simply went to the command line to try and run the psexec command. I am obvisously missing something. Thank your for your patience with me. Do you have any thoughts on what I am doing wrong???
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
Is the admin login correct? As said, PsExec installs the service, if required, on first connect. If it cannot install or start the service, because of account restrictions or because the service is already installed, but disabled, the above error message appears.

If you have resolved that, the next obstacle might be to have access to the UNC path (\\...). That does not work all the time. If you get PsExec to start the service, but get an error message about the script, try to copy the script to the remote machine, and then start it locally.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:BLACK THANOS
Comment Utility
I will try all you suggest after I get some sleep. I am tired right now and will now go to bed. You have definately given me some direction to go in. Please stay tuned and good night....
0
 
LVL 66

Expert Comment

by:johnb6767
Comment Utility
Actually, if you launch calc, use the -I switch to see if it appears on screen on the target., an can also use the -d as well. If it is not on screen, check the task manager for it's existence, by clicking the "show processes from all users" button....
0
 

Author Comment

by:BLACK THANOS
Comment Utility
Good evening Gentlemen, I havent been able to test the suggestions above. I have been away and concentrating on my dissertation, but I will start again tomorrow and let you know what the results were.
0
 

Author Comment

by:BLACK THANOS
Comment Utility
Okay guys , I have tried everything you have suggested.
I have accdss to the $ shares
The unc paths can be seen from each machines
each machine has the same user name and password combinations. I am at my wits end. I will go back to see if I have missed something
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
I'm not certain which issue we are at at the moment?
Is PsExec able to start something on the other side, or not?
Did you check the PsExec service state, if PsExec does not work?
If it works, try to start a cmd via PsExec and providing explicit credentials with PsExec (important!), then see if you can still access UNC paths from the DOS prompt.
0
 

Author Comment

by:BLACK THANOS
Comment Utility
Okay guys, as I have finished my Doctoral homework, I can now re-focus on this question.
I am doing some testing now. I hope to get back to you shortly tonight or early tomorrow.

Regards,
Regis
0
 

Author Closing Comment

by:BLACK THANOS
Comment Utility
Qlemo,
Finally, finally, finally, I was sucessful in implementing psexec to run scripts on remote computers. I made slight modifications to your solution and it worked like a charm. For completeness here are the commands I was finally able to get working:

C:\Windows\system32>PSEXEC.EXE -u administrator -p 12345678  "\\wks-wnxp-01902" -i 0  -d -c -f c:\install\CreateShortcut.exe and
C:\Windows\system32>PSEXEC.EXE -u administrator -p 12345678  "\\wks-wnxp-01902" -i 0  -d -c -f c:\install\DelShortCuts.exe

The actual scripts were wrapped in the form of an executable via primalscript.

Thank you , Thank you , Thank you
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
Great, and thanks for coming back and award. As Cleanup Volunteer for MSDOS I really appreciate that twice ;-).
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now