SyMenu Forum

SyMenu

 

HomeConfigure portable programs

How to configure programs in SyMenu

Autorun 32 or 64 bit version of app Messages in this topic - RSS

Jess
Jess
Posts: 4


21/05/2015
Jess
Jess
Posts: 4
Update 25 May 2015: Re-wrote the script to fix some bugs and typos, and also to allow additional parameters to be passed to the target app. Attached zip and source files updated. Additional instruction inserted below.

==========


I wrote an AutoHotkey script to detect if the current OS is 32 or 64 bit, and then run the correct version of an app. Obviously, this is only applicable to apps which come in 32 and 64 bit versions! The source code is attached for those who want to check it out, or compile it with AutoHotkey themselves (remember to compile as 32 bit so that it will run on any Windows machine). The compiled EXE file is also attached if you are happy to take me on trust.

How To Use It
1. Place SyMenuRun32or64.exe somewhere on the drive where you have installed SyMenu.
2. Open the SyMenu Configuration window (Tools=>Configuration in the pop-up menu).
3. Either drag SyMenuRun32or64.exe using your favourite file manager onto the SyMenu Configuration window, or use the Browse for SyItem button at the right side of the Path text box in the Configuration window to locate it.
4. Enter the name of the app you want to run in the Program text box.
5. Use the Browse for icon button at the right side of the Icon text box to select the EXE file you want to run (either the 32 or 64 bit version, it makes no difference)
6. Enter the paths to the 32 and 64 bit versions of the app you want to run in the Program Arguments text box (under Additional Params) like this: "#:\path\to\32bit_file.exe" "#:\path\to\64bit_file.exe"
(SyMenu automatically converts the # symbol to the current drive letter before passing the parameters to SyMenuRun32or64.exe)
7. If you want the app to run only if there are no other instances of it running, then add a third parameter like this: "1"
Be sure to insert a space between the 2nd and 3rd parameters. However the third parameter is optional. If you omit it then SyMenuRun32or64.exe will attempt to run the app regardless.
8. If you want to pass parameters to the target app, add them after the third parameter (which must be present). Separate all parameters with a space.
9. Click the Save or Save & Exit button.

See attached SyMenuExample.png for an example of what the Configuration should look like.

.
edited by Jess on 21/05/2015
edited by Jess on 21/05/2015
edited by Jess on 21/05/2015
edited by Jess on 21/05/2015
edited by Jess on 21/05/2015
edited by Jess on 25/05/2015

link
VVV_Easy_Symenu
VVV_Easy_Symenu
Posts: 95


10/09/2015
VVV_Easy_Symenu
VVV_Easy_Symenu
Posts: 95
Very useful. Thank you.


Adding an example, CCleaner.
I install CCleaner with SPSuite, add SyItem to SyMenuRun32or64 with parameter (copied from the original links):
".\ProgramFiles\SPSSuite\SyMenuSuite\CCleaner_Portable_sps\CCleaner.exe" ".\ProgramFiles\SPSSuite\SyMenuSuite\CCleaner_Portable_sps\CCleaner64.exe" "1"
and I hide the two original links (I must copy one representative icon for avoid the SyMenu wipe).
link
Ilias
Ilias
Posts: 5


26/11/2015
Ilias
Ilias
Posts: 5
I have implemented a simple batch script for doing that , but your app it's so much upper levels. Thanks !
link
ZeDingo
ZeDingo
Posts: 8


06/02/2016
ZeDingo
ZeDingo
Posts: 8
IsOS_64bit() {
; Returns TRUE for 64bit OS
Return (FileExist("C:\Program Files (x86)")) ? 1 : 0
}


Not everyone has Windows installed on C:. You should use "%SYSTEMDRIVE%\Program Files (x86)", or check either PROCESSOR_ARCHITECTURE or PROCESSOR_ARCHITEW6432 is AMD64 or IA64.
PROCESSOR_ARCHITEW6432 will be AMD64 or IA64 when running via WOW64.
PROCESSOR_ARCHITECTURE will be AMD64 or IA64 when running 64-bit native.

And just in case everything's running in 32-bit mode on a 64-bit machine, launch the 64-bit app with %SYSTEMROOT%\sysnative\cmd.exe /c
HOWTO: Detect Process Bitness

EM64T is another possible value of PROCESSOR_ARCHITECTURE, but quite rare.
Possible values of %PROCESSOR_ARCHITECTURE%
link
Jess
Jess
Posts: 4


08/02/2016
Jess
Jess
Posts: 4
ZeDingo wrote:
Not everyone has Windows installed on C:.


Absolutely correct! It was a bit of quick and dirty code written long ago which worked for me (and, I suspect, for the vast majority of Windows users). As it happens AutoHotKey has had a built-in variable A_Is64bitOS since version 1.1.08 which removes the need for a function. However, I can't test it (or any of your suggestions) because I am no longer a Windows user, having moved on to Linux Mint. Feel free to post updated or alternative source code - I'm not possessive wink

Cheers!
link
ZeDingo
ZeDingo
Posts: 8


28/02/2016
ZeDingo
ZeDingo
Posts: 8
Here it is as a CMD script. It doesn't pass parameters because Windows is absolutely terrible at handling parameters in batch files. I'm writing a Win32 utility that will handle this whole mess correctly.

Edit: In a batch script, the fastest/easiest way to check for 64 bit arch is the environment variables. Inside a program, Microsoft recommends using GetProcAddress on kernel32.dll to make sure the call to GetNativeSystemInfo is safe, then GetNativeSystemInfo into a SYSTEM_INFO struct blah blah heavy crap we probably don't need.

I pulled out my Windows 7 ISOs (will need to check on XP/Vista) and opened up the install.wim files. WiaExtensionHost64.dll, ntvdm64.dll, and wowreg32.exe do not exist in 32-bit System32, but do exist in both SysWOW64 and 64-bit System32. This edit is a reminder to myself to try and use the faster(?) method of checking for a file's existence rather than wading through unnecessary WINAPI calls.
edited by ZeDingo on 29/02/2016

Attachments:
bitexec.cmd
link
VVV_Easy_Symenu
VVV_Easy_Symenu
Posts: 95


31/12/2016
VVV_Easy_Symenu
VVV_Easy_Symenu
Posts: 95
Non official Update:
  • 1) Use of A_Is64bitOS in place of IsOS_64bit() as Jess suggested.
    2) Change working directoy to the app before run the app.
