executing .bat file doesn't find target. OK in Explorer

Discussion & Support for xplorer² professional

Moderators: fgagnon, nikos, Site Mods

dunno
Gold Member
Gold Member
Posts: 541
Joined: 2007 Nov 18, 03:00
Location: Tropical Hammock

executing .bat file doesn't find target. OK in Explorer

Post by dunno »

3.3.0.2 x64 10/28/16
Windows 7 Ult.

I execute a .bat file in order to merge two .tgz files (updating hacked firmware file for my ereader).

From within X2 the cmd window returns "cannot find source file", (it's lying because I can see the fvcking thing).

From within windows explorer I execute the same .bat file and it finds the correct path, and .tgz file is updated.

(whilst it appears that I'm knowledgeable with merging .tgz files I have no idea what I'm doing, I just follow the point and click instructions for this hack which has worked find in the past from within X2).

I've also attached the .bat file as a text file. never mind I jpg'd the thing.

P.S. why are all the sentences underlined....?

Cmd path error below
Kilmatead
Platinum Member
Platinum Member
Posts: 4879
Joined: 2008 Sep 30, 06:52
Location: Baile Átha Cliath

Re: executing .bat file doesn't find target. OK in Explorer

Post by Kilmatead »

As the error seems to indicate that it's looking inside the x2 folder itself, that probably means the current-working-directory (which your script relies upon) is misplaced again. Try un-checking Tools -> Options -> Advanced (Tab) -> Don't lock browsed folder.

(Your post is underlined because when you quoted your x2 version you included the bracketed 'U' (for unicode), which the new forum software interprets as the beginning of an underlined senstence, and, of course, never finds the cancelling \U to kill it.) :shrug: The good news is that obviously humans have little to fear from the forum-AI being smarter than us anytime soon.
dunno
Gold Member
Gold Member
Posts: 541
Joined: 2007 Nov 18, 03:00
Location: Tropical Hammock

Re: executing .bat file doesn't find target. OK in Explorer

Post by dunno »

Unchecking the "Don't Lock Folders" fixed it, (I'm trying to get my head around how "Uncheck a Don't lock" unlocks the thing).

silly me for not knowing the Unicode text paste stuff.

Cheers :beer:
User avatar
johngalt
Gold Member
Gold Member
Posts: 654
Joined: 2008 Feb 10, 19:41
Location: 3rd Rock

Re: executing .bat file doesn't find target. OK in Explorer

Post by johngalt »

Kilmatead wrote: 2017 Feb 18, 07:38 As the error seems to indicate that it's looking inside the x2 folder itself, that probably means the current-working-directory (which your script relies upon) is misplaced again. Try un-checking Tools -> Options -> Advanced (Tab) -> Don't lock browsed folder.

(Your post is underlined because when you quoted your x2 version you included the bracketed 'U' (for unicode), which the new forum software interprets as the beginning of an underlined senstence, and, of course, never finds the cancelling \U to kill it.) :shrug: The good news is that obviously humans have little to fear from the forum-AI being smarter than us anytime soon.
I, too was experiencing a similar issue, also dealing with files to flash my Android-based Nexus 6.

This also worked for me.

Just as a curiosity, why does not locking the folder cause this issue?
Image
Kilmatead
Platinum Member
Platinum Member
Posts: 4879
Joined: 2008 Sep 30, 06:52
Location: Baile Átha Cliath

Re: executing .bat file doesn't find target. OK in Explorer

Post by Kilmatead »

johngalt wrote: 2017 Feb 28, 18:03Just as a curiosity, why does not locking the folder cause this issue?
It all rather depends upon what one's definition of what "locking" means, however the mechanics are these:

If this option is un-checked, x2 sets the working-directory to whatever folder you happen to be browsing within at the time. Thus, when you click upon a batch file (or, really, any programme which assumes its own folder as the current-working folder) the new process inherits the default-folder, and assumes it as its own.

On the other hand, if this option is checked, then x2 sets the current-working-directory to the x2 install folder itself, thus messing up any relative-path references the batch-file presumes from its own location.

Now, obviously, your next question is going to be "Why use the x2 install folder, and what does this have to do with locking another folder in a galaxy far far away?"

The answer to that, I'm afraid, is above my pay-grade. I would surmise that as working-directories are stored as a global variable for each process which launches within it, if that folder/script/process goes awry and hangs for some reason, x2 may then be unable to delete/access the folder in question (on the level it needs to for shell-references to work properly), as it's considered to be held in purgatory by another process.

But to be honest, that's just a wild guess - and I suspect that the whole thing is really just a work-around to half-solve a conundrum wrapped up in an enigma of filesystem infidelity (that is to say, a shot in the dark to solve a problem which has no single cause). :shrug: Perhaps Nikos has a more rational explanation, though as much as he has consistently said he keeps planning on "doing away" with this option (yet never does), it is - if nothing else - a semantic slurry-pit.
dunno
Gold Member
Gold Member
Posts: 541
Joined: 2007 Nov 18, 03:00
Location: Tropical Hammock

Re: executing .bat file doesn't find target. OK in Explorer

Post by dunno »

Dear Sir who loves gardening and weeding code,

Why is a folder name which has & in it considered dangerous ?
I used to name folders "abc & def" until some dev pointed out that executing a .bat on that name could have disastrous consequences.
Kilmatead
Platinum Member
Platinum Member
Posts: 4879
Joined: 2008 Sep 30, 06:52
Location: Baile Átha Cliath

Re: executing .bat file doesn't find target. OK in Explorer

Post by Kilmatead »

Because the '&' character is considered a special character under the command shell, and so while it may be valid within a file/folder name, were you to reference that name/path within a batch file without "escaping" the ampersand first (by using the '^' prefix, etc) then cmd.exe will interpret it as a conditional statement, and your carefully crafted batch file will fold up and cry like the most bereft of souls.

So, this is not to say you can't use it in names, just that it requires more care and attention than a cantankerous lawn-mower engine which has been left in the damp too long. Does a busy hammock-dweller like yourself really need the hassle? :wink:
dunno
Gold Member
Gold Member
Posts: 541
Joined: 2007 Nov 18, 03:00
Location: Tropical Hammock

Re: executing .bat file doesn't find target. OK in Explorer

Post by dunno »

Kilmatead wrote: 2017 Mar 01, 07:42Does a busy hammock-dweller like yourself really need the hassle? :wink:
I have this incredible knack of being able to break the most carefully crafted software....through sheer ignorance of code, you see I don't know what the do's and don'ts of this language are, hence the software developers in my old life hated me, as I could reduce their UI's to tears.

The above & issue scared the dev's of that .bat code to the extent that they included in the instructions, "ensure that you don't have any of the following etc" in the folder name. I was proud to have such a influence on the .bat file, whilst knowing that deep down they were shaking their heads in total disbelief that someone would dare/dumb to use a & in a folder name, how could I not know that I cannot use a certain special character which the file name monitor doesn't flag, in a file name ?, silly me.

I'm currently prodding Sony (PS4 UI) and Bethesda (Fallout 4 UI) to do something about their button selections, they're ignoring me now :biggrin:

My hammock is such a drag, I watched the fishermen this morning, extremely tiring, must retire.
User avatar
nikos
Site Admin
Site Admin
Posts: 16402
Joined: 2002 Feb 07, 15:57
Location: UK

Re: executing .bat file doesn't find target. OK in Explorer

Post by nikos »

you can use any characters you like in your names and keep your BAT too. Either enclose arguments in "quotes" or use 8.3 names (lowercase $p etc tokens in xplorer2) that won't have anything funny in them
dunno
Gold Member
Gold Member
Posts: 541
Joined: 2007 Nov 18, 03:00
Location: Tropical Hammock

Re: executing .bat file doesn't find target. OK in Explorer

Post by dunno »

nikos wrote: 2017 Mar 01, 09:22 Either enclose arguments in "quotes" or use 8.3 names (lowercase $p etc tokens in xplorer2) that won't have anything funny in them
Nikos, you don;t understand, I know nothing of your language but I do expect coders to know that users might use characters in file names which might affect execution of the .bat file, as a user is it my responsibility to know what can and cant be done with instructions ?.

I point and click, thats it, I read and do, if instructions say "click the .bat file" I'll do exactly that,

I'm still struggling to understand how uncheck a Don't Lock, unlocks the thing.