Page 1 of 1 1
Topic Options
#31885 - 2002-11-07 12:14 AM Need help with script writing - I'm a total beginner....
Pilot Offline
Lurker

Registered: 2002-11-04
Posts: 2
Loc: London
Hello everyone - this is my first post, and I hope you guys can help me.

I've only been working on Kixtart on and off for two days now, and need to have a script to map users drives etc. by the end of the week. Now, here is one I tried - it maps the drives OK, but not sure of the syntax - is this correct? As I say, bear in mind I'm a total beginner with this....

OK - to begin with me are using a Windows 2000 Active Directory Network. 90% of our users are using Windows 2000 Pro on their PC's, and the remainder are Windows 98 (I've not put scripting in for 98' yet).

In the user profile settings, their logon file is Logon.bat:

@ECHO OFF

REM Kixtart batch file to call Kixlogon.kix

%0\..\KIX32.exe KIXLOGON.kix

EXIT

The Kixlogon.kix script that is called looks like this:

DEBUG ON

;LOGON SCRIPT NOV 6TH 2002

;------------------
;Set server details
;------------------

$LSERVER1 = "SERVER1"

$LSERVER2 = "SERVER2"

;----------------------------------------------
;This displays a message to the user logging on
;----------------------------------------------

SETCONSOLE ("SHOW")

MESSAGEBOX("Welcome to the Network. Please wait while drives are connected",64,8)

;-------------------------------------------------------------------------
;Checks to ensure all files are located on the clients Windows 2000 system
;-------------------------------------------------------------------------

IF NOT EXIST ("C:\WINNT\KIX32.EXE")

COPY "@SERVER2+\NETLOGON\KIX32.EXE" "c:\WINNT"
ENDIF

IF NOT EXIST ("c:\WINNT\KXRPC.EXE")

COPY "@SERVER2+\NETLOGON\KXRPC.EXE" "C:\WINNT"
ENDIF

IF NOT EXIST ("c:\WINNT\SYSTEM32\KX32.DLL")

COPY "@SERVER2+\NETLOGON\KX32.DLL" "C:\WINNT\SYSTEMS32"
ENDIF

IF NOT EXIST ("c:\WINNT\SYSTEM32\KX16.DLL")

COPY "@SERVER2+\NETLOGON\KX16.DLL" "c:\WINNT\SYSTEM32"
ENDIF

IF NOT EXIST ("c:\WINNT\SYSTEM32\KX95.DLL")

COPY "@SERVER2+\NETLOGON\KX95.DLL" "C\WINNT\SYSTEM32"
ENDIF

;-----------------------------------------------
;Test beep - if you hear this the script has run (so far!)
;-----------------------------------------------

BEEP

;IF INGROUP ("Admin")

; USE J: /DELETE

; USE J: "\\FILESERV\Administration"
;ENDIF

;IF INGROUP ("Buisiness Admin")

; USE J: /DELETE

; USE J: "\\FILESERV\Business Admin"
;ENDIF

;IF INGROUP ("ZONE1")

; USE J: /DELETE

; USE J: "\\FILESERV\Zone1"
;ENDIF

;IF INGROUP ("ZONE2")

; USE J: /DELETE

; USE J:\ "\\FILESERV\Zone2"
;ENDIF

;IF INGROUP ("ZONE3")

; USE J: /DELETE

; USE J: "\\FILESERV\Zone3"
;ENDIF

;IF INGROUP ("ZONE4")

; USE J: /DELETE

; USE J: "\\FILESERV\Zone4"
;ENDIF

;IF INGROUP ("ZONE5")

; USE J: /DELETE

; USE J: "\\FILESERV\Zone5"
;ENDIF

;---------------------------------------------------
;This deletes all currently connected drive mappings
;---------------------------------------------------

USE J: /DELETE

USE T: /DELETE

;--------------------
;This maps the drives
;--------------------

USE J: "\\FILESERV\Work"

;--------
;Test map
;--------

USE T: "\\FILESERV\Profiles"

EXIT

OK - So there is my current 'testing' script.

I have a couple of questions though:

