You are here

is there a tutorial

7 posts / 0 new
Last post
PC MAX
Offline
Last seen: 17 years 10 months ago
Joined: 2007-01-04 13:29
is there a tutorial

Is there a tutorial for creating portable applications?
I downloaded NSIS but it looked so hard Sad
anybody can help?

The MAZZTer
The MAZZTer's picture
Offline
Last seen: 1 year 10 months ago
Developer
Joined: 2006-11-17 15:31
Samples

John has released the source code for the launchers he has made thus far... I'm afraid it's not easy to understand. But, once you've looked through the NSIS help and start to understand the syntax, you might try looking at his code.

Perhaps a more conceptual approach will be useful... I'm afraid I have little practical experience to draw from.

First, we have a program we want to make portable. Many programs aren't designed with this in mind. Some have optional features that can make them more portable-friendly. Here's a few examples.

Let's say we want to make ScummVM (www.scummvm.org) portable. First we need to see if it does anything unfriendly to portability.

Ex: Writing user settings to the registry is very unfriendly. At best, the default settings suit you and this can have little impact. Worser, you may need to change some settings. When you go to another computer, these settings will have reverted because they were stored on the first computer. Thus our program would have to work around this. At worst, a program might leave pointers to itself in the system registry (file associations, start menu, desktop... I found a program that places its icon on the desktop every time you run it, yeck!) which will of course break once you remove the usb drive. Not fun. Your program would have to revert or block all these system registry changes.

Fortunately a quick search through the registry reveals ScummVM does not utilize it, so we don't have to be concerned with that.

Now, user settings can also be written to files on the computer's hard drive or in a user profile. Same problems as above; however it is easier to fix, because moving files around is easier than moving registry entries around since your USB drive can't have it's own mobile registry (actually... that's a good idea. Get on that Microsoft, I want a HKEY_MOBILE_DEVICE!).

A quick hard drive search reveals ScummVM dumps its configuration file in your Windows directory. This is a problem, mainly because if you set up games in ScummVM, they won't be there when you switch computers.

Now, we could solve this by making a launcher which does the following:

1) Look in the Windows directory for a scummvm.ini.
2) Back it up somwhere
3) Put our scummvm.ini from the usb drive in its place.
4) Run ScummVM
5) Wait for ScummVM to quit.
6) Move scummvm.ini from Windows back to the drive.
7) Restore the old scummvm.ini

Indeed, this may have to be done with some programs. With registry changes, it becomes more complicated because you can't just move a file; you have to manipulate the registry (I think John uses command line regedit.exe options to do all the hard work for him... I tip my hat, since I would have done it the hard way!).

Again, fortunately, a quick search through the ScummVM docs for information about scummvm.ini reveals a useful command-line param: --config. Now all we have to do is point it to OUR USB drive file to make ScummVM (almost) portable! We don't even need more than a batch file as a launcher... although with a different program a launcher may be required.

(Actually, it's slightly more complicated since ScummVM stores absolute paths in the INI file. Luckily, you can edit them by hand with Notepad into relative paths and everything works, but ideally a launcher could scan scummvm.ini after ScummVM quits and make these changes automagically... this is left as an exercise to the very determined reader. Smile

Signature automatically removed for being too awesome.

PC MAX
Offline
Last seen: 17 years 10 months ago
Joined: 2007-01-04 13:29
Thanks .. but

Thanks a lot for this small guide.
But, as in your example, what would happen if the application crashed suddenly?
1- The original version of scummvm.ini will be lost.
2- The portable application can't take a copy of it (scummvm.ini).
------------

Another question..,
Can't I use a program other than NSIS?
Like Autoit (http://www.autoitscript.com) because it looks easier for me, as I usually create my applications using it.
------------

About Firefox Portable..
When I explored the FirefoxPortable folder, I saw many different folders.
App, Dara and Other
I understood what 'Other' contains.
But for 'Data' I didn't. (Especially 'Data\profile')
As for 'App', I found three folder, firefox, Appinfo and DefaultData.
I found out that firefox contains the data of the Firefox itself, so, what are AppInfo and DefaultData used for?
-------------

Was FirefoxPortable.exe created by using NSIS?
If not, for what is that source in the 'Other\FirefoxPortableSource' folder?
-------------

If I want to make my app portable, and install it on PortableApps, the extension has to '*.paf.exe'. How to do that? Is that by comperssing it using 7z ?

And thanks very much again Biggrin Smile

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 15 years 1 month ago
Joined: 2006-01-06 21:27
.

Data = Your settings
AppInfo = For the menu, don't worry about that yet until John releases the spec.
DefaultData = Default settings, copied to Data if there are no settings.

Yes, you can use AutoIt if you want, it doesn't matter.

Yes, FirefoxPortable.exe is created by NSIS, but it's open-source so you have to have the source.

Yes, it's a self-extractor from 7-Zip. You have to have inside the archive:

AppNamePortable
AppNamePortable\App
AppNamePortable\App\AppName
AppNamePortable\Data

----
Ryan McCue
Person 1: Oh my god. You will never believe what just happened.
Person 2: What?
Person 1: I can't remember, I've forgotten.

"If you're not part of the solution, you're part of the precipitate."

PC MAX
Offline
Last seen: 17 years 10 months ago
Joined: 2007-01-04 13:29
What if the application

What if the application crashed suddenly? like the USB was disconnected suddenly.
What would happen to the data stored on the PC ? and the back up of the data (if existed somewhere on the harddisk) ?

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 15 years 1 month ago
Joined: 2006-01-06 21:27
It would stay there

It would just stay there.
The backup is kept in the Data directory anyway.
----
Ryan McCue
Person 1: Oh my god. You will never believe what just happened.
Person 2: What?
Person 1: I can't remember, I've forgotten.

"If you're not part of the solution, you're part of the precipitate."

dannyoneill
Offline
Last seen: 17 years 10 months ago
Joined: 2006-12-28 12:23
I recommend looking at the

I recommend looking at the launcher for Suduko, I think thats the simplist ive found so far.

Topic locked