1.

Solve : Self move Batch file?

Answer»

Hey frnds,
'm new to batch scripting, so havin some trouble.
I jst wanted to know if I cld write a batch file to move itself to another LOCATION jst by executing(running) it...

meaning, If I have a batch file at
C:\old\dir\first.bat (wer first.bat is my batch file that dat to run)
I wish to move it to
d:\new\directory\

Plz help... Why do you need to do this?

Quote from: Salmon Trout on March 06, 2011, 12:49:49 AM

Why do you need to do this?
Yes, smells like he wants to build a worm in batch.Hahaha, no no, not at all...
Actually, I wrote a batch file
Code: [Select]@echo off
cd /d "%1"
javac %2
if errorlevel 1 goto finish
java %3
:finish
pauseso that I could compile java from notepad++ directly...
Now my frnds arnt good at batch(I mean, they got no idea, not at all) so I want this above written batch file to automatically copy itself to "C:\notepad++"
& so I asked this question...Quote
Hahaha, no no, not at all...

Your friends are no good at batch and cannot place a simple batch file in a DESIRED directory, yet they can write java programs in notepad++, which they wish to compile?

[Edit] And you, who is are so much better than they are, can't work it out either?


Quote from: Salmon Trout on March 06, 2011, 01:25:14 AM
Your friends are no good at batch and cannot place a simple batch file in a desired directory, yet they can write java programs in notepad++, which they wish to compile?
Mabe not, but if a process can be automated, then y cant we do so ?

Quote from: Salmon Trout on March 06, 2011, 01:25:14 AM
And you, who is are so much better than they are, can't work it out either?
Is that an offense ?
Not all are genius like you Salmon...Quote from: Rico on March 06, 2011, 02:22:04 AM
Not all are genius like you Salmon...

Not even me. As you can see I was uncertain of my grammar.

They do say that "genius" is 1% inspiration and 99% perspiration, and it is certainly true that the willingness to do research and look for information is a big PART of gaining knowledge. So you should investigate

1. The COPY and MOVE commands.

2. You seem to know what the replaceable parameters %1, %2 etc are... Find out what %0 (percent zero) means.

3. In connection with (2) you should CAREFULLY study the variable modifiers such a %~d %~p etc which are documented in the FOR help.









Discussion

No Comment Found