You are here

StartPortableApps.exe

29 posts / 0 new
Last post
Stretch 4x4
Offline
Last seen: 17 years 2 months ago
Joined: 2006-10-25 00:15
StartPortableApps.exe

Hi I am interested in how John created the StartPortableApps.exe, it would be really useful to have something like that can be customized as shortcuts can not be made relative. Was it it made using NSIS, I have started looking into this as it seems that quite powerful exes can be made that launch things in interesting ways, which would be useful for making things happen just the way I like. Any advice on NSIS and how StartPortableApps.exe works would be greatly appreciated.

Thanks Andrew

John T. Haller
John T. Haller's picture
Offline
Last seen: 18 hours 29 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
One line of code

Aside from the usual NSIS setups and configs, it's only a single line of code:

Exec `"$EXEDIR\PortableApps\PortableAppsMenu\PortableAppsMenu.exe"`

You don't really need those quotes, either... they're there from an earlier cut n paste.

Sometimes, the impossible can become possible, if you're awesome!

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

I find it funny you used a scriptable installer for a symlink-type dealie. Blum

Personally I'd have just whipped up a one-line C program (more if you want to emulate $EXEDIR... you have to take argv[0], usually the full path of the exe, and parse it...).

But yeah, I know not all of us use C... but even then I'd have used AutoIt or something more geared toward general purpose stuff... (same goes if I wanted to make a portable app launcher).

Signature automatically removed for being too awesome.

rich.bradshaw
Offline
Last seen: 11 years 6 months ago
Joined: 2006-10-05 08:41
Can you edit the registry

Can you edit the registry using C?

The launcher does more than just run the file, it removes registry entries and things as well. AutoIt is a possible alternative - NSIS does all the right stuff as well!

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

You're thinking the launcher for the portable apps. This EXE just runs another EXE... that's all.

And yes, of course you can edit the registry with C!

http://msdn2.microsoft.com/en-us/library/ms724875.aspx

You can pretty do whatever the hell you want in C... of course it's not going to be as easy as .NET or some other languages.

Signature automatically removed for being too awesome.

John T. Haller
John T. Haller's picture
Offline
Last seen: 18 hours 29 min ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Oh I know

But it was there... and I didn't even have a C/C++ environment setup at the time. I gotta get that setup and replace some of those little bits.

Sometimes, the impossible can become possible, if you're awesome!

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

While you're at it, you can make it portable (I want a Portable Dev-C++!!!) Wink

At least, it'd be easier than Visual Studio... :X

Signature automatically removed for being too awesome.

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 15 years 2 months ago
Joined: 2006-01-06 21:27
Erm

http://www.portasoft.org/ ?
----
Ryan McCue
Santa: Ho Ho Ho!
Kim: Yes, thank you Santa, I am.
(Kath and Kim)

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

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 15 years 2 months ago
Joined: 2006-01-06 21:27
Well

NSIS is quick, easy to learn and very extensible.
Besides, I like it Blum

Too bad symlinks aren't built in to XP, it took Microsoft a while to work out that's what we wanted (and not just shortcuts). I can't wait for Vista Wink
----
Ryan McCue
Cube Games
Life is like a sewer. What you get out of it depends on what you put into it.
(Tom Lehrer)

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

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

I've found the syntax of NSIS quite rigid and not really good for more than small blocks of code for installers. In fact, that's all I use it for... Smile I find it amusing and neat that it's being used for more complex programming tasks not at all related to installers (in fact, portable apps can be used as a way to avoid installers). But, I still think .NET or C++ would be a better candidate for a launcher to be programmed in. Of course, John's already made a proper framework, so at this point he should probably just continue using NSIS since he's already familiar with it, and making new launchers should be trivial, with a twist every now and then to make things interesting of course.

Signature automatically removed for being too awesome.

Stretch 4x4
Offline
Last seen: 17 years 2 months ago
Joined: 2006-10-25 00:15
Interesting

When I finally get NSIS I will probably work it out myself but obviously some of those "usual NSIS setups and configs" do things like find the current path, so that when executed paths can be made relative to this point, getting around the changing drive letter. Are these things created by NSIS or do you have to look at the examples and work out what you need yourself?

