#203267 - 2011-10-15 07:06 PM
Windows 7 @ ProductType Kix4.61
|
Chan
Fresh Scripter
Registered: 2011-10-14
Posts: 15
Loc: Arizona
|
Hello , I am new to the Kix area, and have be faced with revamping/Creat a whole new loging script..... We currently are running ad 2003 mixed mode 2000, XP win 7.... come up to a wall where the scrip will not check OS version with the "@producttype command .. The scrip is scipping it and going to the end .. and Help would be appricated
;********************************************************************************
;* Check To See If System Is A Server *
;********************************************************************************
$aOS = "Windows XP Professional","Windows 2000 Professional","Windows NT Workstation","Windows 7 Professional Edition"
IF ASCAN ($aOS,$OS) = 0
GOTO Skip_System
EndIf
;********************************************************************************
;* Checking for Admin Rights on the PC *
;********************************************************************************
$AdminRights = "0"
IF $OS = "Windows XP Professional" AND EXIST("C:\Documents and Settings\xpadmin\ntuser.ini") = 1
$AdminRights = "1"
ENDIF
IF $OS = "Windows XP Professional" AND EXIST("C:\Documents and Settings\Administrator\ntuser.ini") = 1
$AdminRights = "1"
ENDIF
IF $OS = "Windows 2000 Professional" AND EXIST("C:\Documents and Settings\Administrator\ntuser.ini") = 1
$AdminRights = "1"
ENDIF
IF $OS = "Windows 7 Professional Edition" AND EXIST("C:\Users\Administrator\ntuser.ini") = 1
$AdminRights = "1"
ENDIF
;********************************************************************************
;* Module To Disable IE Reuse of Window When Launching Shortcut *
;********************************************************************************
$IEWindowReuse = ReadValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main","AllowWindowReuse")
IF $IEWindowReuse = "" OR $IEWindowReuse = "1"
Writevalue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main","AllowWindowReuse","0","REG_DWORD")
ELSE
ENDIF
:Skip_System
:EndSystem
Edited by Mart (2011-10-16 11:45 AM) Edit Reason: Please use code tags when posting code.
|
Top
|
|
|
|
#203271 - 2011-10-15 09:36 PM
Re: Windows 7 @ ProductType Kix4.61
[Re: ShaneEP]
|
Chan
Fresh Scripter
Registered: 2011-10-14
Posts: 15
Loc: Arizona
|
Yes the $os is set from another script that called from this one... full script OS.....O- if found i also tried it with -1 to run if missing from the array.....
-----------------Call---------------------
; ----- Call System Wide Scripts for System Wide Changes - Begin ---------
Call @ldrive + $Path + "\System.kix"
; ----- Call System Wide Scripts for System Wide Changes - End -----------
--------------------Full Script---------------------
Break On
? "Adding Adobe JS Patch"
SHELL "C:\Windows\regedit.exe -s " + @ldrive + "\adobeJS.reg"
; ------- Determine if the user is in the LoginScript_QA group - Begin ------------------------
Global $Path
$QAMessage = "You are running the QA Login Script"
If @ScriptDir = @ldrive
Goto QACheck
EndIf
If @ScriptDir = @ldrive + "qa\netlogon"
Goto RunQA
EndIf
:QACheck
If InGroup ("LoginScript_QA")
$Path = "qa\Netlogon"
Call @ldrive + "qa\netlogon\login.kix"
exit
Else
$Path = ""
Goto Production
Endif
Goto EndPTI
:RunQA
MessageBox($QAMessage, "Message from Your System Administrator......",64,5)
; ------- Determine if the user is in the LoginScript_QA group - End --------------------------
:Production
; --------------- IDENTIFY SITE ------------------
;
;
; ----- Home Script ------------------------------------------------------
; Created by: 10.10.2011
;
; -----------------------------------------------------------------------------------
Global $ipbyte1, $ipbyte2, $ipbyte3, $site, $OS
$IPMessage = "Logon scripts are not currently supported on this system or in this location. Script operation aborting. Click OK to continue."
$sHome3 = "xxx"
$OS = @PRODUCTTYPE ; Get OS for conditional scripting
; ------- Determine if the computer is a server - Begin --------------------------------------------------
$Computer_Name= LCase (LTrim (Substr(@WkSta , 1, 1)))
if $Computer_Name == "w" GOTO EXECUTE_SCRIPT
ELSE
if $Computer_Name == "n" GOTO EXECUTE_SCRIPT
ELSE
if $Computer_Name == "f" GOTO EXECUTE_SCRIPT
ELSE
if $Computer_Name == "s" GOTO Server
ELSE GOTO ScriptError
; ------- Determine if the computer is a server - End ----------------------------------------------------
:Server
; ------- Determine if the computer is a server - Begin --------------------------------------------------
if AScan ($Server, @WkSta) <> -1
Call @ldrive + $Path + "\Server\Server.kix"
GOTO EndPTI
ELSE
GoTo ScriptError
; ------- Determine if the computer is a server - End -----------------------
:EXECUTE_SCRIPT
; ----- Determine site by Domain Controller name - Begin -------------------------------------------------
$site=LCase(LTrim (substr(@LServer , 6, 3)))
$sitecheck = "xxx"
If AScan ($Sitecheck,$Site) <> -1 GOTO SKIP_IP_CHECK
ELSE ; do nothing
; ----- Determine site by Domain Controller name - End ----------------------------------------------------
; ----- Generate ipbytes - Begin --------------------------------------------------
$ipbyte1 = Val (LTrim (SubStr( @IPADDRESS0 , 1 ,3)))
If $ipbyte1 <> xxx
$ipbyte1 = Val (LTrim (SubStr( @IPADDRESS1 ,1 ,3)))
If $ipbyte1 <> xxx
$ipbyte1 = Val (LTrim (SubStr( @IPADDRESS2 ,1 ,3)))
If $ipbyte1 <> xxx
GoTo SkipIP
Else
$ipbyte2 = Val (LTrim (SubStr( @IPADDRESS2 , 5 ,3)))
$ipbyte3 = Val (LTrim (SubStr( @IPADDRESS2 , 9 ,3)))
EndIf
Else
$ipbyte2 = Val (LTrim (SubStr( @IPADDRESS1 , 5 ,3)))
$ipbyte3 = Val (LTrim (SubStr( @IPADDRESS1 , 9 ,3)))
EndIf
Else
$ipbyte2 = Val (LTrim (SubStr( @IPADDRESS0 , 5 ,3)))
$ipbyte3 = Val (LTrim (SubStr( @IPADDRESS0 , 9 ,3)))
EndIf
If $ipbyte2 <> xx
GoTo ScriptError
Else
GoTo SkipIP
; Exit script if ipbyte2 <> xx
EndIf
; ----- Generate ipbytes - End ----------------------------------------------------
:SkipIP
; ----- Check ipbyte3 for valid range and assign site - Begin ---------------------
Select
Case AScan ($axxx3, $ipbyte3) <> 0 ; Array operations
$site = "xxx"
Case 1
GoTo ScriptError
EndSelect
; ----- Check ipbyte3 for valid range and assign site - End -----------------------
:SKIP_IP_CHECK
; ----- Call System Wide Scripts for System Wide Changes - Begin ---------
Call @ldrive + $Path + "\System.kix"
; ----- Call System Wide Scripts for System Wide Changes - End -----------
; ----- Call Main.kix for the user - Begin ----------------------------------------
If InGroup("xxx-Users")
Call @ldrive + $Path + "\xxx\xxx.kix"
If @error = 4 ; Checks for forced exit of script
Else "User Is Not A Member of the xxx-User Group"
GoTo ScriptError
EndIf
Case 0
GoTo ScriptError
? "The user does not belong to a site group or belongs to more than one."
EndSelect
; ----- Call Main.kix for the user - End ------------------------------------------
; Calls the printer script based on current site
Call @ldrive + $Path + "\" + $site + "\Printers.kix"
GoTo EndPTI
:ScriptError
MessageBox($IPMessage, "Kixtart Error",16,5)
:EndPTI
Edited by Mart (2011-10-16 11:46 AM) Edit Reason: Please use code tags when posting code.
|
Top
|
|
|
|
#203276 - 2011-10-16 07:26 PM
Re: Windows 7 @ ProductType Kix4.61
[Re: Chan]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
There is quite a bit going on that I would not recommend, particularly all the GOTO usage.
But to be more specific to your problem. There are a number of IF ELSE ENDIF statements that are missing an ENDIF.
There are also some SELECT statements that are written incorrectly.
$Computer_Name= Left(@WkSta,1)
If $Computer_Name = "w" OR $Computer_Name = "n" OR $Computer_Name = "f"
GOTO EXECUTE_SCRIPT
Else
If $Computer_Name = "s"
GOTO Server
Else
GOTO ScriptError
Endif
Endif
If AScan($Server, @WkSta) <> -1
Call @ldrive + $Path + "\Server\Server.kix"
GOTO EndPTI
Else
GoTo ScriptError
Endif
$site = LTrim(substr(@LServer,6,3))
$sitecheck = "xxx"
If AScan($Sitecheck,$Site) <> -1
GOTO SKIP_IP_CHECK
Endif I'm not sure what you were trying to do in this section, there was a random Case and Endselect, so I just guessed.If InGroup("xxx-Users")
Call @ldrive + $Path + "\xxx\xxx.kix"
If @error = 4 ; Checks for forced exit of script
GoTo ScriptError
Else
? "User Is Not A Member of the xxx-User Group"
GoTo ScriptError
EndIf
Endif Also adding a simple assignment statement to function calls will eliminate the 1's and 0's displaying on the console. For example...:ScriptError
$nul = MessageBox($IPMessage, "Kixtart Error",16,5)
|
Top
|
|
|
|
#203277 - 2011-10-17 06:25 AM
Re: Windows 7 @ ProductType Kix4.61
[Re: ShaneEP]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Here is your first script without the GOTOs, and a little simplified.
;********************************************************************************
;* Check To See If System Is A Server *
;********************************************************************************
$aOS = "Windows XP Professional","Windows 2000 Professional","Windows NT Workstation","Windows 7 Professional Edition"
IF ASCAN($aOS,$OS) = -1
Exit 1
EndIf
;********************************************************************************
;* Checking for Admin Rights on the PC *
;********************************************************************************
Select
Case $OS = "Windows XP Professional" AND EXIST("C:\Documents and Settings\xpadmin\ntuser.ini")
$AdminRights = "1"
Case $OS = "Windows XP Professional" AND EXIST("C:\Documents and Settings\Administrator\ntuser.ini")
$AdminRights = "1"
Case $OS = "Windows 2000 Professional" AND EXIST("C:\Documents and Settings\Administrator\ntuser.ini")
$AdminRights = "1"
Case $OS = "Windows 7 Professional Edition" AND EXIST("C:\Users\Administrator\ntuser.ini")
$AdminRights = "1"
Case 1
$AdminRights = "0"
EndSelect
;********************************************************************************
;* Module To Disable IE Reuse of Window When Launching Shortcut *
;********************************************************************************
$IEWindowReuse = ReadValue("HKCU\SOFTWARE\Microsoft\Internet Explorer\Main","AllowWindowReuse")
IF $IEWindowReuse = "" OR $IEWindowReuse = "1"
$nul = Writevalue("HKCU\SOFTWARE\Microsoft\Internet Explorer\Main","AllowWindowReuse","0","REG_DWORD")
ENDIF And also an example of the second script you posted without using GOTOs.Break On
? "Adding Adobe JS Patch"
SHELL "C:\Windows\regedit.exe -s " + @ldrive + "\adobeJS.reg"
; ------- Determine if the user is in the LoginScript_QA group - Begin ------------------------
Global $Path
$QAMessage = "You are running the QA Login Script"
If @ScriptDir = @ldrive
If InGroup ("LoginScript_QA")
$Path = "qa\Netlogon"
Call @ldrive + "qa\netlogon\login.kix"
exit 0
Else
$Path = ""
Endif
EndIf
If @ScriptDir = @ldrive+"qa\netlogon"
$nul = MessageBox($QAMessage, "Message from Your System Administrator......",64,5)
EndIf
; ------- Determine if the user is in the LoginScript_QA group - End --------------------------
; --------------- IDENTIFY SITE ------------------
;
;
; ----- Home Script ------------------------------------------------------
; Created by: 10.10.2011
;
; -----------------------------------------------------------------------------------
Global $ipaddress,$ipbytes[3],$site,$OS
$IPMessage = "Logon scripts are not currently supported on this system or in this location. Script operation aborting. Click OK to continue."
$sHome3 = "xxx"
$OS = @PRODUCTTYPE ; Get OS for conditional scripting
; ------- Determine if the computer is a server - Begin --------------------------------------------------
$Computer_Name= Left(@WkSta,1)
If $Computer_Name <> "w" AND $Computer_Name <> "n" AND $Computer_Name <> "f"
If $Computer_Name = "s"
If AScan ($Server, @WkSta) <> -1
Call @ldrive + $Path + "\Server\Server.kix"
Exit 0
Else
$nul = MessageBox($IPMessage, "Kixtart Error",16,5)
Exit 1
Endif
ELSE
$nul = MessageBox($IPMessage, "Kixtart Error",16,5)
Exit 1
Endif
Endif
; ------- Determine if the computer is a server - End ----------------------------------------------------
; ----- Determine site by Domain Controller name or IP - Begin -------------------------------------------
$site = substr(@LServer,6,3)
$sitecheck = "xxx"
If AScan($Sitecheck,$Site) = -1
$ipaddress = Join(Split(@IPADDRESS0," "),"")
If Len($ipaddress) = 0
$ipaddress = Join(Split(@IPADDRESS1," "),"")
Endif
If Len($ipaddress) = 0
$ipaddress = Join(Split(@IPADDRESS2," "),"")
Endif
If Len($ipaddress) = 0
$ipaddress = Join(Split(@IPADDRESS3," "),"")
Endif
$ipbytes = Split($ipaddress,".")
If $ipbytes[1] <> xx
$nul = MessageBox($IPMessage, "Kixtart Error",16,5)
Exit 1
EndIf
Select
Case AScan($axxx3, $ipbytes[2]) <> 0
$site = "xxx"
Case 1
$nul = MessageBox($IPMessage, "Kixtart Error",16,5)
Exit 1
EndSelect
Endif
; ----- Determine site by Domain Controller name or IP - End --------------------------------------------
; ----- Call System Wide Scripts for System Wide Changes - Begin ---------
Call @ldrive + $Path + "\System.kix"
; ----- Call System Wide Scripts for System Wide Changes - End -----------
; ----- Call Main.kix for the user - Begin ----------------------------------------
If InGroup("xxx-Users")
Call @ldrive + $Path + "\xxx\xxx.kix"
If @error = 4 ; Checks for forced exit of script
Else
? "User Is Not A Member of the xxx-User Group"
$nul = MessageBox($IPMessage, "Kixtart Error",16,5)
Exit 1
EndIf
Endif
; ----- Call Main.kix for the user - End ------------------------------------------
; Calls the printer script based on current site
Call @ldrive + $Path + "\" + $site + "\Printers.kix"
Exit 0 Not sure if any of the changed variable would effect your other called scripts, but you can atleast look at it as an example of how to do all the tasks without using the GOTOs. I think most people on this forum would agree that the GOTO code just makes the script much more confusing to follow/edit/debug.
|
Top
|
|
|
|
#203287 - 2011-10-18 06:36 AM
Re: Windows 7 @ ProductType Kix4.61
[Re: ShaneEP]
|
Chan
Fresh Scripter
Registered: 2011-10-14
Posts: 15
Loc: Arizona
|
well yet another day , and another night.... I will try some of those sugestion you provided thank you .. But one thing i can not figure out is the "@ldrive" Wits is the local drive \\servername\netlogon. in my script i have a check to check if you a re a member of the QA group to run it from \\servername\Netlogon\QA\netlogon. With it seem like it does for i see the pope up i set to tell user that they are running the QA script...
; ------- Determine if the user is in the LoginScript_QA group - Begin ------------------------
Global $Path
$QAMessage = "You are running the QA Login Script"
If @ScriptDir = @ldrive
Goto QACheck
EndIf
If @ScriptDir = @ldrive + "qa\netlogon"
Goto RunQA
EndIf
:QACheck
If InGroup ("LoginScript_QA")
$Path = "qa\Netlogon"
Call @ldrive + "qa\netlogon\login.kix"
exit
Else
$Path = ""
Goto Production
Endif
Goto EndPTI
:RunQA
MessageBox($QAMessage, "Message from Your System Administrator......",64,5)
; ------- Determine if the user is in the LoginScript_QA group - End --------------------------
That being said it should run the whole script from the \\servername\Netlogon\QA\netlogon , and not the \\servername\netlogon. Somewhere is the mioddle it is losing it becasue it is trying to call the below it tries to pull it from \\Servnmae\netlogon
$Path = "qa\Netlogon" .......... Withc is seet as a global
; ----- Call System Wide Scripts for System Wide Changes - Begin ---------
Call @ldrive + $Path + "\xxx.kix"
; ----- Call System Wide Scripts for System Wide Changes - End ----------
Edited by Mart (2011-10-18 01:32 PM) Edit Reason: Please use code tags when posting code.
|
Top
|
|
|
|
#203290 - 2011-10-18 04:41 PM
Re: Windows 7 @ ProductType Kix4.61
[Re: Chan]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
@ScriptDir = @ldrive doesn't seem right. Im not sure that the @scriptdir has a trailing \. Try replacing that test...
|
Top
|
|
|
|
#203292 - 2011-10-20 04:57 AM
Re: Windows 7 @ ProductType Kix4.61
[Re: Jochen]
|
Chan
Fresh Scripter
Registered: 2011-10-14
Posts: 15
Loc: Arizona
|
rrrrr. Thank you for the catch thier but still having the issue.. ran it with a debug and seems it is not seeing the Correct Path $Path = "qa\Netlogon" later in the script when it calls the main Kix it returns a path that is not correct and goes to error. it is returning the bellow path
\\seervername\netlogon\\xxx\xxx.kix it should be \\seervername\netlogon\qa\netlogon\xxx\xxx.kix somewhere in here teh $path is going screwy
any one have any thoughts?
|
Top
|
|
|
|
#203294 - 2011-10-20 05:17 AM
Re: Windows 7 @ ProductType Kix4.61
[Re: ShaneEP]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Maybe something like this would work (if i understand what youre trying to do correctly)?
; ------- Determine if the user is in the LoginScript_QA group - Begin ------------------------
$Path = "qa\Netlogon"
$QAMessage = "You are running the QA Login Script"
If @ScriptDir = @ldrive + "qa\netlogon"
GOTO RunQA
EndIf
If InGroup ("LoginScript_QA")
Call @ldrive + $Path + "\login.kix"
exit 0
Else
$Path = ""
Goto Production
Endif
:RunQA
MessageBox($QAMessage, "Message from Your System Administrator......",64,5)
; ------- Determine if the user is in the LoginScript_QA group - End --------------------------
|
Top
|
|
|
|
#203295 - 2011-10-20 05:22 AM
Re: Windows 7 @ ProductType Kix4.61
[Re: ShaneEP]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Better yet, you can get rid of another GOTO by using the following instead...
; ------- Determine if the user is in the LoginScript_QA group - Begin ------------------------
$Path = "qa\Netlogon"
$QAMessage = "You are running the QA Login Script"
If @ScriptDir = @ldrive + "qa\netlogon"
$nul = MessageBox($QAMessage, "Message from Your System Administrator......",64,5)
Else
If InGroup ("LoginScript_QA")
Call @ldrive + $Path + "\login.kix"
exit 0
Else
$Path = ""
Goto Production
Endif
EndIf
; ------- Determine if the user is in the LoginScript_QA group - End --------------------------
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 515 anonymous users online.
|
|
|