copying file in location

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Locked
Message
Author
tcpman
Posts: 53
Joined: 05 Mar 2014 15:01

copying file in location

#1 Post by tcpman » 30 Mar 2014 09:47

hi i want my batch file when is runing will copy his self in a place
how can i do this?
like a virus

Squashman
Expert
Posts: 4472
Joined: 23 Dec 2011 13:59

Re: copying file in location

#2 Post by Squashman » 30 Mar 2014 09:51

%0 references the batch file name.

tcpman
Posts: 53
Joined: 05 Mar 2014 15:01

Re: copying file in location

#3 Post by tcpman » 12 Apr 2014 05:35

can you exmplain more?
i know i have to use that but i cant find any good help about it

tnx by the way

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: copying file in location

#4 Post by foxidrive » 12 Apr 2014 05:49

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.

Squashman
Expert
Posts: 4472
Joined: 23 Dec 2011 13:59

Re: copying file in location

#5 Post by Squashman » 12 Apr 2014 10:35

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?

tcpman
Posts: 53
Joined: 05 Mar 2014 15:01

Re: copying file in location

#6 Post by tcpman » 13 Apr 2014 05:04

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

ShadowThief
Expert
Posts: 1163
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: copying file in location

#7 Post by ShadowThief » 13 Apr 2014 05:10

%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.

tcpman
Posts: 53
Joined: 05 Mar 2014 15:01

Re: copying file in location

#8 Post by tcpman » 13 Apr 2014 05:16

tnx i thought it will need more then just typing %0

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: copying file in location

#9 Post by foxidrive » 13 Apr 2014 05:43

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.

Squashman
Expert
Posts: 4472
Joined: 23 Dec 2011 13:59

Re: copying file in location

#10 Post by Squashman » 13 Apr 2014 09:54

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"

Locked