[<<]Message[>>]    [<<]Author[>>]    [<<]Subject[>>]    [<<]Thread    

Number : 4772 Date : 2003-06-08 Author : Kan Yabumoto Subject : Re: Installing Xxcopy Size(KB) : 5
Garry's statements hit the nail right on the head. Let me give my take on this topic which ends up as my gibbering of the week as usual... Garry wrote: >--- In xxcopy@yahoogroups.com, "ray_mccormick" >> "I have not had any problems with this and have just >> installed 2.84.4 by this process.." >> I should be more explicit and say that I have *always* >> installed Xxcopy in this way without problem. This was even a surprise that some people don't have any problem. > Ray, > > you're right that the default behaviour when double > clicking on a batch file in explorer will be to make > that directory current and the install will proceed > correctly. In that regard there's no problem with > simply clicking on install.bat. I have never been sure that Windows Explorer's behavior *IS ALWAYS* that way. I have never fully studied the behavior of Windows with this regard (basically the behavior of the command processor --- in the case of Win9X, this is Windows Explorer (more than the command processor as in the traditional DOS world). When you open up a DOS Box in XP by Start > Run... and CMD.EXE, the initial current directory will be at c:\Document and Settings\ In Win9X, Start > Run... and COMMAND.COM the initial current directory will be at C:\Windows\Desktop So, when the user runs C:\TEMP\INSTALL.BAT, we will not get the desired effect unless the CD C:\TEMP command is invoked first. On the other hand, if you run the INSTALL.BAT like Start > Run... and C:\TEMP\INSTALL.BAT Then, yes, it seems that c:\temp\ becomes the current directory before the INSTALL.BAT is invoked. ---- I just discovered an odd behavior: When you run Start > Run... and invoke TEST1.BAT in Win98SE, The c:\windows\desktop\test1.bat will be invoked even though the C:\windows\desktop\ directory is not in the declared path in the EnvVar PATH. The only explanation for this is that in Win98SE, Start > Run... sets the current directory at C:\windows\desktop before evaluating the command string that you submit. At any rate, it is best that a program should never make an assumption as to what is the "current" directory is. Garry also wrote: > However this default behaviour can and does change > depending on the user's setup. As a developer of software products for the consumption of the general public for almost 20 years, I have formed a habit of accepting the fact that everyone's environment is different. The simple fact that there are so many ways to invoke a batch file, I have never made any assumption as to what the current directory settings when a batch file is invoked. So, even from Day One when I wrote the initial version of the INSTALL.BAT, I was fully aware of the potential problem of the batch file when the batch file were run from a directory other than of its own. The question that I asked to Garry as to how to let the batch file find and set the current directory to the batch file's own directory was one of the techniques that I was always wanted an answer for. And even when I asked Garry of the technique, I was not sure that a reasonably bullet- proof technique exists for the problem. So, learning the trick Garry shared with us was a pleasant surprise. Even after you guys enlightened me that Windows Explorer sets the current directory to its own directory of the batch file being invoked, I am not ready to accept it as a universal fact. Simply, I have never come across any written document from Microsoft (nor from respected publications) that the current directory is *ALWAYS* set to the batch file's own directory. In my opinion, such an assumption is even *DEAD WRONG". A case in point: XXCopy has a "DOS escape" feature (in our "IN-HOUSE" version) which allows an execution of any arbitrary command be invoked prior to running the XXCOPY's usual command line job. The command is "/SY". If you put /SY in the XXCOPY command line, any string following the /SY switch will be treated as a fully-formed "DOS" command line: E.g., xxcopyx \src\ dst\ /sy:c:\temp\install.bat This hypothetical command will invoke the specified batch file from XXCOPYX.EXE program but prior to running the batch program, XXCOPYX does not set the initial directory to the c:\temp\ directory. XXCOPYX simply calls the Win32 API which creates a process in which the given command will be executed. Since I have not seen any Microsoft's documentation which "requires" that the current directory be adjusted to the install.bat directory, it simply did not occur to me that it is a good thing to do. But, no one can legitimately claim the it is a BUG. If this feature were to be released without making the SY command to adjust the current directory before handing over the control to the target program, we would eventually receive a "problem" report from an angry customer who lost indispensable files (by making the assumption that we are now discussing). ------------------------------------------------------- XXCOPY has a "/MD" command which unconditionally creates the specified directory prior to running anything else (originally conceived as a mechanism for allowing the log file to be written to a yet-to-be-created directory). The /SY command can be thought of as an ultimately generalized scheme to handle unforeseen circumstances from a demanding customer who insists certain things need be done from inside XXCOPY. One by-product of the /SY command is that it at least offers an interesting utility (a batch enhancer) that would allow XXCOPY's macro feature as part of a batch file which would otherwise be awkward. E.g., xxcopy /tm-10d /SY: my_program.exe /$yyyy-mm-dd$ this command invokes my_program.exe with the date of 10 days ago as its argument which may be inside a batch file (and the batch file would otherwise be quite messy if not impossible). ------------------------------------------------------- I wonder if anyone really wants the "/SY" switch to be officially incorporated in the XXCOPY program... Kan Yabumoto
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.