Page 1 of 1 1
Topic Options
#96800 - 2002-12-06 04:34 PM Another %0 method
Crazy Eddie Offline
Starting to like KiXtart

Registered: 2002-11-20
Posts: 105
Loc: Sacramento, CA USA
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 ]
_________________________
{Insert your favorite Witty Tag Line here}

Top
#96801 - 2002-12-06 04:58 PM Re: Another %0 method
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
The '%0\..\' is only necessary in login scripts for Windows 9x. Windows NT/2000/XP do not require '%0\..\' at all.
_________________________
There are two types of vessels, submarines and targets.

Top
#96802 - 2002-12-06 05:07 PM Re: Another %0 method
Crazy Eddie Offline
Starting to like KiXtart

Registered: 2002-11-20
Posts: 105
Loc: Sacramento, CA USA
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.
_________________________
{Insert your favorite Witty Tag Line here}

Top
#96803 - 2002-12-06 05:10 PM Re: Another %0 method
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
good snippet anyway.
easier to show this to newbies than try to get them change their whole batch.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 700 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.055 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org