essexboy80
asked on
Kix Script Help
Hi,
I am using Kix Scripts to do my logins and map my drives and I am assigned them if user are in a group.
But I want to assign multiple drives to each group, how can I do this?
The code I am using to map a drive a present is here :
;;Map the Executive Drive
? " Checking 'J Drive' group membership."
If InGroup("JDrive")
? " Applying 'J Drive' group membership."
$ScriptLog=$ScriptLog + @CRLF + " In J drive group" + @CRLF
If Exist ( "J:" )
Use J: /d
If @Error=0
$ScriptLog=$ScriptLog + " Disconnected J drive OK" + @CRLF
Else
$ScriptLog=$ScriptLog + " Couldn't disconnect J drive" + @CRLF
EndIf
EndIf
Use J: $FileServer + "\Executive"
If @Error=0
$ScriptLog=$ScriptLog + " Connected J drive OK" + @CRLF
Else
$ScriptLog=$ScriptLog + " Couldn't connect J drive" + @CRLF
EndIf
Else
? " Not in group."
$ScriptLog=$ScriptLog + @CRLF + " Not in J drive group" + @CRLF
EndIf
I am using Kix Scripts to do my logins and map my drives and I am assigned them if user are in a group.
But I want to assign multiple drives to each group, how can I do this?
The code I am using to map a drive a present is here :
;;Map the Executive Drive
? " Checking 'J Drive' group membership."
If InGroup("JDrive")
? " Applying 'J Drive' group membership."
$ScriptLog=$ScriptLog + @CRLF + " In J drive group" + @CRLF
If Exist ( "J:" )
Use J: /d
If @Error=0
$ScriptLog=$ScriptLog + " Disconnected J drive OK" + @CRLF
Else
$ScriptLog=$ScriptLog + " Couldn't disconnect J drive" + @CRLF
EndIf
EndIf
Use J: $FileServer + "\Executive"
If @Error=0
$ScriptLog=$ScriptLog + " Connected J drive OK" + @CRLF
Else
$ScriptLog=$ScriptLog + " Couldn't connect J drive" + @CRLF
EndIf
Else
? " Not in group."
$ScriptLog=$ScriptLog + @CRLF + " Not in J drive group" + @CRLF
EndIf
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi to add printers it is the same process.
;========================= ========== ========== ========== ========== ========== ====
; Script for assigning printers to DOMAIN-GROUP.
;========================= ========== ========== ========== ========== ========== ====
If InGroup("DOMAIN-GROUP")
If AddPrinterConnection ("\\printerserver\HP3600") = 0
? "Added printer connection...."
If SetDefaultPrinter ("\\printerserver\HP3600") = 0
? "Set default printer to \\printerserver\HP3600"
Endif
EndIf
EndIf
So you setup is fine.
If the PERL script works properly, why rebuild the wheel at the moment? With that said, if you have time, you could use the WshShortCut option to achieve the same results possibly.
ex : WshShortCut("%userprofile% \desktop\m y notepad.lnk","c:\winnt\sys tem32\note pad.exe")
Are you using an script.ini file with your script.kix?
-Hades666
;=========================
; Script for assigning printers to DOMAIN-GROUP.
;=========================
If InGroup("DOMAIN-GROUP")
If AddPrinterConnection ("\\printerserver\HP3600")
? "Added printer connection...."
If SetDefaultPrinter ("\\printerserver\HP3600")
? "Set default printer to \\printerserver\HP3600"
Endif
EndIf
EndIf
So you setup is fine.
If the PERL script works properly, why rebuild the wheel at the moment? With that said, if you have time, you could use the WshShortCut option to achieve the same results possibly.
ex : WshShortCut("%userprofile%
Are you using an script.ini file with your script.kix?
-Hades666
ASKER
Hi,
Thanks I will give that a go, quick question though.
If you want to assign multiple printers to a group would you do it as follows :
If InGroup("DOMAIN-GROUP")
If AddPrinterConnection ("\\printerserver\HP3600") = 0
? "Added printer connection...."
If AddPrinterConnection ("\\printerserver\HP4600") = 0
? "Added printer connection...."
If AddPrinterConnection ("\\printerserver\HP5600") = 0
? "Added printer connection...."
If SetDefaultPrinter ("\\printerserver\HP4600") = 0
? "Set default printer to \\printerserver\HP4600"
Endif
EndIf
EndIf
What does the = 0 signify?
The PERL script works but at the moment I have a SET PERL = at the top of my batch file, how would I do this in kix?
No .ini file, should I be?
Thanks again
Paul
Thanks I will give that a go, quick question though.
If you want to assign multiple printers to a group would you do it as follows :
If InGroup("DOMAIN-GROUP")
If AddPrinterConnection ("\\printerserver\HP3600")
? "Added printer connection...."
If AddPrinterConnection ("\\printerserver\HP4600")
? "Added printer connection...."
If AddPrinterConnection ("\\printerserver\HP5600")
? "Added printer connection...."
If SetDefaultPrinter ("\\printerserver\HP4600")
? "Set default printer to \\printerserver\HP4600"
Endif
EndIf
EndIf
What does the = 0 signify?
The PERL script works but at the moment I have a SET PERL = at the top of my batch file, how would I do this in kix?
No .ini file, should I be?
Thanks again
Paul
Yes.
The =0 signifies "IF PRINT IS NOT PRESENT"
Have you read the KIX Manual? The Kixtart.ini contains sections [YOUR GROUPS], which can include an entry for each domain or workgroup that is to be enabled for use of KiXtart. you can use this for printers, servernames everything. Think of it as a variable page.
http://www.kixtart.org/manual/
In KIX you can't do that, you would either make a VBS script to do it or BATCH.
Does this work for you?
Hades666
The =0 signifies "IF PRINT IS NOT PRESENT"
Have you read the KIX Manual? The Kixtart.ini contains sections [YOUR GROUPS], which can include an entry for each domain or workgroup that is to be enabled for use of KiXtart. you can use this for printers, servernames everything. Think of it as a variable page.
http://www.kixtart.org/manual/
In KIX you can't do that, you would either make a VBS script to do it or BATCH.
Does this work for you?
Hades666
ASKER
Hi,
This is one of my printer bits, it only maps the first printer and not the rest
If InGroup("12UGS-3rd")
If AddPrinterConnection ("\\Philby\OKI_B6300_1")
? "Added printer connection...."
If AddPrinterConnection ("\\Philby\fl3cl")
? "Added printer connection...."
If AddPrinterConnection ("\\Philby\3rdFloorSAV")
? "Added printer connection...."
If AddPrinterConnection ("\\Philby\CanonC5045")
? "Added printer connection...."
If AddPrinterConnection ("\\Philby\CanonC5045PS")
? "Added printer connection...."
If SetDefaultPrinter ("\\Philby\3rd Floor Large")
? "Set default printer to \\Philby\3rd Floor Large"
Endif
EndIf
EndIf
Endif
EndIf
EndIf
EndIf
Thanks
Paul
This is one of my printer bits, it only maps the first printer and not the rest
If InGroup("12UGS-3rd")
If AddPrinterConnection ("\\Philby\OKI_B6300_1")
? "Added printer connection...."
If AddPrinterConnection ("\\Philby\fl3cl")
? "Added printer connection...."
If AddPrinterConnection ("\\Philby\3rdFloorSAV")
? "Added printer connection...."
If AddPrinterConnection ("\\Philby\CanonC5045")
? "Added printer connection...."
If AddPrinterConnection ("\\Philby\CanonC5045PS")
? "Added printer connection...."
If SetDefaultPrinter ("\\Philby\3rd Floor Large")
? "Set default printer to \\Philby\3rd Floor Large"
Endif
EndIf
EndIf
Endif
EndIf
EndIf
EndIf
Thanks
Paul
ASKER
Hi,
Okay I have sorted the printers out now.
Anotehr question, it seems when you add a user to a group for the first time even if you re-run the login script they don't get the group until they reboot.
WHy is this?
Paul
Okay I have sorted the printers out now.
Anotehr question, it seems when you add a user to a group for the first time even if you re-run the login script they don't get the group until they reboot.
WHy is this?
Paul
When adding a user to a new group, the user must log out and log back in for it to take affect. While a reboot will accomplish that, it should not be required.
This is normal for windows as the user identity is cached when logged in.
Hades666
This is normal for windows as the user identity is cached when logged in.
Hades666
ASKER
thanks all, got it working now.
Paul
Paul
ASKER
perfect
ASKER
Thanks for your assistance I agree that maybe I had things over complicated.
I would appreciate your help with a few more points if possible please.
Basically I am writing this KIX Script to replace an existing Batch file that runs commands and calls a lot of PERL.
For Example I have this line in my current login script which calls a PERL script that changes peoples start menus (i have attached the content of the shortcut.pl)
echo Setting up the shortcuts...
%PERL% %ROOT%\bin\shortcuts.pl
Is there a better way for me to be doing this sort of thing?
Also printers, what is the best way to do them via KIX, currently I was going to do it like this :
;....
;.... Add new printers based on user group
;....
? " Checking to see If you need printer 'HP 3600'."
If InGroup("HP3600")
? " Adding printer 'HP 3600'."
$ScriptLog=$ScriptLog + @CRLF + " In HP 3600 Printer group" + @CRLF
If AddPrinterConnection ( $PrintServer + "\HP3600" ) = 0
? " Added printer OK!"
Else
? " There was a problem adding this printer"
EndIf
Else
? " You dont need this printer."
$ScriptLog=$ScriptLog + @CRLF + " Not in HP 3600 Printer group" + @CRLF
EndIf
? " ."
? ""
;....
;.... Set default printers based on user group
;....
? " Looking to set your default printer."
If InGroup("HP3600-Default")
? " Setting default printer to 'HP 3600'."
$ScriptLog=$ScriptLog + @CRLF + " In HP 3600 Default Printer group" + @CRLF
If SetDefaultPrinter ( $PrintServer + "\HP Color LaserJet 3600" ) = 0
? " Set default printer OK!"
EndIf
EndIf
Thanks for all your help and I am sure I will have more questions.
Thanks
Paul
Open in new window