[color:#333399];******************************************
;*** Initialise Global script variables ***
CALL @LDRIVE+"C:\Netlogon\UDF_Global.kix"
$UpdatesScripts_Loc = "C:\Netlogon\"
$LogonLogs = "C:\Netlogon\Software_Inventory\"
;*** End Initialise Global script variables ***
;**********************************************
IF @ProductType="Windows NT Workstation" OR @ProductType="Windows 2000 Professional" OR @ProductType="Windows XP Professional" OR @ProductType="Windows XP Professional Tablet PC" OR @ProductType="Windows 7 Enterprise"
CALL $UpdatesScripts_Loc+"Software_Inventory.kix"
ENDIF
; *** End Write Logon info ***
; ***************************************************************************************************
[/color]
Software_Inventory.kix
[color:#3333FF]; ========================================================================
$uninstallkey="HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\"
$PackageList=Chr(34)+"PC"+Chr(34)+","+CHR(34)+"Software_Name"+CHR(34)+","+CHR(34)+"Software_Version"+Chr(34)+","+Chr(34)+"Software_Publisher"+Chr(34)
$Index=0
:PackageLoop
$package=ENUMKEY($uninstallkey, $Index)
If @ERROR = 0
$SoftwareName=READVALUE($uninstallkey+$package,"Displayname")
If $SoftwareName<>""
If InStr($SoftwareName,"Security Update For")=0 AND InStr($SoftwareName,"Update for Windows XP")=0 AND InStr($SoftwareName,"Windows XP Hotfix")=0 AND InStr($SoftwareName,"Hotfix for Windows XP")=0 AND InStr($SoftwareName,"Windows 2000 Hotfix")=0
$SoftwareVersion="N/A"
$SoftwareVersion=READVALUE($uninstallkey+$package,"DisplayVersion")
If $SoftwareVersion=""
$SoftwareVersion="N/A"
EndIf
$Publisher="N/A"
$Publisher=READVALUE($uninstallkey+$package,"Publisher")
If $Publisher=""
$Publisher="N/A"
EndIf
$PackageList = $PackageList + @CRLF +CHR(34)+ @WKSTA +CHR(34)+ "," +CHR(34)+ $SoftwareName +CHR(34)+ "," +CHR(34)+ $SoftwareVersion+CHR(34)+","+Chr(34)+$Publisher+Chr(34)
ENDIF
EndIf
$Index=$Index+1
Goto PackageLoop
EndIf
LogtoFile("ForceOverwrite",$LogonLogs+"Software_Inventory\"+@WKSTA+".csv",$PackageList)[/color]
UDF_Global.kix
[color:#6633FF];*** Global Variables ***
$GlobalScripts_Loc = @LDRIVE+"C:\Netlogon\"
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;FUNCTION ChkRegSec
;ACTION Checks if the user can write to the specified registry key
;SYNTAX ChkRegSec(RegistryKey)
;PARAMETERS RegistryKey
; Registry key to check for write access (in form HKLM\Key\Subkey or HKCU\Key\Subkey)
;RETURNS 0 if write permission OK, error code if failed
;EXAMPLE IF ChkRegSec("HKLM\Software\MiltonKeynesCouncil")<>0 ? "No permission to write to registry" ENDIF
;
FUNCTION ChkRegSec( $RegKey )
DIM $regsectest
$ChkRegSec = 0
$regsectest = WriteValue($RegKey, "MKCTESTSEC", "Passed", "REG_SZ")
If $regsectest <> 0
Shell $GlobalScripts_Loc+"regseclog.bat "+@USERID+" "+@WKSTA+" "+@TIME+" "+@DATE+" "+@LSERVER+" "+$RegKey
$ChkRegSec = $regsectest
EndIf
EndFunction
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;FUNCTION ChkPerms
;ACTION Checks if the user can write to the specified registry key
;AUTHOR Jeremy Smedley
;VERSION 1.00
;KIXTART 4.21
;DATE CREATED 2006/03/21
;SYNTAX ChkPerms(Type, Location)
;PARAMETERS Type
; Registry or Folder
; Location
; Folder or Registry key to check for write access (in form HKLM\Key\Subkey or HKCU\Key\Subkey, or Drive:\folder)
;RETURNS 0 if write + delete permission OK, 1 if no write permission, 2 if no delete permission
;EXAMPLE IF ChkPerms("Registry","HKLM\Software\MiltonKeynesCouncil")=1 ? "No permission to write to registry" ENDIF
;
Function ChkPerms( $chkpermstype, $chkpermsLocation )
DIM $chkpermstest, $chkpermstest2, $chkpermstatus
Select
Case $chkpermstype="Registry"
$chkpermstest = WriteValue($chkpermsLocation, "MKCTESTSEC", "Passed", "REG_SZ")
$chkpermstest2 = ReadValue($chkpermsLocation, "MKCTESTSEC")
If $chkpermstest2 = "Passed"
$chkpermstest = DelValue($chkpermsLocation, "MKCTESTSEC")
If $chkpermstest = 0
$chkpermstatus = 0
Else
$chkpermstatus = 2
EndIf
Else
$chkpermstatus = 1
EndIf
$ChkPerms = $chkpermstatus
Case $chkpermstype="Folder"
Copy @LDRIVE+"C:\Logons\securitytest.txt" $chkpermsLocation+"\securitytest.txt"
If Exist($chkpermsLocation+"\securitytest.txt")
Del $chkpermsLocation+"\securitytest.txt"
If Exist($chkpermsLocation+"\securitytest.txt")
$chkpermstatus = 2
Else
$chkpermstatus = 0
EndIf
Else
$chkpermstatus = 1
EndIf
$ChkPerms = $chkpermstatus
Case 1
$ChkPerms = 50
EndSelect
EndFunction
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;FUNCTION LogtoFile
;ACTION Writes data to log file
;AUTHOR Jeremy Smedley
;VERSION 1.00
;KIXTART 4.21
;DATE CREATED 2006/03/21
;SYNTAX LogtoFile(Function, Location, Data)
;PARAMETERS Function
; Append or Overwrite
; Location
; File to write to
; Data
; Required contents of file
;RETURNS N/A
;EXAMPLE LogtoFile("Append",$LogonLogs+"byuser\user1","Testing User1 logging")
;
Function LogtoFile( $LogtoFile_Fn, $LogtoFile_Loc, $LogtoFile_Data )
$LogtoFile_x = FreeFileHandle()
IF $LogtoFile_x >0
Select
Case $LogtoFile_Fn = "Append"
IF Open( $LogtoFile_x , $LogtoFile_Loc , 5 ) = 0
$LogtoFile_y = WriteLine( 1 , $LogtoFile_Data + @CRLF )
$LogtoFile_y = Close($LogtoFile_x)
ENDIF
Case $LogtoFile_Fn = "ForceOverwrite"
IF EXIST ($LogtoFile_Loc)
DEL $LogtoFile_Loc
ENDIF
IF Open( $LogtoFile_x , $LogtoFile_Loc , 5 ) = 0
$LogtoFile_y = WriteLine( 1 , $LogtoFile_Data + @CRLF )
$LogtoFile_y = Close($LogtoFile_x)
ENDIF
Case $LogtoFile_Fn = "Overwrite"
RUN "CMD.exe /C ECHO "+$LogtoFile_Data+">"+"$LogtoFile_Loc"
Case 1
RUN "CMD.exe /C ECHO "+$LogtoFile_Data+">>"+"$LogtoFile_Loc"
EndSelect
EndIf
EndFunction
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$[/color]