#194017 - 2009-05-27 02:51 PM
login script calling bat leaves bat open
|
wa1ed
Just in Town
Registered: 2006-09-20
Posts: 1
|
Hi, I have a loign script I cobbled together that checks to see if the PC had logged in already today, and if notcalls an external batch file to unzip some data. It works well except the external batch leaves an unclosable dos window open on the desktop. I am going to paste both scripts, can someone please help? Thanks Ed login script
$VER = ReadValue("HKEY_CURRENT_USER\Software\RapidApp", "Version")
If $VER = 1.4
Goto ALWAYS
Else
Goto RUNONCE
EndIf
:RUNONCE
AddKey("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate") >NULL
AddKey("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU") >NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "NoAutoUpdate", "00000001", "REG_DWORD") > NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "AUOptions", "00000000", "REG_DWORD") > NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "ScheduledInstallDay", "00000000", "REG_DWORD") > NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "ScheduledInstallTime", "00000019", "REG_DWORD")> NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "NoAutoRebootWithLoggedOnUsers", "00000001", "REG_DWORD")> NULL
; Write the version info into the registry.
AddKey("HKEY_CURRENT_USER\Software\RapidApp")> NULL
WriteValue("HKEY_CURRENT_USER\Software\RapidApp", "Version", "1.4", "REG_SZ")> NULL
:ALWAYS
AddKey("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate") > NULL
AddKey("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU") > NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "NoAutoUpdate", "00000001", "REG_DWORD")> NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "AUOptions", "00000000", "REG_DWORD")> NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "ScheduledInstallDay", "00000000", "REG_DWORD")> NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "ScheduledInstallTime", "00000019", "REG_DWORD")> NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "NoAutoRebootWithLoggedOnUsers", "00000001", "REG_DWORD")> NULL
$TRUE = 1
$FALSE = 0
If $Debug=1
$DebugFlag = 0
Else
$DebugFlag = 0
EndIf
$DebugLevel = "Info" ; Info, Debug, Error
$AdminEmail = "ed@santasvillage.com" ; Where to send all of the warning messages
$MailServer = "192.168.0.1"
$Lserver = @LServer
;$LServer = "santa4"
$LoggingLocation="\\santa4\log$\"
$FileLocation="\\santa4\netlogon\"
;$FileLocation=@LDRIVE + "\new"
;$FileLocation="."
;Break Off
Break On
;Default Settings
$os=""
$os_type=""
$os_service_pack=""
$progressstep=4
$sleeptime=0
$numerrors=0
Global $time
Global $UpdateSoftware[0]
$Updates=0
$RunUpdates=$False
$tmpdir=ExpandEnvironmentVars("%tmp%")
$systemdrive=ExpandEnvironmentVars("%systemdrive%")
$windir=ExpandEnvironmentVars("%windir%")
$comspec=ExpandEnvironmentVars("%comspec%")
$CentralSoftwareIniFile=$FileLocation + "\Software.ini"
$LocalSoftwareIniFile=$windir + "\InstalledSoftware.ini"
$GeneralSourceLocation=ReadProfileString($CentralSoftwareIniFile, "Packages", "GeneralSourceLocation")
If Exist($systemdrive + "/program files/utils/kixtart")
$KixDir=$systemdrive + "/program files/utils/kixtart"
Else
$KixDir=@LDrive
$KixDir="."
EndIf
Global $DebugMessages[0]
$NumMessages=0
$DebugMessages[$NumMessages]="-BEGIN--------------------------"
;Main Application
; Draw Form
DrawForms()
; Get OperatingSystemInformation
OperatingSystem()
$OSBox.Text=SubStr($os,1,22)
; Show News
ShowNews()
; Syncing Time
SyncTime()
; Connecting Drives
ConnectDrives()
If FirstLogonToday()=$True And InGroup("POS")
; Check Software Versions
SetTime "\\santa4"
Run "%comspec% /c j:\SYN\UOFFDAT2.BAT C:\syn datafils"
;Run "j:\SYN\UOFFDAT2.BAT C:\syn datafils"
; IF INGROUP("cash") RUN "J:\SYN\UOFFDAT.BAT C:\syn datafils"
; Update Software
;enter something here
Else
;$CheckSoftwareRadioButton.Value=0
;$CheckSoftwareRadioButton.Enabled =0
;$InstallSoftwareRadioButton.Value=0
;$InstallSoftwareRadioButton.Enabled =0
;$AntiVirusRadioButton.Value=0
;$AntiVirusRadioButton.Enabled =0
EndIf
; Set machine to stanard Settings
StandardSettings()
; Write Log File
WriteLogFile()
; Fill Progressbar
While $ProgressBar.Value < 100
Progress("Finalizing",20)
Loop
Exit
Quit
;***********************************************************************
;**
;** Update the clock
;**
Function UpdateClock()
If @Time<>$time
$Clock.Text=@Time
$time=@time
EndIf
EndFunction
;***********************************************************************
;**
;** Retrieve News File
;**
Function ShowNews()
$NewsRadioButton.Value=1
Progress( "Retrieving News")
If Open(1, $FileLocation + "\News.txt") = 0
$NewsLine = ReadLine(1)
While @ERROR=0
$NewsTextBox.Text=$NewsTextBox.Text + $NewsLine + Chr(13) + Chr(10)
$NewsLine = ReadLine(1)
Loop
If Close (1) <> 0
DbgMessage("Error","News File could not be closed", @SError)
EndIf
Else
DbgMessage("Debug","No News")
EndIf
$NewsRadioButton.Value=0
$NewsRadioButton.Enabled =0
EndFunction
;***********************************************************************
;**
;** Syncronize the local system time with the logon server. The PDC
;** server santa4 syncronizes with NTP server
;**
Function SyncTime()
$TimeRadioButton.Value=1
DBGMessage ("Info", "Syncing Time:" )
Progress( "Syncing Time")
If $NT_Mode="yes"
SetTime "\\" + $Lserver
If @ERROR<>0
DBGMessage ("Error", " - Error Finding Time Server : " + $Lserver )
Else
DbgMessage("Info"," - Synchronized time with : " + $Lserver)
EndIf
EndIf
$TimeRadioButton.Value=0
$TimeRadioButton.Enabled =0
EndFunction
;***********************************************************************
;**
;** First time Logon.kix runs today
;**
Function FirstLogonToday()
Progress( "Checking If FirstLogon today")
DbgMessage("Info", "Checking If FirstLogon today")
;DbgMessage("Info", $FileDate)
$FirstLogonToday=$False
If Exist($LoggingLocation + "\" + @Wksta + ".log")
$FileDate=Left(GetFileTime ($LoggingLocation + "\" + @Wksta + ".log"),10)
If $FileDate<>@Date
$FirstLogonToday=$True
EndIf
Else
$FirstLogonToday=$True
EndIf
EndFunction
;***********************************************************************
;**
;** Connect Shares to Drives
;**
Function ConnectDrives()
Use * /delete
$SharesRadioButton.Value=1
Progress( "Connecting Drives")
DbgMessage("Info", "Connecting Drives:")
Use * /delete
; ConnectHomeDrive()
ConnectDefaultDrives()
ConnectGroupDrives()
ConnectGroupDrives1()
ConnectGroupDrives2()
ConnectGroupDrives3()
;COnnectGroupDrives2()
$SharesRadioButton.Value=0
$SharesRadioButton.Enabled =0
EndFunction
;***********************************************************************
;**
;** Connect DefaultShares to Drives
;**
Function ConnectDefaultDrives()
If InGroup("STAFF")
;Maps specified share to a drive letter
If Exist("J" + ":")
Use "J" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " J " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "J" + ":" "\\santa4\apps"
If @ERROR <> 0
? "Error @ERROR Mapping " J " to "\\santa4\apps " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Maps specified share to a drive letter
If Exist("k" + ":")
Use "k" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " k " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "k" + ":" "\\santa4\trainers"
If @ERROR <> 0
? "Error @ERROR Mapping " k " to "\\santa4\users " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Maps specified share to a drive letter
If Exist("t" + ":")
Use "t" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " t " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "t" + ":" "\\timeclock\time"
If @ERROR <> 0
? "Error @ERROR Mapping " t " to "\\timeclock\time " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
EndIf
EndFunction
;***********************************************************************
;**
;** Connect GroupShares to Drives
;**
Function ConnectGroupDrives()
If InGroup("POS")
;Maps specified share to a drive letter
If Exist("J" + ":")
Use "J" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " J " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "J" + ":" "\\santa4\apps"
If @ERROR <> 0
? "Error @ERROR Mapping " J " to "\\santa4\apps " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Maps specified share to a drive letter
If Exist("t" + ":")
Use "t" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " t " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "t" + ":" "\\timeclock\time"
If @ERROR <> 0
? "Error @ERROR Mapping " t " to "\\timeclock\time " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
EndIf
EndFunction
Function ConnectGroupDrives1()
If InGroup("TRAINERS")
;Maps specified share to a drive letter
If Exist("k" + ":")
Use "k" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " k " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "k" + ":" "\\santa4\trainers"
If @ERROR <> 0
? "Error @ERROR Mapping " k " to "\\santa4\trainers " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Maps specified share to a drive letter
If Exist("t" + ":")
Use "t" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " t " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "t" + ":" "\\timeclock\time"
If @ERROR <> 0
? "Error @ERROR Mapping " t " to "\\timeclock\time " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
EndIf
EndFunction
Function ConnectGroupDrives2()
If InGroup("REAL")
;Maps specified share to a drive letter
If Exist("J" + ":")
Use "J" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " J " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "J" + ":" "\\santa4\apps"
If @ERROR <> 0
? "Error @ERROR Mapping " J " to "\\santa4\apps " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Maps specified share to a drive letter
If Exist("k" + ":")
Use "k" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " k " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "k" + ":" "\\santa4\users"
If @ERROR <> 0
? "Error @ERROR Mapping " k " to "\\santa4\users " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Maps specified share to a drive letter
If Exist("t" + ":")
Use "t" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " t " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "t" + ":" "\\timeclock\time"
If @ERROR <> 0
? "Error @ERROR Mapping " t " to "\\timeclock\time " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Use m: "\\tkt1\c"
;Use n: "\\tkt2\c"
;Use o: "\\tkt3\c"
;Use l: "\\tkt4\c"
EndIf
EndFunction
Function ConnectGroupDrives3()
If InGroup("PAYROLL")
;Maps specified share to a drive letter
If Exist("J" + ":")
Use "J" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " J " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "J" + ":" "\\santa4\apps"
If @ERROR <> 0
? "Error @ERROR Mapping " J " to "\\santa4\apps " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Maps specified share to a drive letter
If Exist("k" + ":")
Use "k" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " k " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "k" + ":" "\\santa4\users"
If @ERROR <> 0
? "Error @ERROR Mapping " k " to "\\santa4\users " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Maps specified share to a drive letter
If Exist("t" + ":")
Use "t" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " t " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "t" + ":" "\\timeclock\time"
If @ERROR <> 0
? "Error @ERROR Mapping " t " to "\\timeclock\time " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Maps specified share to a drive letter
If Exist("l" + ":")
Use "l" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " l " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "l" + ":" "\\tkt4\c"
If @ERROR <> 0
? "Error @ERROR Mapping " l " to "\\tkt4\c " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Maps specified share to a drive letter
If Exist("o" + ":")
Use "o" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " o " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "o" + ":" "\\tkt3\c"
If @ERROR <> 0
? "Error @ERROR Mapping " o " to "\\tkt3\c " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Maps specified share to a drive letter
If Exist("n" + ":")
Use "n" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " n " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "n" + ":" "\\tkt2\c"
If @ERROR <> 0
? "Error @ERROR Mapping " n " to "\\tkt2\c " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Maps specified share to a drive letter
If Exist("m" + ":")
Use "m" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " m " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "m" + ":" "\\tkt1\c"
If @ERROR <> 0
? "Error @ERROR Mapping " m " to "\\tkt1\c " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
;Maps specified share to a drive letter
If Exist("q" + ":")
Use "q" + ":" /DEL
If @ERROR <> 0
? "Error @ERROR Removing Drive Mapping for " q " (@SERROR)"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use "q" + ":" "\\exit2\c"
If @ERROR <> 0
? "Error @ERROR Mapping " q " to "\\exit2\c " (@SERROR)"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
EndIf
EndFunction
;************************************************************************
;**
;** Set machine to default settings
;**
Function StandardSettings()
$StandardSettingsRadioButton.Value=1
Progress( "Setting Standard Settings")
DbgMessage("Info","Setting standard settings:")
; ScreenSaver
; Auto Logoff MfgPro Gui Client
$StandardSettingsRadioButton.Value=0
$StandardSettingsRadioButton.Enabled=0
EndFunction
;************************************************************************
;**
;** Used to send email to the NT Administrator defined in $AdminEmail.
;** Attaches a copy of the local $DebugFile to the message so we can see
;** if there's a history of problems on the machine.
;**
;** Interprets the user's email address from their logon name. Both
;** logon names as well as email addresses are based on the employee's
;** insurance (employee) number.
;**
Function SendAdminMail()
If Len(DebugMessages)>1
Progress( "Sending Debug Report")
$UserEmail = @USERID + "@@" + $MailServer
; REM Run "POSTIE.exe -host:$MailServer -to:$AdminEmail -from:$UserEmail -s:Logon_Script_Error_on_@WKSTA -msg:" + Chr(34) + "$DebugMessages"
EndIf
EndFunction
;************************************************************
;** Function: ConnectShare
;** Usage: ConnectShare ("H:, \\server\LOG_Procurement$, Logistics Procurement")
;**
Function ConnectShare( $DriveDefinition)
$DriveLetter=SubStr($DriveDefinition,1,InStr($DriveDefinition,",")-1)
$DriveDefinition=LTrim(RTrim(SubStr($DriveDefinition,InStr($DriveDefinition,",")+1)))
$Share=LTrim(RTrim(SubStr($DriveDefinition,1,InStr($DriveDefinition,",")-1)))
$ShareDesc=LTrim(RTrim(SubStr($DriveDefinition,InStr($DriveDefinition,",")+1)))
DbgMessage("Info"," - Disconnecting " + $DriveLetter + " on " + $Share)
; Use $DriveLetter /delete
; If @ERROR <> 0
; DBGMessage ( "DisMountError", $DriveLetter)
; EndIf
If ($NT_mode = "no")
DelKey("HKEY_CURRENT_USER\Network\Persistent\" + $DriveLetter)
EndIf
Progress( "Connecting " + $DriveLetter + " to " + $Share)
DbgMessage("Info"," - Connecting " + $DriveLetter + " on " + $Share)
Use $DriveLetter $Share
If @ERROR <> 0
DBGMessage ( "MountError", $DriveLetter + " on " + $Share )
EndIf
EndFunction
;***********************************************************************
;**
;** Update Progress Bar
;**
Function Progress($ProgressText,optional $Step)
If $Step=""
$Step=$progressstep
EndIf
$ProgressTextBox.Text=$ProgressText
If $ProgressBar.Value + $Step < 101
$ProgressBar.Value=$ProgressBar.Value+$Step
If $DebugFlag = $TRUE
Sleep $sleeptime
EndIf
Else
$ProgressBar.Value=100
EndIf
$=Execute($Form.DoEvents())
EndFunction
;************************************************************
;** Function: DBGMessage
;** Usage: DBGMessage( "Debug", "This is a debug Message" )
;** DebugType : Info, Debug, Error
;**
Function DBGMessage($DebugType, $DebugMessage, Optional $SError)
Select
Case $DebugLevel="Error"
If $DebugType="Info" Or $DebugType="Debug"
Return
EndIf
Case $DebugLevel="Info"
If $DebugType="Debug"
Return
EndIf
EndSelect
If $DebugType="Error"
$numerrors=$numerrors+1
EndIf
$NumMessages=$NumMessages + 1
ReDim Preserve $DebugMessages[$NumMessages]
$DebugTime="" + @Date + " - " + @Time +" >"
$DebugText=$DebugType + " : " + $DebugMessage
If $SError<>""
$DebugText=$DebugText + " | Additional Info: @SERROR"
EndIf
$DebugMessages[$NumMessages]=$DebugTime + $DebugText
If $DebugFlag = $TRUE
$DbgTextBox.Text=$DbgTextBox.Text + $DebugText + @CRLF
Sleep $sleeptime
EndIf
EndFunction
;************************************************************
;** Function: WriteLogfile
;** Usage: WriteLogFIle()
;**
Function WriteLogFile()
; Display DebugMessage
$WriteLogFileRadioButton.Value=1
Progress( "Writing Logfile")
$LogFile=$LoggingLocation + "\" + @Wksta + ".log"
If Exist($LogFile)
If GetFileSize($LogFile) > 1024 * 1024
Del($LogFile)
EndIf
EndIf
$NumMessages=$NumMessages + 1
ReDim PRESERVE $DebugMessages[$NumMessages]
$DebugMessages[$NumMessages]="-END----------------------------"
If Open(1, $LogFile,5) = 0
For $x=0 to $NumMessages
If WriteLine(1, $DebugMessages[$x] + @CRLF)<>0
DbgMessage("Error","DebugLine could not be written")
EndIf
Next
If Close(1)<>0
DbgMessage("Error","Log File could not be closed")
EndIf
Else
DbgMessage("Debug","Log file could not be written")
EndIf
$WriteLogFileRadioButton.Value=0
$WriteLogFileRadioButton.Enabled =0
EndFunction
;***********************************************************************
;**
;** calculates OS version with service pack
;**
Function OperatingSystem()
DbgMessage("Info","Checking Operating System")
Progress("Checking Operating System")
If (@inwin = 1)
$NT_mode="yes"
Else
$NT_mode="no"
EndIf
$os=""
$os_dos=@dos
$os_product=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType")
$os_productSuite=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductSuite")
$os_service_pack=""
$os_subversion=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","SubVersionNumber")
Select
Case ($NT_mode = "yes") And ($os_product <> "WinNT") And ($os_dos = "5.1") And (InStr($os_productSuite,"Terminal Server") <> 0)
$os="XP_Terminal_Server"
Case ($NT_mode = "yes") And ($os_product <> "WinNT") And ($os_dos = "5.1") ; - Windows XP Server
$os="XP_Server"
Case ($NT_mode = "yes") And ($os_product = "WinNT") And ($os_dos = "5.1") ; - Windows XP Professional
$os="XP_Professional"
Case ($NT_mode = "yes") And ($os_product <> "WinNT") And ($os_dos = "5.0") And (InStr($os_productSuite,"Terminal Server") <> 0)
$os="W2K_Terminal_Server"
Case ($NT_mode = "yes") And ($os_product <> "WinNT") And ($os_dos = "5.0") ; - Windows 2000 -
$os="W2K_Server"
Case ($NT_mode = "yes") And ($os_product = "WinNT") And ($os_dos = "5.0")
$os="W2K_Professional"
Case ($NT_mode = "yes") And ($os_product = "LANMANNT") ; - Windows NT -
$os="NT4_Domain_Controller"
Case ($NT_mode = "yes") And ($os_product = "ServerNT") And (InStr($os_productSuite,"Terminal Server") <> 0)
$os="NT4_Terminal_Server"
Case ($NT_mode = "yes") And ($os_product = "ServerNT")
$os="NT4_Member_Server"
Case ($NT_mode = "yes") And ($os_product = "WinNT")
$os="NT4"
Case ($NT_mode <> "yes") And (@dos = "4.90")
$os="ME"
Case ($NT_mode <> "yes") And ($os_dos = "4.10") And (InStr(LCase($os_subversion),"c") <> 0) ; - Windows 98 -
$os="W98c"
Case ($NT_mode <> "yes") And ($os_dos = "4.10") And (InStr(LCase($os_subversion),"b") <> 0)
$os="W98b"
Case ($NT_mode <> "yes") And ($os_dos = "4.10") And (InStr(LCase($os_subversion),"a") <> 0)
$os="W98a"
Case ($NT_mode <> "yes") And ($os_dos = "4.10")
$os="W98"
Case ($NT_mode <> "yes") And ($os_dos = "4.0") And (InStr(LCase($os_subversion),"c") <> 0) ; - Windows 95 -
$os="W95c"
Case ($NT_mode <> "yes") And ($os_dos = "4.0") And (InStr(LCase($os_subversion),"b") <> 0)
$os="W95b"
Case ($NT_mode <> "yes") And ($os_dos = "4.0") And (InStr(LCase($os_subversion),"a") <> 0)
$os="W95a"
Case ($NT_mode <> "yes") And ($os_dos = "4.0")
$os="W95"
Case 1
$os="???" ; - undetermined -
EndSelect
;
$os_service_pack=""
Select
Case ($NT_mode = "yes") And ($os_dos = "5.1") ; - Windows XP
$os_service_pack=ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion","BuildLab")
If (Len($os_service_pack) <> 0)
$os=SubStr($os,1,3)+"_"+LTrim(RTrim($os_service_pack))
$os_service_pack=LTrim(RTrim($os_service_pack))
EndIf
Case ($NT_mode = "yes") And ($os_dos <> "5.1") ; Windows NT4 + W2K
$os_service_pack=ReadValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion","CSDVersion")
If (Len($os_service_pack) <> 0)
$os=SubStr($os,1,3)+"_"+SubStr($os_service_pack,Len($os_service_pack),1)
$os_service_pack=LTrim(RTrim($os_service_pack))
EndIf
Case 1
; Windows 95, 98 + ME
EndSelect
;
$os_type=""
$os_dos=@dos
Select
Case ($NT_mode = "yes") And ($os_dos = "5.1") ; - Windows XP -
$os_type="XP"
Case ($NT_mode = "yes") And ($os_dos = "5.0") ; - Windows 2000 -
$os_type="W2K"
Case ($NT_mode = "yes") ; - Windows NT -
$os_type="NT4"
Case ($NT_mode <> "yes") And ($os_dos = "4.90") ; - Windows ME -
$os_type="ME"
Case ($NT_mode <> "yes") And ($os_dos = "4.10") ; - Windows 98 -
$os_type="W98"
Case ($NT_mode <> "yes") And ($os_dos = "4.0") ; - Windows 95 -
$os_type="W95"
Case 1
$os_type="???" ; - undetermined -
EndSelect
$os_type=LTrim(RTrim(SubStr($os_type+" ",1,3)))
EndFunction
;***********************************************************************
;**
;** DrawForms()
;**
Function DrawForms()
; Form
$Form = CreateObject("Kixtart.Form")
$Form.Caption = "Santas Login Script"
$Form.Width = 500
$Form.Height = 320
$Form.BackColor = "DarkGreen"
$Form.ForeColor = "Red"
If $DebugFlag = $True
$Form.Left = (1024 /2) - (500 /2)
$Form.Top = (768 /2) - (400 /2)
Else
$Form.Center
EndIf
; ClockTimer
$Timer = $Form.Timer(600, 0, 0, 15, 15)
$Timer.OnTimer = "UpdateClock()"
; Logo
$Logo = $Form.PictureBox
$Logo.Left = 5
$Logo.Top = 5
$Logo.Width = 483
$Logo.Height = 50
$Logo.Picture = "logo.bmp"
; Info Frame
$InfoFrame = $Form.Frame("Information", 5, 55, 240, 100)
$OSLbl = $InfoFrame.Label("Os", 5, 15, 115, 15)
$OSBox = $InfoFrame.TextBox("", 120, 15, 115, 15)
$OSBox.BackColor = $Form.BackColor
$OSBox.ForeColor = $Form.ForeColor
$OSBox.Enabled = 0
$UserIdLbl = $InfoFrame.Label("UserId", 5, 30, 115, 15)
$UserIdBox = $InfoFrame.TextBox(@USERID, 120, 30, 115, 15)
$UserIdBox.BackColor = $Form.BackColor
$UserIdBox.Enabled = 0
$UserIdBox.ForeColor = "Red"
;$FullNameLbl = $InfoFrame.Label("Full Name", 5, 45, 115, 15)
;$FullNameBox = $InfoFrame.TextBox(@FULLNAME, 120, 45, 115, 15)
;$FullNameBox.BackColor=$Form.BackColor
;$FullNameBox.Enabled=0
;$PriviledgeLbl = $InfoFrame.Label("Priviledge", 5, 60, 115, 15)
;$PriviledgeBox = $InfoFrame.TextBox(@WKSTA, 120, 60, 115, 15)
;$PriviledgeBox.BackColor=$Form.BackColor
;$PriviledgeBox.Enabled=0
$WorkStnLbl = $InfoFrame.Label("Workstation", 5, 45, 115, 15)
$WorkStnBox = $InfoFrame.TextBox(@WKSTA, 120, 45, 115, 15)
$WorkStnBox.BackColor = $Form.BackColor
$WorkStnBox.Enabled = 0
$DomainLbl = $InfoFrame.Label("Domain", 5, 60, 115, 15)
$DomainBox = $InfoFrame.TextBox(@DOMAIN, 120, 60, 115, 15)
$DomainBox.BackColor = $Form.BackColor
$DomainBox.Enabled = 0
$ServerLbl = $InfoFrame.Label("Server", 5, 75, 115, 15)
$ServerBox = $InfoFrame.TextBox($LSERVER, 120, 75, 115, 15)
$ServerBox.BackColor = $Form.BackColor
$ServerBox.Enabled = 0
;$MemberLbl = $InfoFrame.Label("Group Member", 5, 120, 115, 15)
;$MemberBox = $InfoFrame.TextBox(@group, 120, 120, 115, 15)
;$MemberBox.BackColor=$Form.BackColor
;$MemberBox.Enabled=0
; Action Frame
$ActionFrame = $Form.Frame("Actions", 250, 55, 240, 100)
$NewsRadioButton = $ActionFrame.RadioButton("Get News", 5, 15, 230, 15)
$TimeRadioButton = $ActionFrame.RadioButton("Set Time", 5, 30, 230, 15)
$SharesRadioButton = $ActionFrame.RadioButton("Connect Drives", 5, 45, 230, 15)
;$CheckSoftwareRadioButton = $ActionFrame.RadioButton("Check Software Versions", 5, 60, 230, 15)
;$InstallSoftwareRadioButton = $ActionFrame.RadioButton("Install Software", 25, 75, 230, 15)
;$AntiVirusRadioButton = $ActionFrame.RadioButton("Update Antivirus", 5, 90, 230, 15)
$StandardSettingsRadioButton = $ActionFrame.RadioButton("Standard Settings", 5, 60, 230, 15)
$WriteLogFileRadioButton = $ActionFrame.RadioButton("Write Logfile", 5, 75, 230, 15)
; Logging Frame
$NewsFrame = $Form.Frame("News", 5, 155, 485, 110)
$NewsTextBox = $NewsFrame.TextBox("", 5, 15, 475, 90)
$NewsTextBox.BackColor = $Form.BackColor
$NewsTextBox.MultiLine = 1
$NewsTextBox.Enable = 0
$NewsTextBox.Text = ""
$NewsTextBox.ForeColor = 0, 225, 0
$NewsTextBox.ScrollBars = 2
$NewsTextBox.Wordwrap = 1
; Progress Bar
$ProgressTextBox = $Form.TextBox
$ProgressTextBox.Left = 5
$ProgressTextBox.Top = 270
$ProgressTextBox.Width = 200
$ProgressTextBox.Height = 20
$ProgressTextBox.Enable = 0
$ProgressTextBox.BackColor = $Form.BackColor
$ProgressBar = $Form.ProgressBar
$ProgressBar.Left = 210
$ProgressBar.Top = 270
$ProgressBar.Width = 220
$ProgressBar.Height = 20
$ProgressBar.Style = 1
; Clock
$CurrentTime = @Time
$Clock = $Form.TextBox("", 435, 270, 55, 20)
$Clock.Alignment = 2
$Clock.Enabled = 0
$Clock.BackColor = $Form.BackColor
$Form.Show
; DebugForm
If $DebugFlag = $True
$DbgForm = CreateObject("Kixtart.Form")
$DbgForm.Caption = "DebugBox"
$DbgForm.Width = 260
$DbgForm.Height = 500
$DbgForm.Left = 1024 - 260
$DbgFOrm.Top = 768 - 550
$DbgTextBox = $DbgForm.TextBox()
$DbgTextBox.Left = 5
$DbgTextBox.Top = 5
$DbgTextBox.Width = 245
$DbgTextBox.Height = 465
$DbgTextBox.MultiLine = 1
$DbgTextBox.Enable = 0
$DbgTextBox.Text = ""
$DbgTextBox.ScrollBars = 2
$DbgTextBox.Wordwrap = 1
$CurrentX = 0
$CurrentY = 0
$DbgForm.Show
EndIf
EndFunction
Exit
BATCH FILE uoffdat2.bat
@echo off
If not Exist j:\syn\datafils\OFFDAT.ZIP Goto nozip
rem If /"%3"==/"OFFUPD" Goto BEGIN
Goto BEGIN
chkdrive c:\syn
If errorlevel 1 Goto baddrive
If Exist OFFEMPU.RSP echo Empty user selections will also be unzipped
If Exist OFFDATU.RSP echo User selections will also be unzipped
echo.
If not Exist c:\syn\*.* MD %1
:BEGIN
If not Exist c:\syn\datafils\*.* MD c:\syn\datafils
If not Exist c:\syn\datafils\reports\*.* MD c:\syn\datafils\reports
If not Exist c:\syn\datafils\EXPORT\*.* MD c:\syn\datafils\EXPORT
@j:\syn\SCHDATE "Log entry created %%x at %%X" > templog.log
@echo UOFFDAT.BAT - Begin unzip offline data for Company datafils >> templog.log
@echo Path is set to c:\syn >> templog.log
j:\syn\pkzipc -Extract -directories -overwrite -times=all j:\syn\OFFEMP.ZIP c:\syn\datafils @j:\syn\OFFEMP.RSP
If Exist j:\syn\OFFEMPU.RSP pkzipc -Extract -directories -overwrite -times=all j:\syn\OFFEMPU.ZIP c:\syn\datafils @j:\syn\OFFEMPU.RSP
If Exist j:\syn\OFFEMPU.RSP echo Empty user selections were also unzipped >> templog.log
j:\syn\pkzipc -Extract -directories -overwrite -times=all j:\syn\datafils\OFFDAT.ZIP c:\syn\datafils @j:\syn\OFFDAT.RSP
If Exist j:\syn\OFFDATU.RSP j:\syn\pkzipc -Extract -directories -overwrite -times=all j:\syn\datafils\OFFDATU.ZIP c:\syn\datafils @j:\syn\OFFDATU.RSP
If Exist j:\syn\OFFDATU.RSP echo User selections were also unzipped >> templog.log
Copy j:\syn\OFFEMP.ZIP c:\syn
If Exist j:\syn\uoffdatu.bat Call j:\syn\uoffdatu %1 %2 %3 %4 %5 %6 %7 %8 %9
Exit
Goto end
:nodest
echo.
echo You must specify a destination location and company ID
echo e.g. UOFFDAT C:\SYN DATAFILS
echo.
Goto end
:nocomp
echo.
echo You must specify a company ID to process
echo e.g. UOFFDAT %1 DATAFILS
echo.
Goto end
:nozip
echo.
echo The file %2\OFFDAT.ZIP does not exist
echo You must run ZOFFDAT to create it
echo.
Goto end
:baddrive
echo.
echo %1 is not a local fixed disk drive
echo.
Goto end
:end
Exit
Edited by Benny69 (2009-05-27 04:42 PM) Edit Reason: Added Code Tags
|
Top
|
|
|
|
#194020 - 2009-05-27 04:43 PM
Re: login script calling bat leaves bat open
[Re: wa1ed]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
Hi wa1ed and Welcome to the board.
When you post code please place that code in code tags, here is a link that will help you with that, The Post/Reply Formatting Box and How to use it
|
Top
|
|
|
|
#194021 - 2009-05-27 05:10 PM
Re: login script calling bat leaves bat open
[Re: wa1ed]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
I don't have time to dive completely into your code, so maybe others can chime in, I think a good place to start is to clean up some of your code logic:
lets start with the first few opening lines, you have:
$VER = ReadValue("HKEY_CURRENT_USER\Software\RapidApp", "Version")
If $VER = 1.4
Goto ALWAYS
Else
Goto RUNONCE
EndIf
:RUNONCE
AddKey("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate") >NULL
AddKey("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU") >NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "NoAutoUpdate", "00000001", "REG_DWORD") > NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "AUOptions", "00000000", "REG_DWORD") > NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "ScheduledInstallDay", "00000000", "REG_DWORD") > NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "ScheduledInstallTime", "00000019", "REG_DWORD")> NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "NoAutoRebootWithLoggedOnUsers", "00000001", "REG_DWORD")> NULL
; Write the version info into the registry.
AddKey("HKEY_CURRENT_USER\Software\RapidApp")> NULL
WriteValue("HKEY_CURRENT_USER\Software\RapidApp", "Version", "1.4", "REG_SZ")> NULL
:ALWAYS
AddKey("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate") > NULL
AddKey("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU") > NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "NoAutoUpdate", "00000001", "REG_DWORD")> NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "AUOptions", "00000000", "REG_DWORD")> NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "ScheduledInstallDay", "00000000", "REG_DWORD")> NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "ScheduledInstallTime", "00000019", "REG_DWORD")> NULL
WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU", "NoAutoRebootWithLoggedOnUsers", "00000001", "REG_DWORD")> NULL
you have some double coding happening here, and it is always bad to use the Goto or GoSub commands. I think we can say that you want to add some of these keys in both situations so lets just isolate what is spacific and simplify this code a bit.
$VER = ReadValue("HKEY_CURRENT_USER\Software\RapidApp", "Version")
If Not($VER = "1.4") ;RUNONCE
; Write the version info into the registry.
$nul = WriteValue("HKEY_CURRENT_USER\Software\RapidApp", "Version", "1.4", "REG_SZ")
EndIf
$Key = "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"
$nul = WriteValue($Key, "NoAutoUpdate", "00000001", "REG_DWORD")
$nul = WriteValue($Key, "AUOptions", "00000000", "REG_DWORD")
$nul = WriteValue($Key, "ScheduledInstallDay", "00000000", "REG_DWORD")
$nul = WriteValue($Key, "ScheduledInstallTime", "00000019", "REG_DWORD")
$nul = WriteValue($Key, "NoAutoRebootWithLoggedOnUsers", "00000001", "REG_DWORD")
I have also removed your AddKey() becasue the WriteValue() will add the the key if it does not exist. I have also added the "$nul = " to the front of each WriteValue() because it returns with a code and this will silence it on the command window, no more zeros and wondering what they are from.
|
Top
|
|
|
|
#194039 - 2009-05-28 01:06 PM
Re: login script calling bat leaves bat open
[Re: NTDOC]
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
I had'nt noticed the "> NULL", I bet Doc is right, I think that is a Dos thing. I have modified my post to reflect that change.
|
Top
|
|
|
|
#194042 - 2009-05-28 06:48 PM
Re: login script calling bat leaves bat open
[Re: Benny69]
|
Kdyer
KiX Supporter
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Did some more clean up on this script and was able to come up with the following. It still appears to need more work.
CLS
Break ON
;Break Off
;Break On ; -- MOVED THESE TO THE TOP OF THE FILE AS YOU MAY WANT TO DO DEBUGGING
If ReadValue("HKCU\Software\RapidApp", "Version") <> 1.4
$rc = AddKey("HKCU\Software\RapidApp") > NULL
$rc = WriteValue("HKCU\Software\RapidApp", "Version", "1.4", "REG_SZ") > NULL
EndIf
; -- These values appear to be settable in GPO
$Wup = "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"
$rc = AddKey($wup)
$rc = AddKey($wup + "\AU")
$rc = WriteValue($wup + "\AU", "NoAutoUpdate", 1, "REG_DWORD")
$rc = WriteValue($wup + "\AU", "AUOptions", 0, "REG_DWORD")
$rc = WriteValue($wup + "\AU", "ScheduledInstallDay", 0, "REG_DWORD")
$rc = WriteValue($wup + "\AU", "ScheduledInstallTime", 19, "REG_DWORD")
$rc = WriteValue($wup + "\AU", "NoAutoRebootWithLoggedOnUsers", 1, "REG_DWORD")
$TRUE = 1
$FALSE = 0
If $Debug = 1
$DebugFlag = 0
Else
$DebugFlag = 0
EndIf
$DebugLevel = "Info" ; Info, Debug, Error
$AdminEmail = "ed@santasvillage.com" ; Where to send all of the warning messages
$MailServer = "192.168.0.1"
$Lserver = @LServer
;$LServer = "santa4"
$LoggingLocation = "\\santa4\log$\" ;--Are all of your users Domain Admins, if so this poor practice
$FileLocation = "\\santa4\netlogon\" ; -- Do you have only one DC?
;$FileLocation=@LDRIVE + "\new"
;$FileLocation="."
;Default Settings
$os = ""
$os_type = ""
$os_service_pack = ""
$progressstep = 4
$sleeptime = 0
$numerrors = 0
Global $time
Global $UpdateSoftware[0]
$Updates = 0
$RunUpdates = $False
$tmpdir = ExpandEnvironmentVars("%tmp%")
$systemdrive = ExpandEnvironmentVars("%systemdrive%")
$windir = ExpandEnvironmentVars("%windir%")
$comspec = ExpandEnvironmentVars("%comspec%")
$CentralSoftwareIniFile = $FileLocation + "\Software.ini"
$LocalSoftwareIniFile = $windir + "\InstalledSoftware.ini"
$GeneralSourceLocation = ReadProfileString($CentralSoftwareIniFile, "Packages", "GeneralSourceLocation")
If Exist($systemdrive + "/program files/utils/kixtart") ; -- Are you running *NIX? It should be "\"
$KixDir = $systemdrive + "/program files/utils/kixtart"
Else
$KixDir = @LDrive
$KixDir = "."
EndIf
Global $DebugMessages[0]
$NumMessages = 0
$DebugMessages[$NumMessages] = "-BEGIN--------------------------"
;Main Application
; Draw Form
DrawForms()
; Get OperatingSystemInformation
OperatingSystem()
$OSBox.Text = SubStr($os, 1, 22)
; Show News
ShowNews()
; Syncing Time
SyncTime()
; Connecting Drives
ConnectDrives()
If FirstLogonToday() = $True And InGroup("POS")
; Check Software Versions
SetTime "\\santa4" ; -- Is this necessary? Most systems W2k and up have W32time inbuild
Run "%comspec% /c j:\SYN\UOFFDAT2.BAT C:\syn datafils"
EndIf
; Set machine to stanard Settings
StandardSettings()
; Write Log File
WriteLogFile()
; Fill Progressbar
While $ProgressBar.Value < 100
Progress("Finalizing", 20)
Loop
Exit
Quit
;***********************************************************************
;**
;** Update the clock
;**
Function UpdateClock()
If @Time <> $time
$Clock.Text = @Time
$time = @time
EndIf
EndFunction
;***********************************************************************
;**
;** Retrieve News File
;**
Function ShowNews()
$NewsRadioButton.Value = 1
Progress("Retrieving News")
If Open(1, $FileLocation + "\News.txt") = 0
$NewsLine = ReadLine(1)
While @ERROR = 0
$NewsTextBox.Text = $NewsTextBox.Text + $NewsLine + Chr(13) + Chr(10)
$NewsLine = ReadLine(1)
Loop
If Close(1) <> 0
DbgMessage("Error", "News File could not be closed", @SError)
EndIf
Else
DbgMessage("Debug", "No News")
EndIf
$NewsRadioButton.Value = 0
$NewsRadioButton.Enabled = 0
EndFunction
;***********************************************************************
;**
;** Syncronize the local system time with the logon server. The PDC
;** server santa4 syncronizes with NTP server
;**
Function SyncTime()
$TimeRadioButton.Value = 1
DBGMessage("Info", "Syncing Time:")
Progress("Syncing Time")
If $NT_Mode = "yes"
SetTime "\\" + $Lserver
If @ERROR <> 0
DBGMessage("Error", " - Error Finding Time Server : " + $Lserver)
Else
DbgMessage("Info", " - Synchronized time with : " + $Lserver)
EndIf
EndIf
$TimeRadioButton.Value = 0
$TimeRadioButton.Enabled = 0
EndFunction
;***********************************************************************
;**
;** First time Logon.kix runs today
;**
Function FirstLogonToday()
Progress("Checking If FirstLogon today")
DbgMessage("Info", "Checking If FirstLogon today")
;DbgMessage("Info", $FileDate)
$FirstLogonToday = $False
If Exist($LoggingLocation + "\" + @Wksta + ".log")
$FileDate = Left(GetFileTime($LoggingLocation + "\" + @Wksta + ".log"), 10)
If $FileDate <> @Date
$FirstLogonToday = $True
EndIf
Else
$FirstLogonToday = $True
EndIf
EndFunction
;***********************************************************************
;**
;** Connect Shares to Drives
;**
Function ConnectDrives()
Use * /delete
$SharesRadioButton.Value = 1
Progress("Connecting Drives")
DbgMessage("Info", "Connecting Drives:")
Use * /delete
ConnectDefaultDrives()
$SharesRadioButton.Value = 0
$SharesRadioButton.Enabled = 0
EndFunction
;***********************************************************************
;**
;** Connect DefaultShares to Drives
;**
Function ConnectDefaultDrives()
;-- Common Drives for everyone
drvmap("T", "\\timeclock\time")
If InGroup("STAFF")
drvmap("J", "\\santa4\apps")
drvmap("K", "\\santa4\trainers")
EndIf
If InGroup("POS")
drvmap("J", "\\santa4\apps")
EndIf
If InGroup("TRAINERS")
drvmap("K", "\\santa4\trainers")
EndIf
If InGroup("REAL")
drvmap("J", "\\santa4\apps")
drvmap("K", "\\santa4\users")
EndIf
If InGroup("PAYROLL")
drvmap("J", "\\santa4\apps")
drvmap("K", "\\santa4\users")
drvmap("L", "\\tkt4\c")
drvmap("O", "\\tkt3\c")
drvmap("N", "\\tkt2\c")
drvmap("M", "\\tkt1\c")
drvmap("Q", "\\exit2\c")
EndIf
EndFunction
Function drvmap($drv, $resource)
;Maps specified share to a drive letter
If Exist($drv + ":\.")
Use $drv + ":" /DEL
If @ERROR <> 0
? "Error " + @ERROR + " Removing Drive Mapping for " + $drv + " (" + @SERROR + ")"
$Mapadrive = "Could not remove existing drive letter"
EndIf
EndIf
Use $drv + ":" $resource
If @ERROR <> 0
? "Error " + @ERROR + " Mapping " + $drv + " to " + $resource + " (" + @SERROR + ")"
$Mapadrive = "Could not create new mapping"
Else
$Mapadrive = "Drive map successful"
EndIf
EndFunction
;************************************************************************
;**
;** Set machine to default settings
;**
Function StandardSettings()
$StandardSettingsRadioButton.Value = 1
Progress("Setting Standard Settings")
DbgMessage("Info", "Setting standard settings:")
; ScreenSaver
; Auto Logoff MfgPro Gui Client
$StandardSettingsRadioButton.Value = 0
$StandardSettingsRadioButton.Enabled = 0
EndFunction
;************************************************************************
;**
;** Used to send email to the NT Administrator defined in $AdminEmail.
;** Attaches a copy of the local $DebugFile to the message so we can see
;** if there's a history of problems on the machine.
;**
;** Interprets the user's email address from their logon name. Both
;** logon names as well as email addresses are based on the employee's
;** insurance (employee) number.
;**
Function SendAdminMail()
If Len(DebugMessages) > 1
Progress("Sending Debug Report")
$UserEmail = @USERID + "@@" + $MailServer
; REM Run "POSTIE.exe -host:$MailServer -to:$AdminEmail -from:$UserEmail -s:Logon_Script_Error_on_@WKSTA -msg:" + Chr(34) + "$DebugMessages"
EndIf
EndFunction
;************************************************************
;** Function: ConnectShare
;** Usage: ConnectShare ("H:, \\server\LOG_Procurement$, Logistics Procurement")
;**
Function ConnectShare($DriveDefinition)
$DriveLetter = SubStr($DriveDefinition, 1, InStr($DriveDefinition, ",") - 1)
$DriveDefinition = LTrim(RTrim(SubStr($DriveDefinition, InStr($DriveDefinition, ",") + 1)))
$Share = LTrim(RTrim(SubStr($DriveDefinition, 1, InStr($DriveDefinition, ",") - 1)))
$ShareDesc = LTrim(RTrim(SubStr($DriveDefinition, InStr($DriveDefinition, ",") + 1)))
DbgMessage("Info", " - Disconnecting " + $DriveLetter + " on " + $Share)
; Use $DriveLetter /delete
; If @ERROR <> 0
; DBGMessage ( "DisMountError", $DriveLetter)
; EndIf
If ($NT_mode = "no")
DelKey("HKCU\Network\Persistent\" + $DriveLetter)
EndIf
Progress("Connecting " + $DriveLetter + " to " + $Share)
DbgMessage("Info", " - Connecting " + $DriveLetter + " on " + $Share)
Use $DriveLetter $Share
If @ERROR <> 0
DBGMessage("MountError", $DriveLetter + " on " + $Share)
EndIf
EndFunction
;***********************************************************************
;**
;** Update Progress Bar
;**
Function Progress($ProgressText, optional $Step)
If $Step = ""
$Step = $progressstep
EndIf
$ProgressTextBox.Text = $ProgressText
If $ProgressBar.Value + $Step < 101
$ProgressBar.Value = $ProgressBar.Value + $Step
If $DebugFlag = $TRUE
Sleep $sleeptime
EndIf
Else
$ProgressBar.Value = 100
EndIf
$ = Execute($Form.DoEvents())
EndFunction
;************************************************************
;** Function: DBGMessage
;** Usage: DBGMessage( "Debug", "This is a debug Message" )
;** DebugType : Info, Debug, Error
;**
Function DBGMessage($DebugType, $DebugMessage, Optional $SError)
Select
Case $DebugLevel = "Error"
If $DebugType = "Info" Or $DebugType = "Debug"
Return
EndIf
Case $DebugLevel = "Info"
If $DebugType = "Debug"
Return
EndIf
EndSelect
If $DebugType = "Error"
$numerrors = $numerrors + 1
EndIf
$NumMessages = $NumMessages + 1
ReDim Preserve $DebugMessages[$NumMessages]
$DebugTime = "" + @Date + " - " + @Time + " >"
$DebugText = $DebugType + " : " + $DebugMessage
If $SError <> ""
$DebugText = $DebugText + " | Additional Info: @SERROR"
EndIf
$DebugMessages[$NumMessages] = $DebugTime + $DebugText
If $DebugFlag = $TRUE
$DbgTextBox.Text = $DbgTextBox.Text + $DebugText + @CRLF
Sleep $sleeptime
EndIf
EndFunction
;************************************************************
;** Function: WriteLogfile
;** Usage: WriteLogFIle()
;**
Function WriteLogFile()
; Display DebugMessage
$WriteLogFileRadioButton.Value = 1
Progress("Writing Logfile")
$LogFile = $LoggingLocation + "\" + @Wksta + ".log"
If Exist($LogFile)
If GetFileSize($LogFile) > 1024 * 1024
Del($LogFile)
EndIf
EndIf
$NumMessages = $NumMessages + 1
ReDim PRESERVE $DebugMessages[$NumMessages]
$DebugMessages[$NumMessages] = "-END----------------------------"
If Open(1, $LogFile, 5) = 0
For $x = 0 to $NumMessages
If WriteLine(1, $DebugMessages[$x] + @CRLF) <> 0
DbgMessage("Error", "DebugLine could not be written")
EndIf
Next
If Close(1) <> 0
DbgMessage("Error", "Log File could not be closed")
EndIf
Else
DbgMessage("Debug", "Log file could not be written")
EndIf
$WriteLogFileRadioButton.Value = 0
$WriteLogFileRadioButton.Enabled = 0
EndFunction
;***********************************************************************
;**
;** calculates OS version with service pack
;**
Function OperatingSystem()
DbgMessage("Info", "Checking Operating System")
Progress("Checking Operating System")
If (@inwin = 1)
$NT_mode = "yes"
Else
$NT_mode = "no"
EndIf
$os = ""
$os_dos = @dos
$os_product = ReadValue("HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions", "ProductType")
$os_productSuite = ReadValue("HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions", "ProductSuite")
$os_service_pack = ""
$os_subversion = ReadValue("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion", "SubVersionNumber")
Select
Case InStr(@PRODUCTTYPE, "XP") And (@productSuite=16)
$os = "XP_Terminal_Server"
; -- There is no such thing as an XP Server
;Case ($NT_mode = "yes") And InStr(@PRODUCTTYPE, "XP") And (@dos = "5.1") ; - Windows XP Server
; $os = "XP_Server"
Case InStr(@PRODUCTTYPE, "XP") And (@dos = "5.1") ; - Windows XP Professional
$os = "XP_Professional"
Case InStr(@PRODUCTTYPE, "2000") And (@productSuite=16)
$os = "W2K_Terminal_Server"
Case InStr(@PRODUCTTYPE, "2000") ; - Windows 2000 -
$os = "W2K_Server"
Case ($NT_mode = "yes") And ( $os_product = "WinNT" ) And (@dos = "5.0")
$os = "W2K_Professional"
Case ($NT_mode = "yes") And InStr(@PRODUCTTYPE, "NT Domain") ; - Windows NT -
$os = "NT4_Domain_Controller"
Case InStr(@PRODUCTTYPE, "NT Server") And (@productSuite=16 )
$os = "NT4_Terminal_Server"
Case InStr(@PRODUCTTYPE, "NT Server")
$os = "NT4_Member_Server"
Case InStr(@PRODUCTTYPE, "NT Workstation")
$os = "NT4"
Case ($NT_mode <> "yes") And ( @dos = "4.90" )
$os = "ME"
Case ($NT_mode <> "yes") And ( $os_dos = "4.10" ) And ( InStr(LCase($os_subversion), "c") <> 0 ) ; - Windows 98 -
$os = "W98c"
Case ($NT_mode <> "yes") And ( $os_dos = "4.10" ) And ( InStr(LCase($os_subversion), "b") <> 0 )
$os = "W98b"
Case ($NT_mode <> "yes") And ( $os_dos = "4.10" ) And ( InStr(LCase($os_subversion), "a") <> 0 )
$os = "W98a"
Case ($NT_mode <> "yes") And ( $os_dos = "4.10" )
$os = "W98"
Case ($NT_mode <> "yes") And ( $os_dos = "4.0" ) And ( InStr(LCase($os_subversion), "c") <> 0 ) ; - Windows 95 -
$os = "W95c"
Case ($NT_mode <> "yes") And ( $os_dos = "4.0" ) And ( InStr(LCase($os_subversion), "b") <> 0 )
$os = "W95b"
Case ($NT_mode <> "yes") And ( $os_dos = "4.0" ) And ( InStr(LCase($os_subversion), "a") <> 0 )
$os = "W95a"
Case ($NT_mode <> "yes") And ( $os_dos = "4.0" )
$os = "W95"
Case 1
$os = "???" ; - undetermined -
EndSelect
$os_service_pack = ""
Select
Case ($NT_mode = "yes") And ( $os_dos = "5.1" ) ; - Windows XP
$os_service_pack = ReadValue("HKLM\Software\Microsoft\Windows NT\CurrentVersion", "BuildLab")
If (Len($os_service_pack) <> 0)
$os = SubStr($os, 1, 3) + "_" + LTrim(RTrim($os_service_pack))
$os_service_pack = LTrim(RTrim($os_service_pack))
EndIf
Case ($NT_mode = "yes") And ( $os_dos <> "5.1" ) ; Windows NT4 + W2K
$os_service_pack = ReadValue("HKLM\Software\Microsoft\Windows NT\CurrentVersion", "CSDVersion")
If (Len($os_service_pack) <> 0)
$os = SubStr($os, 1, 3) + "_" + SubStr($os_service_pack, Len($os_service_pack), 1)
$os_service_pack = LTrim(RTrim($os_service_pack))
EndIf
Case 1
; Windows 95, 98 + ME
EndSelect
;
$os_type = ""
$os_dos = @dos
Select
Case ($NT_mode = "yes") And ( $os_dos = "5.1" ) ; - Windows XP -
$os_type = "XP"
Case ($NT_mode = "yes") And ( $os_dos = "5.0" ) ; - Windows 2000 -
$os_type = "W2K"
Case ($NT_mode = "yes") ; - Windows NT -
$os_type = "NT4"
Case ($NT_mode <> "yes") And ( $os_dos = "4.90" ) ; - Windows ME -
$os_type = "ME"
Case ($NT_mode <> "yes") And ( $os_dos = "4.10" ) ; - Windows 98 -
$os_type = "W98"
Case ($NT_mode <> "yes") And ( $os_dos = "4.0" ) ; - Windows 95 -
$os_type = "W95"
Case 1
$os_type = "???" ; - undetermined -
EndSelect
$os_type = LTrim(RTrim(SubStr($os_type + " ", 1, 3)))
EndFunction
;***********************************************************************
;**
;** DrawForms()
;**
Function DrawForms()
; Form
$Form = CreateObject("Kixtart.Form")
$Form.Caption = "Santas Login Script"
$Form.Width = 500
$Form.Height = 320
$Form.BackColor = "DarkGreen"
$Form.ForeColor = "Red"
If $DebugFlag = $True
$Form.Left = (1024 /2) - (500 /2)
$Form.Top = (768 /2) - (400 /2)
Else
$Form.Center
EndIf
; ClockTimer
$Timer = $Form.Timer(600, 0, 0, 15, 15)
$Timer.OnTimer = "UpdateClock()"
; Logo
$Logo = $Form.PictureBox
$Logo.Left = 5
$Logo.Top = 5
$Logo.Width = 483
$Logo.Height = 50
$Logo.Picture = "logo.bmp"
; Info Frame
$InfoFrame = $Form.Frame("Information", 5, 55, 240, 100)
$OSLbl = $InfoFrame.Label("Os", 5, 15, 115, 15)
$OSBox = $InfoFrame.TextBox("", 120, 15, 115, 15)
$OSBox.BackColor = $Form.BackColor
$OSBox.ForeColor = $Form.ForeColor
$OSBox.Enabled = 0
$UserIdLbl = $InfoFrame.Label("UserId", 5, 30, 115, 15)
$UserIdBox = $InfoFrame.TextBox(@USERID, 120, 30, 115, 15)
$UserIdBox.BackColor = $Form.BackColor
$UserIdBox.Enabled = 0
$UserIdBox.ForeColor = "Red"
;$FullNameLbl = $InfoFrame.Label("Full Name", 5, 45, 115, 15)
;$FullNameBox = $InfoFrame.TextBox(@FULLNAME, 120, 45, 115, 15)
;$FullNameBox.BackColor=$Form.BackColor
;$FullNameBox.Enabled=0
;$PriviledgeLbl = $InfoFrame.Label("Priviledge", 5, 60, 115, 15)
;$PriviledgeBox = $InfoFrame.TextBox(@WKSTA, 120, 60, 115, 15)
;$PriviledgeBox.BackColor=$Form.BackColor
;$PriviledgeBox.Enabled=0
$WorkStnLbl = $InfoFrame.Label("Workstation", 5, 45, 115, 15)
$WorkStnBox = $InfoFrame.TextBox(@WKSTA, 120, 45, 115, 15)
$WorkStnBox.BackColor = $Form.BackColor
$WorkStnBox.Enabled = 0
$DomainLbl = $InfoFrame.Label("Domain", 5, 60, 115, 15)
$DomainBox = $InfoFrame.TextBox(@DOMAIN, 120, 60, 115, 15)
$DomainBox.BackColor = $Form.BackColor
$DomainBox.Enabled = 0
$ServerLbl = $InfoFrame.Label("Server", 5, 75, 115, 15)
$ServerBox = $InfoFrame.TextBox($LSERVER, 120, 75, 115, 15)
$ServerBox.BackColor = $Form.BackColor
$ServerBox.Enabled = 0
;$MemberLbl = $InfoFrame.Label("Group Member", 5, 120, 115, 15)
;$MemberBox = $InfoFrame.TextBox(@group, 120, 120, 115, 15)
;$MemberBox.BackColor=$Form.BackColor
;$MemberBox.Enabled=0
; Action Frame
$ActionFrame = $Form.Frame("Actions", 250, 55, 240, 100)
$NewsRadioButton = $ActionFrame.RadioButton("Get News", 5, 15, 230, 15)
$TimeRadioButton = $ActionFrame.RadioButton("Set Time", 5, 30, 230, 15)
$SharesRadioButton = $ActionFrame.RadioButton("Connect Drives", 5, 45, 230, 15)
;$CheckSoftwareRadioButton = $ActionFrame.RadioButton("Check Software Versions", 5, 60, 230, 15)
;$InstallSoftwareRadioButton = $ActionFrame.RadioButton("Install Software", 25, 75, 230, 15)
;$AntiVirusRadioButton = $ActionFrame.RadioButton("Update Antivirus", 5, 90, 230, 15)
$StandardSettingsRadioButton = $ActionFrame.RadioButton("Standard Settings", 5, 60, 230, 15)
$WriteLogFileRadioButton = $ActionFrame.RadioButton("Write Logfile", 5, 75, 230, 15)
; Logging Frame
$NewsFrame = $Form.Frame("News", 5, 155, 485, 110)
$NewsTextBox = $NewsFrame.TextBox("", 5, 15, 475, 90)
$NewsTextBox.BackColor = $Form.BackColor
$NewsTextBox.MultiLine = 1
$NewsTextBox.Enable = 0
$NewsTextBox.Text = ""
$NewsTextBox.ForeColor = 0, 225, 0
$NewsTextBox.ScrollBars = 2
$NewsTextBox.Wordwrap = 1
; Progress Bar
$ProgressTextBox = $Form.TextBox
$ProgressTextBox.Left = 5
$ProgressTextBox.Top = 270
$ProgressTextBox.Width = 200
$ProgressTextBox.Height = 20
$ProgressTextBox.Enable = 0
$ProgressTextBox.BackColor = $Form.BackColor
$ProgressBar = $Form.ProgressBar
$ProgressBar.Left = 210
$ProgressBar.Top = 270
$ProgressBar.Width = 220
$ProgressBar.Height = 20
$ProgressBar.Style = 1
; Clock
$CurrentTime = @Time
$Clock = $Form.TextBox("", 435, 270, 55, 20)
$Clock.Alignment = 2
$Clock.Enabled = 0
$Clock.BackColor = $Form.BackColor
$Form.Show
; DebugForm
If $DebugFlag = $True
$DbgForm = CreateObject("Kixtart.Form")
$DbgForm.Caption = "DebugBox"
$DbgForm.Width = 260
$DbgForm.Height = 500
$DbgForm.Left = 1024 - 260
$DbgFOrm.Top = 768 - 550
$DbgTextBox = $DbgForm.TextBox()
$DbgTextBox.Left = 5
$DbgTextBox.Top = 5
$DbgTextBox.Width = 245
$DbgTextBox.Height = 465
$DbgTextBox.MultiLine = 1
$DbgTextBox.Enable = 0
$DbgTextBox.Text = ""
$DbgTextBox.ScrollBars = 2
$DbgTextBox.Wordwrap = 1
$CurrentX = 0
$CurrentY = 0
$DbgForm.Show
EndIf
EndFunction
Exit
Thanks,
Kent
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
2 registered
(morganw, mole)
and 414 anonymous users online.
|
|
|