Page 1 of 1

copying file in location

Posted: 30 Mar 2014 09:47
by tcpman
hi i want my batch file when is runing will copy his self in a place
how can i do this?
like a virus

Re: copying file in location

Posted: 30 Mar 2014 09:51
by Squashman
%0 references the batch file name.

Re: copying file in location

Posted: 12 Apr 2014 05:35
by tcpman
can you exmplain more?
i know i have to use that but i cant find any good help about it

tnx by the way

Re: copying file in location

Posted: 12 Apr 2014 05:49
by foxidrive
tcpman wrote:hi i want my batch file when is runing will copy his self in a place
how can i do this?
like a virus


It's a bit worrying when someone says 'virus' when referring to some code.

If there is a legitimate reason and you explain further then it will help us to know what to suggest.

Re: copying file in location

Posted: 12 Apr 2014 10:35
by Squashman
tcpman wrote:can you exmplain more?
i know i have to use that but i cant find any good help about it

tnx by the way

So you don't know how to use the COPY command?

Re: copying file in location

Posted: 13 Apr 2014 05:04
by tcpman
well i can create a virus in c++ if i want ! why i should use a batch?


i know how copy works but i dont know how to %0 will work

Re: copying file in location

Posted: 13 Apr 2014 05:10
by ShadowThief
%0 is a variable that contains the path and name of the script that is currently running, so

Code: Select all

copy %0 .
will make a copy of the script in the folder you were in when you ran the script.

Re: copying file in location

Posted: 13 Apr 2014 05:16
by tcpman
tnx i thought it will need more then just typing %0

Re: copying file in location

Posted: 13 Apr 2014 05:43
by foxidrive
tcpman wrote:well i can create a virus in c++ if i want ! why i should use a batch?


Why should anyone help you to do so in batch??

The real point is that you ask for free help and don't even want to tell anyone what you are doing - You just make cryptic comments about a virus.

Thread locked.

Re: copying file in location

Posted: 13 Apr 2014 09:54
by Squashman
tcpman wrote:tnx i thought it will need more then just typing %0

How hard would it have been for you to create a simple batch file with nothing more than

Code: Select all

@echo off
echo %0

Then from there you would have realised what the variable is and then could have tested it with the copy command.
As they say "You can lead a horse to water....."
or
"Teach a man to fish versus giving them the fish"