Do user commands support relative paths?
Moderators: fgagnon, nikos, Site Mods
relative to what? You can't have plain relative paths since xplorer2 changes its current directory as you browse. What you could do is have commands including environmental variables like
Code: Select all
> %windir%\notepad
Relative to the location of xplorer2. So if I have a portable program inside the xplorer2 folder, can I do something like:
Code: Select all
./foobar/foobar.exe
- FrizzleFry
- Platinum Member
- Posts: 1241
- Joined: 2005 Oct 16, 19:09
Since version 1.7.0.x "don't lock browsed folder" sets the current working directory to the folder that something is launched from by double clicking on it or using the x2 command line. So there is no guarantee that CWD will remain set to the x2 install folder.
Try this:
put this batch file in the x2 folder and use it to start x2 then use the x2path variable in your user commands. For example:
>%x2path%\editor2_UC.exe "$F"
You have to be running Windows 2000 or above for this to work, WIndows 9x (or Me) does not support the %~ modifier.
If your x2 path has spaces then do:
>"%x2path%\editor2_UC.exe" "$F"
Edit: added /P parameter, added x2drive variable
Try this:
Code: Select all
@echo off
set x2drive=%~d0
set x2path=%~dp0
start xplorer2_UC.exe /P
>%x2path%\editor2_UC.exe "$F"
You have to be running Windows 2000 or above for this to work, WIndows 9x (or Me) does not support the %~ modifier.
If your x2 path has spaces then do:
>"%x2path%\editor2_UC.exe" "$F"
Edit: added /P parameter, added x2drive variable
Last edited by FrizzleFry on 2008 Apr 18, 14:53, edited 3 times in total.
- FrizzleFry
- Platinum Member
- Posts: 1241
- Joined: 2005 Oct 16, 19:09
I like SS64.com for command line info. This page explains the ~ modifiers.
%~dp0 returns the drive and path of the batch file.
By placing the batch file in the x2 folder and using it to execute x2, the x2path variable, which the batch file creates, is inherited by the x2 process and can be used in user commands.
The drawback is that these user commands (which use x2path) will not work if you do not use the batch file to execute x2.
%~dp0 returns the drive and path of the batch file.
By placing the batch file in the x2 folder and using it to execute x2, the x2path variable, which the batch file creates, is inherited by the x2 process and can be used in user commands.
The drawback is that these user commands (which use x2path) will not work if you do not use the batch file to execute x2.
Last edited by FrizzleFry on 2008 Apr 16, 17:07, edited 2 times in total.
- FrizzleFry
- Platinum Member
- Posts: 1241
- Joined: 2005 Oct 16, 19:09
- FrizzleFry
- Platinum Member
- Posts: 1241
- Joined: 2005 Oct 16, 19:09
I did test it but I am running XP not Vista.
See if the x2 process is inheriting the x2path variable.
After you run the batch file, which runs x2, open a command prompt from x2 (F10, Enter). then type set and look for x2path or echo %x2path%.
If you cannot find the x2path then Vista is handling inheritance differently than XP and 2000 do and this will not work. If the x2path variable is set correctly then the user command is incorrect.
Another problem is that you need to exit all other x2 processes before you run the batch file otherwise the new instance will run in the previous processes' environment.
See if the x2 process is inheriting the x2path variable.
After you run the batch file, which runs x2, open a command prompt from x2 (F10, Enter). then type set and look for x2path or echo %x2path%.
If you cannot find the x2path then Vista is handling inheritance differently than XP and 2000 do and this will not work. If the x2path variable is set correctly then the user command is incorrect.
Another problem is that you need to exit all other x2 processes before you run the batch file otherwise the new instance will run in the previous processes' environment.
Last edited by FrizzleFry on 2008 Apr 16, 19:47, edited 1 time in total.
x2path is there:
My User command is:
It's not working. What's wrong?
Edit: This works
Code: Select all
x2path=C:\Program Files\zabkat\explorer2\
Code: Select all
>"%x2path%\editor2_UC.exe"
Edit:
Code: Select all
>editor2_UC.exe
Last edited by desslok on 2008 Apr 16, 19:53, edited 1 time in total.