You are here

Running a .bat from the Portable Apps Launcher

9 posts / 0 new
Last post
th3ophilos
th3ophilos's picture
Offline
Last seen: 12 years 3 months ago
Joined: 2012-07-05 17:37
Running a .bat from the Portable Apps Launcher

I have a bit of an odd problem.

I am using the 'Portable Python' from portablepython.com.
This package includes the PyScripter IDE.
I am fond, however, of working with IDLE, python's built in IDE.
I browsed through the contents of the portable app and found that IDLE could still be launched by running a batch file. The contents of the batch file appear to run a python script in the python engine to generate the IDLE GUI (I'm just guessing here, I can post the code if you like).

Ideally I would like to be able to launch IDLE from my portableapps launcher/menu. The '.exe' in the root of the app folder right now are for PyScripter, and therefore PyScripter is what shows up in my portableapps launcher/menu.

I've pondered several solutions, but so far nothing has been useful. I can't move the batch file without rewriting all the relative paths in its code, and I don't think the launcher looks for batch files. The launcher doesn't appear to look for shortcuts either (and relative shortcuts on a flashdrive are a pain anyway). Packaging the batch file as an '.exe' is problematic, because the '.exe' extraction places it in a temp folder- invalidating all of the paths in the batch file. (I suppose I could rewrite all the relative paths to work from inside the temp folder...? AGH!)

Does someone have some helpful advice here?

(First post here! Hello all!)

Aluísio A. S. G.
Offline
Last seen: 8 years 2 months ago
DeveloperTranslator
Joined: 2010-11-09 17:43
Post the batch

If it just calls Python, it'll be very easy.

Previously known as kAlug.

th3ophilos
th3ophilos's picture
Offline
Last seen: 12 years 3 months ago
Joined: 2012-07-05 17:37
The Contents...

Here is what the batch file contains:

| @echo off
| rem Start IDLE using the appropriate Python interpreter
| set CURRDIR=%~dp0
| start "IDLE" "%CURRDIR%..\..\pythonw.exe" "%CURRDIR%idle.pyw" %1 %2 %3 %4 %5 %6 %7 %8 %9

Aluísio A. S. G.
Offline
Last seen: 8 years 2 months ago
DeveloperTranslator
Joined: 2010-11-09 17:43
Just one more thing

Where is the batch file located, relative to where Portable Python is installed?

Previously known as kAlug.

th3ophilos
th3ophilos's picture
Offline
Last seen: 12 years 3 months ago
Joined: 2012-07-05 17:37
File Tree...

Dropbox/Flashdrive
|---PortableApps
|---|---Portable-Python
|---|---|---EXECUTABLES.exe
|---|---|---App
|---|---|---|---PYTHONW.exe
|---|---|---|---Lib
|---|---|---|---|---idlelib
|---|---|---|---|---|---idle.bat

Bennieboj
Bennieboj's picture
Offline
Last seen: 5 years 3 months ago
Joined: 2010-09-16 07:28
It's a start...

So if I got it right, you want an exe that does the same as the batch file?

I downloaded portablepython 3.2...
I copied the files inthere to the PAL template. (an older version, but who cares...)

For other people who want to try, this is my launcher.ini:
[Launch]
ProgramExecutable=pythonw.exe
WorkingDirectory=%PAL:AppDir%
LaunchAppAfterSplash=true
SinglePortableAppInstance=true
CommandLineArguments=%PAL:AppDir%\Lib\idlelib\idle.pyw

I didn't use the "IDLE" part, I didn't see the function of that part.
Nor did I use the " %1 %2 %3 %4 %5 %6 %7 %8 %9" parts:
I didn't know how to pass command line parameters to the exe, I never used that function of PAL and I didn't have that much time.

I also noticed that the pythonw.exe doesn't get closed, I don't know how to fix that atm, I suppose custom code...

Here's a SF link maybe Klaug can work further on this...
LINK

Yes, I set the working directory!

th3ophilos
th3ophilos's picture
Offline
Last seen: 12 years 3 months ago
Joined: 2012-07-05 17:37
Thanks for the help so far!

Thanks for the help so far!

Unfortunately that didn't work.

When I opened the executable, it warned me that paths had changed, and that this was not advisable- I clicked ok, and the error closed,
then I got the development splash screen, it closed.
Nothing else happened though.

(I cannot recreate the error message to get the actual content.)

Is there anything else I should test?
(...or should I try to get in contact with Klaug...?)

th3ophilos
th3ophilos's picture
Offline
Last seen: 12 years 3 months ago
Joined: 2012-07-05 17:37
I've Got a Working Fix

I managed to change the relative paths and package the bat as an exe with a software called "Quick batch File Compiler".

The code I ended up using is simply modified to run from the root directory of the app:

| @echo off
| rem Start IDLE using the appropriate Python interpreter
| set CURRDIR=%~dp0
| start "IDLE" "%CURRDIR%\App\pythonw.exe" "%CURRDIR%\App\Lib\idlelib\idle.pyw" %1 %2 %3 %4 %5 %6 %7 %8 %9

This will work for me, but if anyone here at PortableApps wanted to develop a fully supported version I'd give them a hug and a handshake!

Thanks for your help Kalug and Bennieboj!

This is the executable: http://dl.dropbox.com/u/10942543/Stuff%20For%20The%20Internet/Portable%2...

Bennieboj
Bennieboj's picture
Offline
Last seen: 5 years 3 months ago
Joined: 2010-09-16 07:28
I know Quick Batch File Compiler...

I know Quick Batch File Compiler. It uses UPX to compress the exe. Some antivirusses will flag the exe as a false positive, deleting your exe.

About the error message: that's normal the first time you opened it.
Normally when it's a real installer this won't happen.

Did you unzip the file I uploaded?
If you didn't do that (and ran the exe from the zip), thats the reason nothing showed up after the splash screen.

If you did, maybe the exe is being blocked by your antivirus or something, I'm not sure. (This is normally not the case, since most AV's know that a PA launcher ain't bad ^^)

Yes, I set the working directory!

Log in or register to post comments