batch files, current directory

Discussion & Support for xplorer² professional

Moderators: fgagnon, nikos, Site Mods

Post Reply
billou31
Member
Member
Posts: 62
Joined: 2004 Oct 27, 14:00

batch files, current directory

Post by billou31 »

When I execute a batch file from any directory using explorer2, the shell starts in the zabkat folder (Program Files\...).  Which means that I need fully-qualified paths coded in all of my batch files, or some logic to determine the current directory and then cd to it.  I have many existing utility batch files that expect the shell to start in the current directory (which is the default  behavior of Windows Explorer) and I do not want to have to modify them.  
I do not want to use any of xplorer2's shell features, I just want it to behave like a dual-paned Windows Explorer replacement (which to an acceptable degree I have been able to configure it to be, until now).
Is there a way to configure xplorer2 to start shells in the current directory?
Thanks.
billou31
Member
Member
Posts: 62
Joined: 2004 Oct 27, 14:00

Post by billou31 »

Also, I just noticed that sort orders apply globally to all folders.  is there a per-folder sort order?
User avatar
fgagnon
Site Admin
Site Admin
Posts: 3737
Joined: 2003 Sep 08, 19:56
Location: Springfield

Post by fgagnon »

a.  on Tools | Options... | Advanced tab UNcheck Don't lock browsed folder

b. for individual folder settings, use
Actions | Folder settings | Save
billou31
Member
Member
Posts: 62
Joined: 2004 Oct 27, 14:00

Post by billou31 »

I can't uncheck that value; I find my self constantly deleting things, and it's quite annoying to have to remember to browse to another folder before I can delete (or receive an annoying error message).  Any other way?  This is kind of a deal-breaker for me, since I just recently had to put on the 'windows admin' hat, and I find myself knee-deep in shell scripts.

As for the second response,  thanks!
billou31
Member
Member
Posts: 62
Joined: 2004 Oct 27, 14:00

Post by billou31 »

Maybe there's a way to change how a file with a given extension is executed?  E.g. if filetype is 'cmd', change the environment before executing a shell script: cmd.exe /c <script to determine current directory> <cd to current directory> <execute desired script>

I don't know anything about the capabilities of this software, that's just pure speculation.
User avatar
nikos
Site Admin
Site Admin
Posts: 15806
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Post by nikos »

the only other workaround would be to use full paths for all commands inside the script, e.g. using $F instead of $N
CmputrAce
Member
Member
Posts: 10
Joined: 2006 Dec 27, 18:38

Post by CmputrAce »

nikos wrote:the only other workaround would be to use full paths for all commands inside the script, e.g. using $F instead of $N
Is there no way to tell xplorer2 to run batch files / executables from the folder in which they reside? Surely that information is available. If I'm in File Explorer and double-click on a .bat / .cmd file, it executes the file from the folder it's in - I can't imagine ever wanting to run it from the xplorer folder.

Thank you,
CmputrAce
User avatar
nikos
Site Admin
Site Admin
Posts: 15806
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Post by nikos »

you can put "cd $p" as the first command in the batch file
CmputrAce
Member
Member
Posts: 10
Joined: 2006 Dec 27, 18:38

Post by CmputrAce »

nikos wrote:you can put "cd $p" as the first command in the batch file
I'm not sure what that's supposed to do, but I added as the first command in the batch file and it didn't work. I tested it from the command prompt and got:
C:\>"C:\Program Files\Pentaho\ReportDesignWizard\reportwizard.bat"

C:\>cd $P
The system cannot find the path specified.

C:\Documents and Settings\jb78071>set PATH=C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;c:\sys;c:\sys\bin;I:\Program Files\IDM Computer Solutions\UltraEdit-32;C:\Program Files\Subversion\bin;

... and so on...
User avatar
nikos
Site Admin
Site Admin
Posts: 15806
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Post by nikos »

try "$P" or $p (spaces are giving you trouble)
User avatar
FrizzleFry
Platinum Member
Platinum Member
Posts: 1241
Joined: 2005 Oct 16, 19:09

Post by FrizzleFry »

$P is an internal x2 variable.  It can be used from x2's addressbar/commandline, in user commands, and from the script generator but it is not available from a batch file.

Just create a layout which has "Don't lock browsed folder" disabled and use it to execute batch files.

You can also use variable modifiers to get to the batch file's folder:
echo %~dp0
%~d0
cd %~p0

%0 is the batch file's name (including path)
%~d0 extracts the drive
%~p0 extracts the path

See "Using batch parameters" in Help and Support
Post Reply