Crazy Eddie
(Starting to like KiXtart)
2002-12-06 04:34 PM
Another %0 method

I've seen a lot of references to script handling XP/W2K with %0 in a different manner.

FWIW, here's my approach:

code:
   SET CurDir=%0\..
IF %0=="%~0" SET CurDir=%~0\..
IF Not %0=="%~0" SET CurDir=%0\..
CLS
"%CurDir%\KIX412\KIX32.EXE" "%CurDir%\myscript.kix"

Discussion:

%0 in W2K and XP adds "" around the value of the batch file name, preventing the normal method of using %0\..\

In XP/W2K %~0 removes the quotes. Comparisons can determine the correct result, for all OSes.

-Crazy Eddie

Edited to show quotes around KIX and script calls. (This allows spaces in the %CurDir% variable to still work.)

[ 06. December 2002, 19:17: Message edited by: Crazy Eddie ]


Sealeopard
(KiX Master)
2002-12-06 04:58 PM
Re: Another %0 method

The '%0\..\' is only necessary in login scripts for Windows 9x. Windows NT/2000/XP do not require '%0\..\' at all.

Crazy Eddie
(Starting to like KiXtart)
2002-12-06 05:07 PM
Re: Another %0 method

You might choose to have it in there, if you want to test your scripts from a non-NETLOGON location.

Also, there are many times you might call a kix script outside of login, via a batch.

This method ensures it is always called and executed the same way.

FWIW.


LonkeroAdministrator
(KiX Master Guru)
2002-12-06 05:10 PM
Re: Another %0 method

good snippet anyway.
easier to show this to newbies than try to get them change their whole batch.