thanks

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 15 years 2 months ago
Joined: 2006-01-06 21:27
Well

Some you do, some you don't.
The current executable's directory (the NSIS installer) is $EXEDIR
However, to get the drive letter, you need a separate function.
----
Ryan McCue
Cube Games
Life is like a sewer. What you get out of it depends on what you put into it.
(Tom Lehrer)

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

Stretch 4x4
Offline
Last seen: 17 years 2 months ago
Joined: 2006-10-25 00:15
thanks

Its not to bad searching through the help and finding bits, although the few programs i have tried are much uglier than any of the other portable app launchers, there is a lot of stuff in them that I don't quite understand. I probably might work it out if I read enough but if anyone has the time how would you get the drive letter, could you strip down the $EXEDIR to get the letter

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 15 years 2 months ago
Joined: 2006-01-06 21:27
Here:

http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.14
It's right there in the manual.
----
Ryan McCue
Cube Games
Life is like a sewer. What you get out of it depends on what you put into it.
(Tom Lehrer)

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

Stretch 4x4
Offline
Last seen: 17 years 2 months ago
Joined: 2006-10-25 00:15
messages

I am trying to make my own launcher, as a part of my ejecting of the usb drive process, and I want some way to give feedback if the process fails. Although I do not want a message box where you have to click, to get rid of it. Something like the balloon that pops up after you use windows safely disconnect dialog would be good, as it then disappears after x seconds, so you know it didn't work but you can start working out why and let the message go away itself. Looked for an exe that can do this so I can just run it from my script but the closest I could find is autohotkey, which is also a scripting tool so I have to now work out how to use this, and then link it in to my NSIS script, unless someone can find a better solution. Thanks Andrew

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 15 years 2 months ago
Joined: 2006-01-06 21:27
Here:

http://nsis.sourceforge.net/NotifyIcon_plug-in
You have to get the icon in the tray first. Then you make a balloon.
----
Ryan McCue
Life is like a sewer. What you get out of it depends on what you put into it.
(Tom Lehrer)

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

Stretch 4x4
Offline
Last seen: 17 years 2 months ago
Joined: 2006-10-25 00:15
Great

Thanks you really know a lot about NSIS and how to do things, I thought I finally had everything I needed to accomplish my task but I have come across a problem. I am trying to create a launcher which removes my usb drive. I have an exe that can do this when given the parameters which is easy. My problem is, any executables running off the drive prevent it from being removed. There is two solutions, A. the launcher copies itself somewhere runs and then goes. Or B.my launcher for PStart can put the launcher somewhere and then Pstart can run it on close, the only problem is I need a way for it to delete itself. This is probably need really for either method. Is there a way to make the installer, or launcher self destruct or delete after it has done its job. I don't want it left on the computer, as it could be at school or where ever else, which is messy etc. Thanks Andrew

Stretch 4x4
Offline
Last seen: 17 years 2 months ago
Joined: 2006-10-25 00:15
Yay

I had been searching how to delete the installer for ages and had basically given up hoping someone else could help me. But today I managed to find something which comes close enough. There is a selfdel plugin which I found on the winamp forums which deletes the exe on finish. The only thing I didn't do is get it to delete the folder I put it in but I just changed the location to C: so this doesn't matter. I will put my scripts up soon for anyone who is interested and for any advice on how I went about it. Thanks All Andrew

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

My solution to this problem would be this:

1) USB:\Program.exe is run.
2) Program.exe sees it is being run from USB.
3) Program.exe copies itself to %TEMP%
4) Program.exe runs the copy in %TEMP%.
5) Program.exe quits immediately.
6) %TEMP%\Program.exe is run.
7) Program.exe sees it is being run from %TEMP%.
8) Program.exe does whatever you want it to do, system tray icon, menu, etc.
9) When it's time, Program.exe ejects the drive. Since Program.exe isn't running off the drive, this can work.
10) If successful, Program.exe can try to delete itself somehow... or just leave it sitting in %TEMP% until something else deletes it for you.

Signature automatically removed for being too awesome.

