Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using PSEXEC to call CMD for a DEL command on a remote computer through a batch script.

PSEXEC \\hostname -u username -p password CMD /C DEL /Q /F C:\Folder\File.txt

The script pauses with a new CMD window popped up connected to the remote machine.

Why will psexec not automatically pass my DEL command via CMD?


The command works fine when sent directly through the CLI and not in a batch script

share|improve this question
up vote 3 down vote accepted

Why not just run:

del /q \\hostname\c$\FolderFile\File.txt

Otherwise, write thet batch file on your system, then use the -c switch of psexec to "Copy the specified program to the remote system for execution"

share|improve this answer

Your example command works fine in my test running in a batch file on Windows 7 targeting Windows XP, which is strange.

You could try enclosing your del command in quotes:

PSEXEC \\hostname-u username -p password CMD /C "DEL /Q /F C:\test.txt"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.