Windows – Prevent Accidental Execution of Windows .BAT File on Workstation

batch-fileheadlesswindows

I have a .BAT file with a robocopy line in it. The .BAT file resides on a network server directory. I use a client/monitor application on my workstation to send out a run command to several headless machines to tell them to each run the .BAT file.

The problem I've had is that a couple times when I've tried to copy and paste the command line to send to the remote machines, I inadvertently executed the command on my own workstation!

Is there some way that I could modify the .BAT file or do something elegant that would make it so the .BAT file couldn't accidentally operate on a workstation with a currently active logged in human or something to that effect? I just need to make it so I don't accidentally run the silly thing on my machine when I'm working with it.

Best Answer

Maybe just throw a short wait command at the beginning, say 10 seconds with a prompt that says "Waiting 10 seconds..."

That would give you enough time to cancel it on your workstation if you accidentally executed it on your own workstation.

Follow this guy's advice on how to create the "timer" if you'd like, or come up with your own parameters/script:

Better way to wait a few seconds in a bat file?