Important note:
Since SyMenu version 5.07 (New SyMenu version 5.07) the resolution for relative paths has changed so if you want use the autorun like the example, 7-Zip:

".\ProgramFiles\SPSSuite\SyMenuSuite\7-Zip_(x86)_sps\7zFM.exe" ".\ProgramFiles\SPSSuite\SyMenuSuite\7-Zip_(x64)_sps\7zFM.exe" "0"

you need save and use "SyMenuRun32or64.exe" in the SyMenu.exe dir for get the same path that the app.
.New exe compilation (change if you have problems of exe disappearance)
.
edited by VVV_Easy_Symenu on 03/02/2017

link
Gianluca
Gianluca
Administrator
Posts: 669


03/01/2017
Gianluca
Gianluca
Administrator
Posts: 669
Ok I haven't seen that you already solved the problem. Thanks.

My two cents, if someone prefer leaving the SyMenuRun32or64.exe in its own folder (for example ".\ProgramFiles\SyMenuRun32or64"), you can use the ..\ to go down one level to the SyMenu root and then add the relative path to the program to execute.

To stay in your example it's something like this:
"..\SPSSuite\SyMenuSuite\7-Zip_(x86)_sps\7zFM.exe" "..\SPSSuite\SyMenuSuite\7-Zip_(x64)_sps\7zFM.exe"
edited by Gianluca on 03/01/2017
link



UGM.NET ©2002-2017
By Gianluca Negrelli - Contact me