Making a batch file to copy itself.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Rage
Posts: 5
Joined: 08 Oct 2009 05:30

Making a batch file to copy itself.

#1 Post by Rage » 08 Oct 2009 05:41

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

Rage
Posts: 5
Joined: 08 Oct 2009 05:30

#2 Post by Rage » 08 Oct 2009 07:27

No worries figured it out. Schoolboy error.

Post Reply