Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Self move Batch file  (Read 2972 times)

0 Members and 1 Guest are viewing this topic.

Rico

    Topic Starter


    Rookie

    • Yes
    • Beginners Python Programming
  • Certifications: List
  • Experience: Beginner
  • OS: Windows 7
Self move Batch file
« on: March 06, 2011, 12:26:45 AM »
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... :) :) :)

Salmon Trout

  • Guest
Re: Self move Batch file
« Reply #1 on: March 06, 2011, 12:49:49 AM »
Why do you need to do this?


Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Self move Batch file
« Reply #2 on: March 06, 2011, 12:51:02 AM »
Why do you need to do this?
Yes, smells like he wants to build a worm in batch.

Rico

    Topic Starter


    Rookie

    • Yes
    • Beginners Python Programming
  • Certifications: List
  • Experience: Beginner
  • OS: Windows 7
Re: Self move Batch file
« Reply #3 on: March 06, 2011, 12:55:26 AM »
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
pause
so 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...

Salmon Trout

  • Guest
Re: Self move Batch file
« Reply #4 on: March 06, 2011, 01:25:14 AM »
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?


« Last Edit: March 06, 2011, 01:44:54 AM by Salmon Trout »

Rico

    Topic Starter


    Rookie

    • Yes
    • Beginners Python Programming
  • Certifications: List
  • Experience: Beginner
  • OS: Windows 7
Re: Self move Batch file
« Reply #5 on: March 06, 2011, 02:22:04 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 ?

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

Salmon Trout

  • Guest
Re: Self move Batch file
« Reply #6 on: March 06, 2011, 02:24:22 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.







« Last Edit: March 06, 2011, 02:42:13 AM by Salmon Trout »