Jump to content

Help needed creating a portable executable.


ahmedah

Recommended Posts

Hello ,

I Know bat script but I have a question :

How To make code when I exit from program

do another code ..

example : I but a program when user exit from

this program I delete any file ..

Thanks for any one help me

Link to comment
Share on other sites


Please provide more information, give at least an example of what you are wanting and do try to improve your English.

Thank you.

Virist Thank you ..

Example ..

I make one program portable with win rar ( Extract to temp ).. and I move some important files to run this program to their corecct place in windows .. like regestry files in regestry editor ( By MS - Dos btatch Of course ) and move some dll files to windows folder .. all this in silen install when user start the program .. and you know it is portable .. mean i must delete this Files and registry keys .. we can contfronting this problem with run messege show on screen when program start .. and it have button .. after user end program .. click this button .. and delete the files ..

but i want another method to delete this files .. by batch ( MS Dos )

I Do not have idea for that but it is example for batch line i want

If program.exe exit delete folder

Of couse it does not correct but i wnat line make same work

ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ

And If You have another method to make portable tell me

Thanks .. and please help me

Link to comment
Share on other sites

ahmedah,

we need yet some more details, as your question involves several different techniques.

Basically your:

If program.exe exit delete folder

would be written in batch as:

IF EXIST C:\myfolder\myprog.exe RMDIR /S /Q C:\myfolder

About shared .dlls, you may try to NOT copy them to the %SystemRoot%\System32\ folder and use .local, see this:

http://www.boot-land.net/forums/DLL-HELL-t3839.html

On the other hand, since you might severely mess up the destination PC, if you really need to copy (and later delete) "shared" .dlls you may want to make sure that you do not delete a file that was on the system BEFORE you ran your "portable".

As a VERY basic example, supposing you use a .dll named ANAME.DLL:

IF EXIST %SystemRoot%\System32\ANAME.DLL (
REN %SystemRoot%\System32\ANAME.DLL ANAME.DLL.OLD
COPY /B /V C:\mytempfolder\ANAME.DLL %SystemRoot%\System32\ANAME.DLL
ECHO TO RESTORE ANAME.DLL.OLD ANAME.DLL>>C:\mytempfolder\portablelog.log
)

And later, when exiting the program:

FOR /F "tokens=3,4 delims= " %%A IN (C:\mytempfolder\portablelog.log) DO (
COPY /B /V %SystemRoot%\System32\%%A %SystemRoot%\System32\%%B
)

Mind you the above are just UNTESTED examples, only useful to illustrate the idea.

About Registry entries, you will need to study REG.EXE syntax and export any (if existing) keys and values that you are going to overwrite and later restore them.

The Rob van der Woude site mentioned early is a very good source for this kinf of batch scripting, but of course do not expect to find a pre-made solution.

jaclaz

Link to comment
Share on other sites

First Thank you

About Your First Code ( If Exits ... )

1 - Is It Can work for Programs work in Task MAnager ..

2 - How Can I make That With Not ..

3 - THis Code Work when its time come .. I want It recoming every second for well user exit program it do the action >> ( If I Do not use code for when program exit do the action )

--------------------------------------------------------

Next ..

When I Do portable I well say that user can not use portable if program is on his computer

Can You explain to me

what this code doing

FOR /F "tokens=3,4 delims= " %%A IN

-------------------------------

More Details

And I take a example for KAV .. and I want that :

I have a messege box .. has text : You Are Close Kasper .. You Can Get More Enformation In This Link http://...........

I want to make a batch ( MS-DOS ) Code .. User Run It After Start KAV

When He exit KAV .. this messege is start

Thanks

Link to comment
Share on other sites

ahmedah,

believe me, no offence intended :), but your explanation is hardly understandable, and, from the few things I can understand you are simply missing some pre-requisites:

1) average knowledge of English

2) BASIC knowledge of batch programming

In other words, you are asking here:

"How do I build a skyscraper?"

but you don't know (yet):

1) how to pour concrete/cement

2) how to assemble steel

3) how to lay bricks

And you have only:

1) a hammer

2) some nails

3) a few wooden planks

4) NO bricks, NO steel NO concrete/cement

What I can suggest you is to forget for the moment about building a "portable" application and study some basic batch programming.

As said the Rob van der Woude site:

http://www.robvanderwoude.com/

has a lot of examples and some very good simple explanations for most if not all batch commands, as an example, this answers your question about FOR loops:

http://www.robvanderwoude.com/ntfortokens.html

(this can help you understand HOW to do things, and if there is something you have problems with, you may ask for help here)

BUT BEFORE attempting to learn from there, you NEED to study ALL commands on this site:

http://www.ss64.com/nt/index.html

(these are the bricks, the steel and concrete you need before knowing how to assemble them)

I am sorry I cannot help you at the moment :(, but until you do not have the base knowledge there is no sense in giving you info that will only confuse you further.

jaclaz

Link to comment
Share on other sites

This topic was allowed to continue in the hope that you were capable of providing sufficient information and knowledge in order for it to progress.

At this time however it appears that you unable to do this, from what you've provided thus far you will be unlikey to achieve your goal in the very near future if you intend to continue down this route.

If you tell us exactly what the application is, what needs importing to the registry, which files need moving to specific locations, when they need moving etc. and what exactly you require to be allowed to be saved and where we may be able to give you a few pointers. It is unlikely that members will be prepared to write the thing for you and I'm fairly sure, even with my extensive knowledge of NT Command Scripting, that it is not going to be easy to do at all.

I'd strongly suggest you start to walk before you can run!

This topic will be closed if the information required is not provided.

Link to comment
Share on other sites

I think we can help you better if you explain what your self extracting sfx package is doing.

1. Where is it extracting the files?

2. What are the registry paths where it writes registry settings?

I think it would be more easier for us to help that way. I think it could be very simple to write a VBScript that waits for the program to exit and then deletes all the files and registry keys.

Link to comment
Share on other sites

This Is My Explain :

I want to make Kaspersky Portable using winrar .. OK ..

I will extract program files and regestry keys and dll files in %temp%

I move files to thear correct place and Emport regestry .. Silently

Then I Run exe file of KAV

and I want when user exit the program .. ( Click Close ) All files I moved to correct place .. delete it .. with regestry keys of corse ( Silently )

((Don't Keep any Files And Regestry For Portable ))

I search for code .. when Exit Program .. do what I said

Thanks

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...