Page 1 of 1

Making a batch file to copy itself.

Posted: 08 Oct 2009 05:41
by Rage
Hello all,

I am fairly new to batch and am basically just trying to learn a few things that will save time doing things later.

I am trying to make a batch file that can be run from any location, and copy itself to a specified location, so that I can take my file on CD or USB or run it from the desktop, and once I have run it once it will store a copy of itself in the same location on every machine.

This is what I have so far:


@echo off
cls
md c:\copydir
start cmd /c copy "%0" "c:\copydir\"


So this will copy itself to c:\copydir\ however this only works when I run the file from c:\ otherwise it only creates the folder and does not copy itself into it. I know I am missing something simple but I cannot find the answer! Thanks

Rage

Posted: 08 Oct 2009 07:27
by Rage
No worries figured it out. Schoolboy error.