?
Solved

How will I use Psexec with .bat file

Posted on 2010-09-07
14
Medium Priority
?
1,126 Views
Last Modified: 2012-05-10
I want to run a batch file on remote computer using psexec. Can any one tell me what the command is "xyz" is name of remote computer & "abc" is name of batch file.
0
Comment
Question by:ekoga
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +4
14 Comments
 
LVL 21

Expert Comment

by:chapmanjw
ID: 33624163
Here is how to do it: http://www.howtonetworking.com/Tools/psexec.htm

For ex: psexec \\xyz c:\abc.bat -u username -p password
0
 
LVL 13

Accepted Solution

by:
NarendraG earned 750 total points
ID: 33624194
psexec \\xyz -u username -p password c:\BatchFile1.bat
0
 

Author Comment

by:ekoga
ID: 33624213
From where will I run this command I tried from my machine from cmd prompt but it does not works.
Do i need to write the above mentione command in a file & then execute the file or just need to run the command.
0
Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

 
LVL 13

Expert Comment

by:NarendraG
ID: 33624221
just u need to rum from command promt

after running command wt error you are getting ?

please check user name and password is correct?

both the machine are in one domain?

or local machines?
0
 
LVL 13

Expert Comment

by:NarendraG
ID: 33624232
if it is local machine not attached to domain then you need run this command with local admin account.

if it is part of domain you need appropriate permissions to run the batch file remotely(domain admin)
0
 

Author Comment

by:ekoga
ID: 33624245
'psexec' is not recognized as an internal or external command,
operable program or batch file.
This is the command tht i get when I run the command. the command that I use is as follows
psexec \\xyz -u username -p password g:\abc.bat
0
 
LVL 2

Expert Comment

by:ngmarowa
ID: 33624250
the way I use is to copy the bat file to the remote machine and run it from there. You can include this in another batch file. I normally have a directory called batches on most of my machines as I use psexec quite a lot. You can still create the folder in the bat file

net use g: /del
net use g: \\xyz\c$
md batches
copy c:\abc.bat g:\batches
psexec \\xyz c:\batches\abc.bat


then delete the bat file later if you dont need to use it
0
 
LVL 13

Expert Comment

by:NarendraG
ID: 33624273
Now i understand the problem

copy the file Psexec.exe to C:\

Then open command prompt type cd \ this will take you to C:\
then run above command

we need run this psexec command from where that file is located
0
 
LVL 13

Expert Comment

by:NarendraG
ID: 33624278
hope you downloaded  you downloaded Pstools to your machine already

you can find this psexec.exe file it pstools
0
 
LVL 2

Expert Comment

by:ngmarowa
ID: 33624301
What I have done is create a folder on my local c drive called pstools. Downloaded the pstools and extracted them to that folder. Then added the path c:\pstools to my environment variables (under system properties->advanced->environment variable and edited the path to include c:\pstools) so I can basically run it from anywhere on my command prompt without navigating to the actual folder
0
 
LVL 1

Assisted Solution

by:Ginsmon Joseph
Ginsmon Joseph earned 750 total points
ID: 33624410
You can use the below command to execute a batch file on the remote machine. Make sure you have the admin rights on the remote machine

psexec \\xyz -c abc.bat

or else you can pass the username and password as an arguement

psexec \\xyz -c abc.bat -u test.com\administrator -p *
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 33624821
Sometimes it is a better idea to have all files located centrally, and call them there. Like
   \\myserver\utils\psexec \\xyz \\myserver\utils\MyBatch.cmd
0
 
LVL 21

Expert Comment

by:AmazingTech
ID: 33629346
I have found that PSEXEC cannot run the batch file from a UNC path unless you run it as system.

\\myserver\utils\psexec \\xyz -s \\myserver\utils\MyBatch.cmd
0
 

Author Closing Comment

by:ekoga
ID: 33633409
It helped me partically to write the code.
Thanks to all for their help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month13 days, 6 hours left to enroll

801 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