OpenWith# commands with %windir% and %SystemRoot%

  • Kej Zemunski

    Kej Zemunski - 2014-03-22

    Below are my OpenWith# commands, which work great, including recognizing the drive variable where I store all of my tools. However, if I use system variables SystemRoot or windir in a command, nothing happens. I have to hard-code the path, so my .ini is not portable. Puzzled...

    See OpenWith3, only one works.

    OpenWith0="Cmd: '%exedrive%\1\Graphics\PSP\PSP.exe %filename%' Menuitem: 'PSP Paint Shop Pro' Flags: 'ShellExecute'"
    OpenWith1="Cmd: '%exedrive%\1\Graphics\IcoFX\IcoFX.exe %filename%' Menuitem: 'IcoFX Icon editor' Flags: 'ShellExecute'"
    OpenWith2="Cmd: '%exedrive%\1\Graphics\ScreenshotCaptor\ScreenshotCaptor.exe %filename%' Menuitem: 'ScreenshotCaptor' Flags: 'ShellExecute'"

    OpenWith3="Cmd: '"C:\Windows\System32\mspaint.exe" %filename%' Menuitem: 'Microsoft Paint' Flags: 'ShellExecute'"
    ;OpenWith3="Cmd: '"%SystemRoot%\System32\mspaint.exe" %filename%' Menuitem: 'Microsoft Paint' Flags: 'ShellExecute'"
    ;OpenWith3="Cmd: '"%windir%\System32\mspaint.exe" %filename%' Menuitem: 'Microsoft Paint' Flags: 'ShellExecute'"

    I'm editing the .ini file by hand (very carefully) and I don't think that it matters. I'm on Windows 8.1 and have Admin privs. It looks like these system variables are not seen by ShellExecute.?

  • David Kleiner

    David Kleiner - 2014-03-22

    JPEGView is not expanding environment variables and the windows API methods ShellExecute and CreateProcess don't do it neither.
    But I will add that expansion in a future version, there is an API method for it: ExpandEnvironmentStrings()

    However that is only an issue when you create 'open with' entries by hand in the INI. The dialog from JPEGView will never add environment variables.


  • Kej Zemunski

    Kej Zemunski - 2014-03-29

    Thanks for implementing this! My command now works perfectly, making JPEGView even more portable:
    OpenWith3="Cmd: '%windir%\system32\mspaint.exe %filename%' Menuitem: 'Microsoft Paint' Flags: 'ShellExecute'"
    Yes, I prefer editing text INIs by hand since it's so much easier, plus one can compare file versions, etc. I avoid GUI dialogs if I can :-)


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks