Re: Dos Batch File
Hi Franc
Thank you very much for your ideas. I loved the one where you combined echo
and find. I had never thought this way. And I didn't know either %0 returned
the name of command line. Good learnings for me.... But...
It works but don't solve my problem.
It's a kind of protection against copies I did for a x_program, and
x_program must run when PC starts without any interference of user. So, it
works like this, when PC starts:
1) In config and autoexec I create a virtual drive D: with ramdrive command.
2) my_dos_program unzips the program to drive D: using a password which
contains the HD serial number.
3) x_program starts imediately after extraction.
Once running, only ctrl-alt-del stops x_program and, of course, x_program
disappears with drive D:
So users can use but can't copy x_program. It only works in HD it was
installed because of pkzip password, and nobody can see x_program after
extraction, but running.
I know it's a very simple protection, but it was the best I could think.
My_dos_program has a copy of autoexec.bat. So, if you try to edit
autoexec.bat to not run x_program after extraction so as you can see it in
drive D, my_dos_program won't decompress x_program.
In fact, my_dos_program is two programs that run one after another in
autoexec.bat. If the second one not runs 0.5 seconds after the first one at
most, I think someone is trying to execute autoexec commands one by one in
line command, and my_dos_program won't decompress x_program.
Are you stil there? lol..
But, I believe a smart guy like you, would copy the 2 parts of
my_dos_program to a new batch file and.. tchan tchan !!! x_program will be
extract to drive D and be copied making me cry.. :-(........
That's the reason I want to know if my_dos_program was called by autoexec,
because in autoexec, x_program starts imediately after (I can't run x_program
within my_dos_program because of dos limited memory.)
So, your ideas were greats but they aren't enough to stop a smart guy, who
would analyze autoexec line per line. I also know, nothing stops a smart guy,
but I try to difficult his life as much as I can.
Thank you, Franc, even if you don't have more ideas for me..
"Franc Zabkar" wrote:
> On Tue, 27 Nov 2007 06:23:11 +1100, Franc Zabkar
> <fzabkar@iinternode.on.net> put finger to keyboard and composed:
>
> >On Tue, 27 Nov 2007 06:16:34 +1100, Franc Zabkar
> ><fzabkar@iinternode.on.net> put finger to keyboard and composed:
> >
> >>I don't know how to detect autoexec.bat directly, but you could test
> >>for a flag in an environment variable.
> >>
> >>For example, add these lines to autoexec.bat and then test for the
> >>existence of the environment variable, flag, within your program.
> >>
> >> set flag=%0
> >> your_dos_program
> >> set flag=
> >>
> >>%0 contains the name of the calling batch routine, in this case
> >>autoexec.bat.
> >
> >Another way is to call your program as follows:
> >
> > your_dos_program %0
> >
> >Then parse the command line arguments within your program.
>
> Here's a third way. It relegates the detection of autoexec.bat to a
> calling batch file.
>
> Add the following line to autoexec.bat:
>
> call your_batch_file %0
>
> Then create a new batch file consisting of these lines:
>
> @echo off
> echo %1 | find /i "autoexec.bat" > nul
> if errorlevel 1 echo autoexec.bat is not running
> your_dos_program
>
> - Franc Zabkar
> --
> Please remove one 'i' from my address when replying by email.
>