i. How long can a share be that kixtart maps drives to? (For example, if I had: USE "\\FILESERV\Business Management Department" would it work ok?

ii. Also, the part that copies files to your local PC- is that required? I've noticed that even though it runs, no files are present on the client PC....very odd behaviour - or is it supposed to be like that?

Anyway, thanks for any time you can spare on this - it's greatly appreciated.

Many thanks

Regards

Pilot

Top
#31886 - 2002-11-07 12:31 AM Re: Need help with script writing - I'm a total beginner....
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Pilot,

welcome to our little board [Big Grin]

Just a few things :

  • Messagebox() will halt script execution until user responds to it
  • You might want to 'silence' the function calls where you don't need the return value by assigning a dummy var like $nul = function()
  • In your Copy statements replace @ with $
  • You map J: first depending on group membership only to delete afterwards an map to a common one ???
Your Questions :
share names can always mapped with KiX no matter how long they are, Rule if you can name it you can map it [Big Grin]

Second question is answered with list item 3 ...
A better startegy though would be copy if not exist within your batch file and then start the locla copy of Kixtart (Could speed the process a bit)

All for now
Hope that helps

Jochen
_________________________



Top
#31887 - 2002-11-07 12:36 AM Re: Need help with script writing - I'm a total beginner....
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You want to copy ONLY Kix32.exe to the W2K client. ALL the other files are for Win9x support. Also you want to copy the files in the batch file not the KiXtart script.

then in your batch file you want to start the script by calling the local copy of "Kix32".
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#31888 - 2002-11-07 12:38 AM Re: Need help with script writing - I'm a total beginner....
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
fully agree to Howards enhancements !
_________________________



Top
#31889 - 2002-11-06 03:49 PM Re: Need help with script writing - I'm a total beginner....
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You must copy from within the batch file because once you start the local KiXtart executable it cannot be copied over.

Please see the KiXtart Manual for a login script example or read the FAQ Forum, especially the KiXtart Starters Guide.

[ 06. November 2002, 17:44: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#31890 - 2002-11-06 04:54 PM Re: Need help with script writing - I'm a total beginner....
masken Offline
MM club member
*****

Registered: 2000-11-27
Posts: 1222
Loc: Gothenburg, Sweden
The reason for kix32.exe not being copied might be that the clients are normal domain users. These do not have write permissions in the C:\WINNT folder. A solution to this is to put kix32.exe directly on c:\ instead.

And as mentioned, you cannot copy/overwrite the kix32 executable while it's running, this has to be done in the batchfile, before kix is started.

The reason why many choose to copy the kix32.exe file locally to each pc is that it will increase script execution speed, since it doesn't have to pull the executable off from the logonserver each time a client logs on [Smile]
_________________________
The tart is out there

Top
#31891 - 2002-11-06 05:10 PM Re: Need help with script writing - I'm a total beginner....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
As Howard mentioned, the DLLs are only for Wintendo. I notice as well you copy the KXRPC. That is only for the domain controllers, not the clients.

I log copy failures and then pick them up from the log and copy them through the c:$ (remotely).
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#31892 - 2002-11-06 05:13 PM Re: Need help with script writing - I'm a total beginner....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
BTW, you can copy from within KiX provided you are not using the same file you are trying to copy. Setup a 'seed' area and copy them from there.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#31893 - 2002-11-08 11:34 AM Re: Need help with script writing - I'm a total beginner....
Pilot Offline
Lurker

Registered: 2002-11-04
Posts: 2
Loc: London
Hi guys,

OK, I've not been able to spend as much time on scripting as I would have liked, but here is the latest attempt. I've followed your advice as best I can (and hope I've done it correctly....)

Anyway, here is the initial login.bat file that the users activates when logging on:

@Echo Off

IF "%OS%" == "Windows_NT" GOTO WinNT

c:\windows\command\XCOPY %0\..\KIX32.EXE %WINDIR%\SYSTEM\ /D /H /I /R /V > NUL
c:\windows\command\XCOPY %0\..\KX16.DLL %WINDIR%\SYSTEM\ /D /H /I /R /V > NUL
c:\windows\command\XCOPY %0\..\KX32.DLL %WINDIR%\SYSTEM\ /D /H /I /R /V >NUL
c:\windows\command\XCOPY %0\..\KX95.DLL %WINDIR%\SYSTEM\ /D /H /I /R /V > NUL

%WINDIR%\SYSTEM\KIX32.EXE %0\..\kixlogon.kix

GOTO End

:WinNT

XCOPY %0\..\KIX32.EXE %WINDIR%\SYSTEM32\ /D /H /I /R /V >NUL

%WINDIR%\SYSTEM32\KIX32.EXE %0\..\kixlogon.kix

GOTO End

End

Now, this copies the KIX32.EXE folder to the client PC OK on Windows 2000, however I haven't tested it on Win98 yet (I actually got this script from the starter manual - cheers).

OK - this is the kixtart script that is called:

;------------------------------
;Test script as of 7th Nov 2002
;------------------------------

Debug ON

Break ON

;------------------
;Set server details
;------------------

$lserver1 = "SERVER1"

$lserver2 = "SERVER2"

SetConsole ("show")
;EndIf

;-------------------------------------------------------
;Test beep - if you hear this the script has run so far!
;-------------------------------------------------------

If Exist "J:" /delete

EndIf

If Exist "L:" /delete

EndIf

If Exist "M:" /delete

EndIf

If InGroup ("Admin")

Use J: "\\IHQFS01\Admin"
EndIf

If InGroup ("Business")

Use J: "\\FILESERV\Business"
EndIf

If InGroup ("Zone1")

Use J: "\\FILESERV\Zone1"
EndIf

If InGroup ("Zone2")

Use J: "\\FILESERV\Zone2"
EndIf

If InGroup ("Zone3")

Use J: "\\FILESERV\Zone3"
EndIf

If InGroup ("Zone4")

Use J: "\\FILESERV\Zone4"
EndIf

If InGroup ("Zone5")

Use J: "\\FILESERV\Zone5"
EndIf

If InGroup ("Zone6")

Use J: "\\FILESERV\Zone6"
AddPrinterConnection ("\\FILESERV\Color2")
; SetDefaultPrinter ("\\IFILESERV\Color1")
EndIf

;--------------------------------------------------------------------
;This maps individuals to the root of the Zone directory if required
;--------------------------------------------------------------------

If InGroup ("All Zone")

Use L: "\\FILESERV\All Zone"
EndIf

;-----------------------------------------------------------
;This maps users to the root of the Work drive if required
;-----------------------------------------------------------

If InGroup ("Work Root")

Use M: "\\FILESERV\Work"
EndIf

So, does that look better? - It does map users to their correct drives. However, I have another question: Here, we have an agreement to always use the J: drive for users work/departmental directory. But, if I add a user to two or more groups (bearing in mind they are always mapped to J:), is it possible for the script to automatically map to the next drive letter if they become members of additional groups? (I hope that makes sense - it didn't when I was typing it...)

So, if a user is a member of Zone1 for example and had a mapping of: J: \\FILESERV\Zone1, when they get put into Zone3, could it automatically move to L: ? (we use K: as their home drives).

I hope that makes sense - but being Friday my brain is slowing down!

One last thing - the script is only set for Windows 2000 so far, as I said I haven't added the Windows 98 part yet.

Thanks

Cheers guys,

Pilot

Top
#31894 - 2002-11-08 02:55 PM Re: Need help with script writing - I'm a total beginner....
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
In the logon.bat you copy files every time instead of first checking IF EXIST.

Also, on some OSs you may need to stuff a Y to XCOPY.

ECHO Y|XCOPY %0\..\KIX32.EXE %WINDIR%\SYSTEM32\ /D /H /I /R /V >NUL
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#31895 - 2002-11-08 03:10 PM Re: Need help with script writing - I'm a total beginner....
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Actually, the copy will only work if the user ahs permissions to copy into the %WINDIR% directory. Since most user do not have the required admin permissions, it'll fail. Thent he script call will fail, too since the executable is not present. For correct login scripts, see for example Mixed Win9x, W2K, WinXP Workstations

code:
If Exist "M:" /delete

EndIf

This is total garbage, please see the KiXtart Manual for correct syntax. Correct syntax would be
code:
IF EXIST('M:\nul')
USE M: /delete /persistent
ENDIF

See also File Operations

Please read the KiXtart Manual and the FAQ Forum.
_________________________
There are two types of vessels, submarines and targets.

Top
#31896 - 2002-12-08 02:53 PM Re: Need help with script writing - I'm a total beginner....
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Very important is it to keep your kixtart client installation separate
from script. A wrong way of calling your script may hang it by a share
violation error.

To make a client installation easy you can use one of our iexpress packages,
which you can find on our site.

F.e. we are using following script for all windows versions.
code:
@echo off
if not exist %windir%\kix412.ok %0\..\kix412update.exe /q
if exist %windir%kix32.exe %windir%\kix32.exe %0\..\your_script.kix
if not exist %windir%kix32.exe %0%\..\kix32.exe %0\..\your_script.kix
@echo off

The iexpress installation package kix412update.exe can be found on our site.

For more information about it see topic KIX-TOOL: fast check of local
installed KiXtart files for users of "kix???update.exe"

greetings.

btw: symbol  - on our homepage has been linked to related http://kixtart.org topic.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1013 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

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

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