Windows – How to use PsExec

Last updated on April 4th, 2018 at 11:06 am

First, Download PsTools from here
Open the .zip archive and copy Psexec.exe into C:\Windows
Run CMD as administrator

Examples for Single commands:

Single Command (ex. Renew IP Address lease on remote computer)

*The command will run with your local logged in user.

psexec \\pc25 ipconfig /renew

 

Single Command (ex. Silent Update Group Policy [User] on remote computer)

*The command will run with your local logged in user.

psexec \\pc25 cmd /c echo n | gpupdate /Target:User /wait:0 /force

 

Single Command (ex. Silent Update Group Policy [Computer] on remote computer)

*The command will run with your local logged in user.

psexec \\pc25 cmd /c echo n | gpupdate /Target:Computer /wait:0 /force

 

Single Command with specific credentials (ex. Renew IP Address lease on remote computer)

*The command will run with specified different user.

psexec \\pc25 -u admin -p password ipconfig /renew

 

Single Command with specific credentials (ex. Stop Printer service on remote server)

*The command will run with specified different user.

psexec \\srv1 -u admin -p password net stop "Spooler"

 

Examples for Loop commands:

Loop Command on list (ex. Add user on few remote computers)

*The command will run with your local logged in user.
**Prepare .txt list with computer names and locate it on desired path. – Example

for /f %%a in (c:\pc-list.txt) do (
psexec \\%%a net user john pass123 /add
)

 

Loop Command on list with specific credentials (ex. Add local user John on few remote computers)

*The command will run with specified different user.
**Prepare .txt list with computer names and locate it on desired path. – Example

for /f %%a in (c:\pc-list.txt) do (
psexec \\%%a -u admin -p password net user John pass123 /add
)

Leave a comment

Your email address will not be published. Required fields are marked *