Administrating Your Network Domain with PsTools

August 6, 2015 | Views: 8117

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

Using PsTools:

With PsTools, there are a number of different utilities included. The two I’ll focus on are: PsExec and PsShutdown. The rest are useful, too, and you can apply these techniques and batch files to them fairly easily.

  • PsExec is used to execute remove cmd commands or processes on domain connected servers or workstations. I actually find myself using PsExec to register DLL files on my domain computers, run update files, MSI installation remotely, etc.
  • PsShutdown is used to remotely restart or shutdown a workstation or server on the domain. I utilize this feature on my domain to force users to restart their machines if they leave them on after work or apply updates. You can also force logoffs for users that stay locked onto a machine and you have GPO’s that prevent the switch user button from being used when someone is logged in (prevents multiple users logging into the machine and reducing machine performance).


Get Started:



All PsTools have similar syntax associated with them. I’ll start with PsExec and then cover PsShutdown.

In order to specify the machine you want to use, you’ll need to tell PsExec the IP address or the domain name for the machine or server:

psexec \(NAME or IP) (COMMAND)

For example:

psexec \ regsvr32 “C:Program Files (x86)123456.dll”


As you can see, I’m executing the regsvr32 command on the machine Then, I’m entering the specifications or modifiers that regsvr32 requires.

Next, remember to use a password and username when the program or command executes. The string above will likely give you an error saying you don’t have permission or it will close without doing anything.


We use a modifier of –u for username and –p for password and we’ll get the following script:

psexec \ -u happydomainadministrator -p 123456 regsvr32 “C:Program Files (x86)123456.dll”

This will use the username “administrator” with the password “123456” to execute the command regsvr32 and register the 123456.dll on the machine

In PsShutdown, type:

PsShutdown \ -u happydomainadministrator -p 123456

This will shutdown the machine with the default of 20 seconds before shutdown.

PLEASE NOTE: This will not restart the machine. To do that, you’ll need to use the –r modifier at the end.

You can also use the –f modifier to force the restart and do so like:

PsShutdown \ -u happydomainadministrator -p 123456 -f -r

You can read more about possible commands and additional arguments on the Microsoft website listed above.


Creating a Batch File Script:

Let’s assume you know how to create batch files and you know how to save and edit them. From this, we can create the following example script.

Example Script:




SET /P comp=Please enter the Computer!

IF “%comp%”== “” GOTO error

PsExec \%comp% -u (DOMAINUSERNAME) -p (PASSWORD) systeminfo




ECHO You did not select a machine!




You can replace the sections in parentheses above to customize your script and use it to administer machines on your domain remotely.


Thanks and I hope this information is useful to you.

Share with Friends
Use Cybytes and
Tip the Author!
Share with Friends
Ready to share your knowledge and expertise?
  1. Thanks for sharing very helpful script.

  2. Thank you, vary helpful. This is far more practical then defrag and chkdsk on windows systems and is much quicker.

  3. I don’t understand but it seems very interesting

  4. The world has to now howwe machines work, this is far out the best ever happend on the internet. What a great job you all do. I will pas it trough to my childeren, hope that they will do somthing with it. This will be a break trough for Humanity, dear team I hope you realeaice that you will be the team that change the world at it is. Manny thanks for this. Excuus for my bath englisch, I’m Dutch, that will say it all 🙂

Page 4 of 4«1234
Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Support Cybrary

Donate Here to Get This Month's Donor Badge


We recommend always using caution when following any link

Are you sure you want to continue?