Passing CMD via PSEXEC to a remote computer via .BAT file

14,157

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:
14,157
Anthony Miller
Author by

Anthony Miller

"Your competition is a hungry immigrant with a digital handheld assistant. America is made up of immigrants... if your children are to be successful they must act like immigrants in their own country. Just by being born here doesn't give you the ability to be successful... it is the work ethic... the pioneering ethic... the service ethic that will win. Your competition is always a hungry immigrant with a digital assistant: hungry in the belly for food, hungry in the mind for knowledge, and the hunger is something that should never leave you." ~Dr. Dennis Waitley

Updated on September 18, 2022

Comments

  • Anthony Miller
    Anthony Miller almost 2 years

    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?

    EDIT:

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