Dirinfo
Offline
Last seen: 10 years 6 months ago
Developer
Joined: 2006-11-24 04:02
Not so usual

I found the Abiword example suggested no so simple at all. Please coud you provide a very very minimal piece of script?

Just to launch a simple "$EXEDIR\App\MyApp.exe"

I suppose the Launcher stays in the U:\PortableApps\MyAppDir\ and I guess $EXEDIR refers to the full Launcher path. I'm I right?

Thank you all for your kind help

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 15 years 2 months ago
Joined: 2006-01-06 21:27
That would be
Exec "$EXEDIR\App\MyApp.exe"

$EXEDIR refers to the launcher's path e.g. If I ran C:\Demented\ZiggyBuggyDoog.exe, the $EXEDIR would be C:\Demented
----
Ryan McCue
Life is like a sewer. What you get out of it depends on what you put into it.
(Tom Lehrer)

"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
Im totally new to NSIS and

Im totally new to NSIS and trying to learn, what would the syntax be to launch an exe located on the root of my usb stick when the NSIS exe ive created is in the PortableApps directly

$EXEDIR wants the exe to be relative to the path of the NSIS exe which I dont want.

Also what do i have to do so that the interface just launches the app like StartPortableApps.exe does rather than show the install dialogue.

Thanks

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 15 years 2 months ago
Joined: 2006-01-06 21:27
Here:

For the Root Directory (C:, D: etc):

;Other header stuff here
!include "FileFunc.nsh"
Section
	${GetRoot} "C:\Program Files\NSIS" $R0
	;$R0="C:"
SectionEnd

For no interface:

;Other header stuff here
SilentInstall silent
;Rest of stuff

Combining these into a functional script:
Priceless Wink
Seriously though:

Name "AppName"
OutFile "AppName.exe"
InstallDir "$EXEDIR"
SilentInstall silent
!include "FileFunc.nsh"
Section
	${GetRoot} "C:\Program Files\NSIS" $R0
	;$R0="C:"
SectionEnd

----
Ryan McCue
Santa: Ho Ho Ho!
Kim: Yes, thank you Santa, I am.
(Kath and Kim)

"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
hmm, doesnt like the

hmm, doesnt like the ${GetRoot} :S

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 15 years 2 months ago
Joined: 2006-01-06 21:27
Well, if you have

the !include "FileFunc.nsh" it should work.
Make sure you have that.
----
Ryan McCue
Santa: Ho Ho Ho!
Kim: Yes, thank you Santa, I am.
(Kath and Kim)

"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
thanks for that, im actually

thanks for that, im actually understanding this now but I would like some advice.

I have a launcher I have created which currently sits in

x:\PortableApps\MyApp\Launcher.exe

Which I want to launch

x:\autorun.exe

At the moment the bit of magic I have is

Exec "$EXEDIR\..\..\autorun.exe"

Is there a cleaner way to do this? As this assumes the launcher is 2 directorys up from the autorun.exe on the root of Secret and assuming that x:\ can change. I basically want a launcher which will just start autorun.exe no matter where it is on the drive.

The MAZZTer
The MAZZTer's picture
Offline
Last seen: 1 year 11 months ago
Developer
Joined: 2006-11-17 15:31
Not sure if NSIS will allow this...

But try just:

Exec "\autorun.exe"

In Windows starting a path with a backslash makes it start at the root of the current drive.

Signature automatically removed for being too awesome.

Ryan McCue
Ryan McCue's picture
Offline
Last seen: 15 years 2 months ago
Joined: 2006-01-06 21:27
Hmm

Dunno about that, could work.

Anyway, you shouldn't use paths with ../ because users change paths Biggrin
The only way to get the root (read: drive letter) is to use GetRoot.
----
Ryan McCue
Santa: Ho Ho Ho!
Kim: Yes, thank you Santa, I am.
(Kath and Kim)

"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
Thanks Mazz, Exec

Thanks Mazz, Exec "\autorun.exe" did the trick.

Although the autorun.exe im running from root reads an ini and for some reason it now wants the ini file in the directory the launcher is run from. Which is weird :S

Topic locked