#200486 - 2010-11-03 11:40 AM
Does my script runs under Windows 2k8 and 2k8 Active Directory?
|
backfight
Getting the hang of it
Registered: 2007-01-22
Posts: 61
Loc: Germany
|
Hello all, does the following script run under Windows 2k8 R2 Stadard Server Platform with an 2k8 Active Directory?
The Domainclients are Windows XP only.
Break off
SetConsole("Hide")
;****************************************************************************
;Loeschen der Temp Dateien (deaktiviert)
;
; run "\\...local\Policies\{81C8A747-9992-4E6D-9BD4-93A7DB5090CB}\User\Scripts\Logon\DelTemp\DelTemp.exe"
;
;****************************************************************************
;****************************************************************************
;Set Wallpaper
;****************************************************************************
$RC=WriteValue ('HKCU\Control Panel\Desktop', 'TitelWallpaper', '1', REG_SZ)
If @ERROR = 0
? 'Value written to the registry'
Endif
$RC=WriteValue ('HKCU\Control Panel\Desktop', 'WallpaperStyle', '2', REG_SZ)
If @ERROR = 0
? 'Value written to the registry'
Endif
If SetWallpaper ('\\....local\Policies\{81C8A747-9992-4E6D-9BD4-93A7DB5090CB}\User\Scripts\Logon\Hintergrundbild\BSL.bmp', 1) = 0
? 'Set current wallpaper to BSL.bmp...'
Endif
;****************************************************************************
;Set Uservariablen
;****************************************************************************
SET "temp=C:\temp"
SET "tmp=C:\temp"
SETTIME "\\SVR"
;****************************************************************************
;Set User Ansicht auf Detail
;****************************************************************************
run "\\....local\Policies\{81C8A747-9992-4E6D-9BD4-93A7DB5090CB}\User\Scripts\Logon\Ansicht-Explorer-Details.exe"
;****************************************************************************
;Definieren der Server
;****************************************************************************
$fs01="\\SRV1"
$fs02="\\SRV2"
$fs03="\\SRV3"
$fs07="\\SRV4"
$fs08="\\SRV5"
$fs09="\\SRV6"
$fs10="\\SRV7"
;****************************************************************************
;Verbinden von Netzwerklaufwerken
;****************************************************************************
use "*" /delete
;****************************************************************************
;Verbinden von Netzwerklaufwerken für die EDV
;****************************************************************************
IF InGroup("EDVGruppe")
Use Z: $fs02+"\Test"
EndIf
;****************************************************************************
;Verbinden der Netzwerkdrucker für alle Abteilungen
;****************************************************************************
;Script Options
If NOT @LOGONMODE
Break On
EndIf
Dim $RC
$RC=SetOption("Explicit", "On")
$RC=SetOption("NoMacrosInStrings", "On")
$RC=SetOption("NoVarsInStrings", "On")
$RC=SetOption("WrapAtEOL", "On")
;***********
;Printserver
;***********
Dim $ERPServer $ERPServer="SRV5"
;****************************************************************************
;Netzwerkdrucker
;****************************************************************************
Dim $EDV $EDV="Brother_.6"
;****************************************************************************
;Verbinden der Netzwerkdrucker für die EDV
;****************************************************************************
If InGroup("EDVGruppe")
$RC = AddPrinterConnection("\\"+$ERPServer+"\"+$EDV)
EndIf
;****************************************************************************
; Hardware Informationen von allen Domain PC´s auslesen
;****************************************************************************
; Umleitung der Ausgaben auf eine Datei mit Rechnernamen im Dateinamen
break on
cls
dim $result
$result=setoption('explicit','on')
$result=setoption('novarsinstrings','on')
$result=setoption('nomacrosinstrings','on')
dim $verzeichnis, $datei, $dimm, $computer
$verzeichnis = '\\...\Anmeldungen\'
$datei = @Hostname+"_info.txt"
if not exist($verzeichnis)
? 'Kann Verzeichnis '+$verzeichnis+' nicht finden'
exit 1
endif
$result=RedirectOutput ($verzeichnis+$datei ,1)
if @error
? 'Error '+@error+' - '+@serror
endif
? "Datum der Erfassung = " + @date
? "Monat = " + @MONTH
? "Tag = " + @DAY
? "Uhrzeit = " + @time
? "Letzter Login von = " + @FULLNAME
? "User Privilegien = " + @PRIV
? "PC Name = " + WMIQuery("CSName","Win32_OperatingSystem")[0]
? "IP Adresse = " + @IPADDRESS0
? "MAC Adresse = " + @ADDRESS
? "OS Name = " + WMIQuery("Caption","Win32_OperatingSystem")[0]
? "Service Pack = " + WMIQuery("CSDVersion","Win32_OperatingSystem")[0]
? "Install Date = " + WMIQuery("InstallDate","Win32_OperatingSystem")[0]
? "OS Version Number = " + WMIQuery("Version","Win32_OperatingSystem")[0]
? "OS Build Number = " + WMIQuery("BuildNumber","Win32_OperatingSystem")[0]
? "Sprache = " + @SysLang
? "Registered User = " + WMIQuery("RegisteredUser","Win32_OperatingSystem")[0]
? "Boot Device = " + WMIQuery("BootDevice","Win32_OperatingSystem")[0]
? "System Device = " + WMIQuery("SystemDevice","Win32_OperatingSystem")[0]
? "Windows Directory = " + WMIQuery("WindowsDirectory","Win32_OperatingSystem")[0]
? "System Directory = " + WMIQuery("SystemDirectory","Win32_OperatingSystem")[0]
? "Last Boot Time = " + WMIQuery("LastBootupTime","Win32_OperatingSystem")[0]
? "OS Serial Number = " + WMIQuery("SerialNumber","Win32_OperatingSystem")[0]
? "System Manufacturer is = " + WMIQuery("Manufacturer","Win32_ComputerSystem")[0]
? "System Model is = " + WMIQuery("Model","Win32_ComputerSystem")[0]
? "System Serial Number is = " + WMIQuery("SerialNumber","Win32_BIOS")[0]
? "System BIOS Version is = " + WMIQuery("SMBIOSBIOSVersion","Win32_BIOS")[0]
? "System BIOS Date is = " + WMIQuery("Version","Win32_BIOS")[0]
? "CPU Modell = " + @CPU
? "CPU Manufacturer: = " + WMIQuery("manufacturer","Win32_Processor")[0]
? "Description: = " + WMIQuery("description","Win32_Processor")[0]
? "CPU Speed is = " + WMIQuery("CurrentClockSpeed","Win32_Processor")[0]+" Mhz"
? "Maximum Clock Speed = " + WMIQuery("maxclockspeed","Win32_Processor")[0]+" Mhz"
? "L2 Cache Size: = " + WMIQuery("l2cachesize","Win32_Processor")[0]
? "L2 Cache Speed: = " + WMIQuery("l2cachespeed","Win32_Processor")[0]
? "Family: = " + WMIQuery("family","Win32_Processor")[0]
? "Level: = " + WMIQuery("level","Win32_Processor")[0]
? "Stepping: = " + WMIQuery("stepping","Win32_Processor")[0]
? "Device ID: = " + WMIQuery("deviceid","Win32_Processor")[0]
? "Unique ID: = " + WMIQuery("uniqueid","Win32_Processor")[0]
? "System Memory = " + cint(Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration")[0])/1024) + " MB"
For Each $dimm in WMIQuery("Capacity","Win32_PhysicalMemory")
? "Dimm Size = " + cint(Val($dimm) / 1048576) + " MB"
Next
? "Disk Name/s = " + join(WMIQuery("name","Win32_LogicalDisk"),', ')
? "Volume Name = " + join(WMIQuery("volumename","Win32_LogicalDisk"),', ') + " MB"
? "Size = " + join(WMIQuery("size","Win32_LogicalDisk"),', ')+ " MB"
? "File System = " + join(WMIQuery("filesystem","Win32_LogicalDisk"),', ')
? "Free Space = " + join(WMIQuery("freespace","Win32_LogicalDisk"),', ')+" MB"
? "Video Card is = " + WMIQuery("Description","Win32_VideoController")[0]
? "Video Res is = " + WMIQuery("VideoModeDescription","Win32_VideoController")[0]
? "Modem is = " + WMIQuery("Description","Win32_POTSModem")[0]
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
Dim $RegArray,$Value,$Product,$Key
$RegArray = SearchReg("HKLM\Software\Microsoft","DigitalProductID",2)
If @Error
Else
For Each $Value in $RegArray
If $Value
$Product = ReadValue(Join(Split($value,'<=>DigitalProductId'),''),'ProductName')
If $Product
$Key = Get_Product_Key(ReadValue(Join(Split($value,'<=>DigitalProductId'),''), 'DigitalProductID'))
? + $Product + ' = ' + $Key ?
EndIf
EndIf
Next
EndIf
$computer = @wksta
? WMIQuery2("Services on","Win32_Service",$computer)
? WMIQuery2("Processes on","Win32_Process",$computer)
$result=redirectoutput('')
exit 0
Function SearchReg($Key,$Str,$SrcIn)
Dim $Idx,$vName,$Value,$num,$SubKey,$fArr,$mbr
$SearchReg = ''
$num = 0
$Idx = 0
$vName = EnumValue($Key,$Idx)
Do
$mbr = ''
If $SrcIn & 1
$Value = ReadValue($Key,$vName)
If InStr($Value,$Str)
$mbr = $Key + "<=>" + IIf($vName,$vName,'<Default>')
EndIf
EndIf
If ($SrcIn & 2) And InStr($vName,$Str)
$mbr = $Key + "<=>" + $vName
EndIf
If $mbr
ReDim Preserve $SearchReg[$num]
$SearchReg[$num] = $mbr
$num = $num + 1
EndIf
$Idx = $Idx + 1
$vName = EnumValue($Key,$Idx)
Until @Error
$Idx = 0
$SubKey = EnumKey($Key,$Idx)
While $SubKey
If ($SrcIn & 4) And InStr($SubKey,$Str)
ReDim Preserve $SearchReg[$num]
$SearchReg[$num] = $Key + '\' + $SubKey + "<=><KeyName>"
$num = $num + 1
EndIf
$fArr = SearchReg($Key + "\" + $SubKey,$Str,$SrcIn)
If @Error = 0
For Each $mbr in $fArr
ReDim Preserve $SearchReg[$num]
$SearchReg[$num] = $mbr
$num = $num + 1
Next
EndIf
$Idx = $Idx + 1
$SubKey = EnumKey($Key,$Idx)
Loop
Exit VarType($SearchReg) = 8
EndFunction
Function Get_Product_Key($sProductID)
Dim $aiKeyChars[24],$bProductKey[15],$ilByte,$i,$sCDKey,$nCur
$aiKeyChars = Split('B,C,D,F,G,H,J,K,M,P,Q,R,T,V,W,X,Y,2,3,4,6,7,8,9',',')
For $i = 0 to 14
$bProductKey[$i] = Val("&"+SubStr($sProductID,$i*2+105,2))
Next
$sCDKey = ""
For $ilByte = 24 to 0 Step -1
$nCur = 0
For $i=14 to 0 Step -1
$nCur = $nCur * 256 | $bProductKey[$i]
$bProductKey[$i] = Int($nCur / 24)
$nCur = $nCur Mod 24
Next
$sCDKey = $aiKeyChars[$nCur] + $sCDKey
If $ilByte Mod 5 = 0 And $ilByte <> 0
$sCDKey = "-" + $sCDKey
EndIf
Next
$Get_Product_Key = $sCDKey
EndFunction
FUNCTION WMIQuery($sWhat, $sFrom, Optional $sComputer, Optional $sWhere, Optional $x, Optional $root)
Dim $sQuery, $objEnum, $sValue, $sItem, $TMP, $SystemSet, $, $objInstance
If Not $sComputer $sComputer="." EndIf
if instr($sComputer,'\') $sComputer=right($sComputer,instrrev($sComputer,'\')) Endif
if not $root $root="\root\cimv2" Endif
$sQuery = "Select " + $sWhat + " From "+ $sFrom
If $sWhere AND $x $sQuery = $sQuery+" Where "+$sWhere+" = '"+$x+"'" EndIf
$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"+$sComputer+$root)
If @ERROR Exit VAL("&"+Right(DecToHex(@ERROR),4)) EndIf
$objEnum = $SystemSet.ExecQuery($sQuery)
If @ERROR Exit VAL("&"+Right(DecToHex(@ERROR),4)) EndIf
For Each $objInstance in $objEnum
If $objInstance
$=Execute("$"+"sValue = $"+"objInstance."+$sWhat)
if VarType($sValue) & 8192
For Each $sItem in $sValue $tmp=$tmp+'|'+Trim($sItem) Next
else
$tmp=$tmp+'|'+Trim($svalue)
Endif
EndIf
Next
$WMIQuery = split(substr($tmp,2),'|')
Exit VAL("&"+Right(DecToHex(@ERROR),4))
ENDFUNCTION
Function WMIQuery2($what,$where,$computer)
dim $wmi, $list, $objs, $obj
$wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!//" + $computer + "/root/cimv2")
$list = "" $objs = $wmi.instancesof($where)
For Each $obj in $objs
$list = $list + $obj.description + Chr(13) + Chr(10)
Next
$list=Left($list, Len($list))
? $what +" "+ $computer + Chr(13) + Chr(10) + $list
EndFunction
Edited by backfight (2010-11-03 11:42 AM)
|
Top
|
|
|
|
#200494 - 2010-11-04 09:18 AM
Re: Does my script runs under Windows 2k8 and 2k8 Active Directory?
[Re: Mart]
|
backfight
Getting the hang of it
Registered: 2007-01-22
Posts: 61
Loc: Germany
|
Hi Mart, can you show me how the script looks like after your changes? I´m a little bit out of theme. Long time ago i wrote this script and only with help of this forum.
Greetz backfight
|
Top
|
|
|
|
#200496 - 2010-11-04 10:22 AM
Re: Does my script runs under Windows 2k8 and 2k8 Active Directory?
[Re: backfight]
|
Mart
KiX Supporter
Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
|
See the script below for some of the changes. I did not make all changes I suggested but this should get you going. I would also DIM all variables at the top of the script. You have Explicit set to on so all vars must be DIMmed. If you DIM them at the top instead of when you need them you can easily move parts of the scrip up or down without getting any error about undeclared variables.
If Not @LOGONMODE
Break On
EndIf
SetConsole("Hide")
$RC=SetOption("Explicit", "On")
$RC=SetOption("NoMacrosInStrings", "On")
$RC=SetOption("NoVarsInStrings", "On")
$RC=SetOption("WrapAtEOL", "On")
;****************************************************************************
;Loeschen der Temp Dateien (deaktiviert)
;
; run "\\...local\Policies\{81C8A747-9992-4E6D-9BD4-93A7DB5090CB}\User\Scripts\Logon\DelTemp\DelTemp.exe"
;
;****************************************************************************
;****************************************************************************
;Set Wallpaper
;****************************************************************************
$RC=WriteValue ('HKCU\Control Panel\Desktop', 'TitelWallpaper', '1', REG_SZ)
If @ERROR = 0
? 'Value written to the registry'
EndIf
$RC=WriteValue ('HKCU\Control Panel\Desktop', 'WallpaperStyle', '2', REG_SZ)
If @ERROR = 0
? 'Value written to the registry'
EndIf
If SetWallpaper ('\\....local\Policies\{81C8A747-9992-4E6D-9BD4-93A7DB5090CB}\User\Scripts\Logon\Hintergrundbild\BSL.bmp', 1) = 0
? 'Set current wallpaper to BSL.bmp...'
EndIf
;****************************************************************************
;Set Uservariablen
;****************************************************************************
Set "temp=C:\temp"
Set "tmp=C:\temp"
;****************************************************************************
;Set User Ansicht auf Detail
;****************************************************************************
Run "\\....local\Policies\{81C8A747-9992-4E6D-9BD4-93A7DB5090CB}\User\Scripts\Logon\Ansicht-Explorer-Details.exe"
;****************************************************************************
;Definieren der Server
;****************************************************************************
$fs01="\\SRV1"
$fs02="\\SRV2"
$fs03="\\SRV3"
$fs07="\\SRV4"
$fs08="\\SRV5"
$fs09="\\SRV6"
$fs10="\\SRV7"
;****************************************************************************
;Verbinden von Netzwerklaufwerken
;****************************************************************************
Use "*" /delete
;****************************************************************************
;Verbinden von Netzwerklaufwerken für die EDV
;****************************************************************************
If InGroup("EDVGruppe")
Use Z: /delete /persistent
Use Z: $fs02+"\Test"
EndIf
;****************************************************************************
;Verbinden der Netzwerkdrucker für alle Abteilungen
;****************************************************************************
;Script Options
Dim $RC
;***********
;Printserver
;***********
Dim $ERPServer
$ERPServer="SRV5"
;****************************************************************************
;Netzwerkdrucker
;****************************************************************************
Dim $EDV
$EDV="Brother_.6"
;****************************************************************************
;Verbinden der Netzwerkdrucker für die EDV
;****************************************************************************
If InGroup("EDVGruppe")
$rc = DelPrinterConnection("\\"+$ERPServer+"\"+$EDV)
$RC = AddPrinterConnection("\\"+$ERPServer+"\"+$EDV)
EndIf
;****************************************************************************
; Hardware Informationen von allen Domain PC´s auslesen
;****************************************************************************
; Umleitung der Ausgaben auf eine Datei mit Rechnernamen im Dateinamen
CLS
Dim $result
Dim $verzeichnis, $datei, $dimm, $computer
$verzeichnis = '\\...\Anmeldungen\'
$datei = @Hostname+"_info.txt"
If Not Exist($verzeichnis)
? 'Kann Verzeichnis '+$verzeichnis+' nicht finden'
Exit 1
EndIf
$rc = Open(1,$verzeichnis+$datei, 5)
If @error
? 'Error '+@error+' - '+@serror
EndIf
$rc = WriteLine(1 "Datum der Erfassung = " + @date + @CRLF)
$rc = WriteLine(1 "Monat = " + @MONTH + @CRLF)
$rc = WriteLine(1 "Tag = " + @DAY + @CRLF)
$rc = WriteLine(1 "Uhrzeit = " + @time + @CRLF)
$rc = WriteLine(1 "Letzter Login von = " + @FULLNAME + @CRLF)
$rc = WriteLine(1 "User Privilegien = " + @PRIV + @CRLF)
$rc = WriteLine(1 "PC Name = " + @WKSTA + @CRLF)
$rc = WriteLine(1 "IP Adresse = " + @IPADDRESS0 + @CRLF)
$rc = WriteLine(1 "MAC Adresse = " + @ADDRESS + @CRLF)
$rc = WriteLine(1 "OS Name = " + @PRODUCTTYPE + @CRLF)
$rc = WriteLine(1 "Service Pack = " + @CSD + @CRLF)
$rc = WriteLine(1 "Install Date = " + WMIQuery("InstallDate","Win32_OperatingSystem")[0] + @CRLF)
$rc = WriteLine(1 "OS Version Number = " + WMIQuery("Version","Win32_OperatingSystem")[0] + @CRLF)
$rc = WriteLine(1 "OS Build Number = " + WMIQuery("BuildNumber","Win32_OperatingSystem")[0] + @CRLF)
$rc = WriteLine(1 "Sprache = " + @SYSLANG + @CRLF)
$rc = WriteLine(1 "Registered User = " + WMIQuery("RegisteredUser","Win32_OperatingSystem")[0] + @CRLF)
$rc = WriteLine(1 "Boot Device = " + WMIQuery("BootDevice","Win32_OperatingSystem")[0] + @CRLF)
$rc = WriteLine(1 "System Device = " + WMIQuery("SystemDevice","Win32_OperatingSystem")[0] + @CRLF)
$rc = WriteLine(1 "Windows Directory = " + WMIQuery("WindowsDirectory","Win32_OperatingSystem")[0] + @CRLF)
$rc = WriteLine(1 "System Directory = " + WMIQuery("SystemDirectory","Win32_OperatingSystem")[0] + @CRLF)
$rc = WriteLine(1 "Last Boot Time = " + WMIQuery("LastBootupTime","Win32_OperatingSystem")[0] + @CRLF)
$rc = WriteLine(1 "OS Serial Number = " + WMIQuery("SerialNumber","Win32_OperatingSystem")[0] + @CRLF)
$rc = WriteLine(1 "System Manufacturer is = " + WMIQuery("Manufacturer","Win32_ComputerSystem")[0] + @CRLF)
$rc = WriteLine(1 "System Model is = " + WMIQuery("Model","Win32_ComputerSystem")[0] + @CRLF)
$rc = WriteLine(1 "System Serial Number is = " + WMIQuery("SerialNumber","Win32_BIOS")[0] + @CRLF)
$rc = WriteLine(1 "System BIOS Version is = " + WMIQuery("SMBIOSBIOSVersion","Win32_BIOS")[0] + @CRLF)
$rc = WriteLine(1 "System BIOS Date is = " + WMIQuery("Version","Win32_BIOS")[0]
$rc = WriteLine(1 "CPU Modell = " + @CPU + @CRLF)
$rc = WriteLine(1 "CPU Manufacturer: = " + WMIQuery("manufacturer","Win32_Processor")[0] + @CRLF)
$rc = WriteLine(1 "Description: = " + WMIQuery("description","Win32_Processor")[0] + @CRLF)
$rc = WriteLine(1 "CPU Speed is = " + @MHZ + " Mhz" + @CRLF)
$rc = WriteLine(1 "Maximum Clock Speed = " + WMIQuery("maxclockspeed","Win32_Processor")[0]+" Mhz" + @CRLF)
$rc = WriteLine(1 "L2 Cache Size: = " + WMIQuery("l2cachesize","Win32_Processor")[0] + @CRLF)
$rc = WriteLine(1 "L2 Cache Speed: = " + WMIQuery("l2cachespeed","Win32_Processor")[0] + @CRLF)
$rc = WriteLine(1 "Family: = " + WMIQuery("family","Win32_Processor")[0] + @CRLF)
$rc = WriteLine(1 "Level: = " + WMIQuery("level","Win32_Processor")[0] + @CRLF)
$rc = WriteLine(1 "Stepping: = " + WMIQuery("stepping","Win32_Processor")[0] + @CRLF)
$rc = WriteLine(1 "Device ID: = " + WMIQuery("deviceid","Win32_Processor")[0] + @CRLF)
$rc = WriteLine(1 "Unique ID: = " + WMIQuery("uniqueid","Win32_Processor")[0] + @CRLF)
$rc = WriteLine(1 "System Memory = " + CInt(Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration")[0])/1024) + " MB" + @CRLF)
For Each $dimm in WMIQuery("Capacity","Win32_PhysicalMemory")
$rc = WriteLine(1 "Dimm Size = " + CInt(Val($dimm) / 1048576) + " MB" + @CRLF)
Next
$rc = WriteLine(1 "Disk Name/s = " + Join(WMIQuery("name","Win32_LogicalDisk"),', ') + @CRLF)
$rc = WriteLine(1 "Volume Name = " + Join(WMIQuery("volumename","Win32_LogicalDisk"),', ') + " MB" + @CRLF)
$rc = WriteLine(1 "Size = " + Join(WMIQuery("size","Win32_LogicalDisk"),', ')+ " MB" + @CRLF)
$rc = WriteLine(1 "File System = " + Join(WMIQuery("filesystem","Win32_LogicalDisk"),', ') + @CRLF)
$rc = WriteLine(1 "Free Space = " + Join(WMIQuery("freespace","Win32_LogicalDisk"),', ')+" MB" + @CRLF)
$rc = WriteLine(1 "Video Card is = " + WMIQuery("Description","Win32_VideoController")[0] + @CRLF)
$rc = WriteLine(1 "Video Res is = " + WMIQuery("VideoModeDescription","Win32_VideoController")[0] + @CRLF)
$rc = WriteLine(1 "Modem is = " + WMIQuery("Description","Win32_POTSModem")[0] + @CRLF)
$rc = Close(1)
Dim $SO
Dim $RegArray,$Value,$Product,$Key
$RegArray = SearchReg("HKLM\Software\Microsoft","DigitalProductID",2)
If Not @Error
For Each $Value in $RegArray
If $Value
$Product = ReadValue(Join(Split($value,'<=>DigitalProductId'),''),'ProductName')
If $Product
$Key = Get_Product_Key(ReadValue(Join(Split($value,'<=>DigitalProductId'),''), 'DigitalProductID'))
? + $Product + ' = ' + $Key ?
EndIf
EndIf
Next
EndIf
$computer = @WKSTA
? WMIQuery2("Services on","Win32_Service",$computer)
? WMIQuery2("Processes on","Win32_Process",$computer)
$result=RedirectOutput('')
Exit 0
Function SearchReg($Key,$Str,$SrcIn)
Dim $Idx,$vName,$Value,$num,$SubKey,$fArr,$mbr
$SearchReg = ''
$num = 0
$Idx = 0
$vName = EnumValue($Key,$Idx)
Do
$mbr = ''
If $SrcIn & 1
$Value = ReadValue($Key,$vName)
If InStr($Value,$Str)
$mbr = $Key + "<=>" + IIf($vName,$vName,'<Default>')
EndIf
EndIf
If ($SrcIn & 2) And InStr($vName,$Str)
$mbr = $Key + "<=>" + $vName
EndIf
If $mbr
ReDim Preserve $SearchReg[$num]
$SearchReg[$num] = $mbr
$num = $num + 1
EndIf
$Idx = $Idx + 1
$vName = EnumValue($Key,$Idx)
Until @Error
$Idx = 0
$SubKey = EnumKey($Key,$Idx)
While $SubKey
If ($SrcIn & 4) And InStr($SubKey,$Str)
ReDim Preserve $SearchReg[$num]
$SearchReg[$num] = $Key + '\' + $SubKey + "<=><KeyName>"
$num = $num + 1
EndIf
$fArr = SearchReg($Key + "\" + $SubKey,$Str,$SrcIn)
If @Error = 0
For Each $mbr in $fArr
ReDim Preserve $SearchReg[$num]
$SearchReg[$num] = $mbr
$num = $num + 1
Next
EndIf
$Idx = $Idx + 1
$SubKey = EnumKey($Key,$Idx)
Loop
Exit VarType($SearchReg) = 8
EndFunction
Function Get_Product_Key($sProductID)
Dim $aiKeyChars[24],$bProductKey[15],$ilByte,$i,$sCDKey,$nCur
$aiKeyChars = Split('B,C,D,F,G,H,J,K,M,P,Q,R,T,V,W,X,Y,2,3,4,6,7,8,9',',')
For $i = 0 to 14
$bProductKey[$i] = Val("&"+SubStr($sProductID,$i*2+105,2))
Next
$sCDKey = ""
For $ilByte = 24 to 0 Step -1
$nCur = 0
For $i=14 to 0 Step -1
$nCur = $nCur * 256 | $bProductKey[$i]
$bProductKey[$i] = Int($nCur / 24)
$nCur = $nCur Mod 24
Next
$sCDKey = $aiKeyChars[$nCur] + $sCDKey
If $ilByte Mod 5 = 0 And $ilByte <> 0
$sCDKey = "-" + $sCDKey
EndIf
Next
$Get_Product_Key = $sCDKey
EndFunction
Function WMIQuery($sWhat, $sFrom, Optional $sComputer, Optional $sWhere, Optional $x, Optional $root)
Dim $sQuery, $objEnum, $sValue, $sItem, $TMP, $SystemSet, $, $objInstance
If Not $sComputer $sComputer="." EndIf
If InStr($sComputer,'\') $sComputer=Right($sComputer,InStrRev($sComputer,'\')) EndIf
If Not $root $root="\root\cimv2" EndIf
$sQuery = "Select " + $sWhat + " From "+ $sFrom
If $sWhere And $x $sQuery = $sQuery+" Where "+$sWhere+" = '"+$x+"'" EndIf
$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"+$sComputer+$root)
If @ERROR Exit Val("&"+Right(DecToHex(@ERROR),4)) EndIf
$objEnum = $SystemSet.ExecQuery($sQuery)
If @ERROR Exit Val("&"+Right(DecToHex(@ERROR),4)) EndIf
For Each $objInstance in $objEnum
If $objInstance
$=Execute("$"+"sValue = $"+"objInstance."+$sWhat)
If VarType($sValue) & 8192
For Each $sItem in $sValue $tmp=$tmp+'|'+Trim($sItem) Next
Else
$tmp=$tmp+'|'+Trim($svalue)
EndIf
EndIf
Next
$WMIQuery = Split(SubStr($tmp,2),'|')
Exit Val("&"+Right(DecToHex(@ERROR),4))
EndFunction
Function WMIQuery2($what,$where,$computer)
Dim $wmi, $list, $objs, $obj
$wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!//" + $computer + "/root/cimv2")
$list = "" $objs = $wmi.instancesof($where)
For Each $obj in $objs
$list = $list + $obj.description + Chr(13) + Chr(10)
Next
$list=Left($list, Len($list))
? $what +" "+ $computer + Chr(13) + Chr(10) + $list
EndFunction
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
Top
|
|
|
|
#200500 - 2010-11-04 12:53 PM
Re: Does my script runs under Windows 2k8 and 2k8 Active Directory?
[Re: Mart]
|
backfight
Getting the hang of it
Registered: 2007-01-22
Posts: 61
Loc: Germany
|
Can you explain to me what has changed with this codechanges?
do i get more performance runing this script?Is there a bug in my script?
|
Top
|
|
|
|
#200575 - 2010-11-11 07:52 AM
Re: Does my script runs under Windows 2k8 and 2k8 Active Directory?
[Re: Mart]
|
backfight
Getting the hang of it
Registered: 2007-01-22
Posts: 61
Loc: Germany
|
Ok, can u help me to code the option with the background? At the moment all clients load the background from a fileserver.
how does the code look like when they download the picture local and after that only load lacaly?
hope u understand what i mean
|
Top
|
|
|
|
#200576 - 2010-11-11 09:21 AM
Re: Does my script runs under Windows 2k8 and 2k8 Active Directory?
[Re: backfight]
|
Mart
KiX Supporter
Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
|
This is based on what we use in our production environment. It retrieves the resolution, checks if matching wallpaper exists on the server. If it does it checks if it exists locally, if not copy it. If it exists locally it checks the file time of the local file and the one on the server if they are different copy it and after all check and copying is done it sets it as the wallpaper. The last four lines set the display mode of the wallpaper.
;Get the current screen resolution using WMI.
$wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_DesktopMonitor")
For Each $wmiObj in $wmiColl
;Check if the found resolution is for the primary monitor.
If $wmiObj.DeviceID = "DesktopMonitor1"
;Combine width and height.
$screenres = CStr($wmiObj.ScreenWidth) + "x" + CStr($wmiObj.ScreenHeight)
EndIf
Next
;Set wallpaper for regular computers and users.
If Exist(@LDRIVE + "wallpaper\Wallpaper" + $screenres + ".bmp")
;Copy wallpaper from the server when a local copy does not exist.
If Not Exist("C:\localfolder\Wallpaper\Wallpaper" + $screenres + ".bmp")
Copy @LDRIVE + "wallpaper\Wallpaper" + $screenres + ".bmp" "C:\localfolder\Wallpaper\*.*"
Else
;Get the timestamp of the local and remote wallpaper.
$local = GetFileTime("C:\localfolder\Wallpaper\Wallpaper" + $screenres + ".bmp")
$logon = GetFileTime(@LDRIVE + "wallpaper\Wallpaper" + $screenres + ".bmp")
;If the timestamps do not match copy the wallpaper from the server. The server is leading.
If $local <> $logon
Copy @LDRIVE + "wallpaper\Wallpaper" + $screenres + ".bmp" "c:\localfolder\wallpaper\*.*"
EndIf
EndIf
;Set the wallpaper.
$rc = SetWallpaper ("C:\localfolder\Wallpaper\Wallpaper" + $screenres + ".bmp", 1)
;Set the way the wallpaper is displayed.
;Stretched: WallpaperStyle = 2, TileWallpaper = 0.
;Centered: WallpaperStyle = 0, TileWallpaper = 0.
;Tiled: WallpaperStyle = 0, TileWallpaper = 1.
$rc = WriteValue("HKU\" + @SID + "\Control Panel\Desktop", "TileWallpaper", "0", "REG_SZ")
$rc = WriteValue("HKU\" + @SID + "\Control Panel\Desktop", "WallpaperStyle", "2", "REG_SZ")
$rc = WriteValue("HKU\" + @SID + "\Software\Microsoft\Internet Explorer\Desktop\General", "TileWallpaper", "0", "REG_SZ")
$rc = WriteValue("HKU\" + @SID + "\Software\Microsoft\Internet Explorer\Desktop\General", "WallpaperStyle", "2", "REG_SZ")
EndIf
Edited by Mart (2010-11-11 10:00 AM) Edit Reason: Typo in the code. Thanks Arend.
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
Top
|
|
|
|
#200577 - 2010-11-11 09:31 AM
Re: Does my script runs under Windows 2k8 and 2k8 Active Directory?
[Re: Mart]
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
|
Mart:
$rc = WriteValue("HKCU\" + @SID + "\Software\Microsoft\Internet Explorer\Desktop\General", "TileWallpaper", "0", "REG_SZ")
$rc = WriteValue("HKCU\" + @SID + "\Software\Microsoft\Internet Explorer\Desktop\General", "WallpaperStyle", "2", "REG_SZ")
Should be:
$rc = WriteValue("HKU\" + @SID + "\Software\Microsoft\Internet Explorer\Desktop\General", "TileWallpaper", "0", "REG_SZ")
$rc = WriteValue("HKU\" + @SID + "\Software\Microsoft\Internet Explorer\Desktop\General", "WallpaperStyle", "2", "REG_SZ")
|
Top
|
|
|
|
#200579 - 2010-11-11 11:16 AM
Re: Does my script runs under Windows 2k8 and 2k8 Active Directory?
[Re: Mart]
|
backfight
Getting the hang of it
Registered: 2007-01-22
Posts: 61
Loc: Germany
|
thanks a lot! I will try this in my testing vmware area
|
Top
|
|
|
|
#200580 - 2010-11-11 11:38 AM
Re: Does my script runs under Windows 2k8 and 2k8 Active Directory?
[Re: backfight]
|
Arend_
MM club member
Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
|
|
Top
|
|
|
|
#200581 - 2010-11-11 12:37 PM
Re: Does my script runs under Windows 2k8 and 2k8 Active Directory?
[Re: backfight]
|
backfight
Getting the hang of it
Registered: 2007-01-22
Posts: 61
Loc: Germany
|
is there a problem with the kix.exe in win2k8 standard r2 x64???
or does the exe run under the client?
|
Top
|
|
|
|
#200583 - 2010-11-11 12:55 PM
Re: Does my script runs under Windows 2k8 and 2k8 Active Directory?
[Re: Mart]
|
backfight
Getting the hang of it
Registered: 2007-01-22
Posts: 61
Loc: Germany
|
As far as I know it runs ok on x64 systems but you might want to take a look at the setoption functions and the x64 options that are there (page 98 and 99 of the 4.61 manual). Wow64FileRedirection - Enables/disables file redirection on 64-bit editions of Windows. See this MSDN article for details of this feature. The default is ON. This option has no effect on 32-bit editions of Windows.
WOW64AlternateRegView - Enables access to the alternate view of the registry. See this MSDN article for details of this feature. The default is OFF. This option has no effect on 32-bit editions of Windows.
Ok but i think i mean a different thing:
Does my script with KIX32.exe starts or transmittet on my server or on the client directly?
My Clients are only 32 Bit And the Servers are after update all on 64 bit.
EDIT: So the question is: Does my Script run under the Client or under the server?
I hardly remember that it runs under the client right? Run Kix32.exe logon.kix
Edited by backfight (2010-11-11 01:09 PM)
|
Top
|
|
|
|
#200605 - 2010-11-13 09:40 AM
Re: Does my script runs under Windows 2k8 and 2k8 Active Directory?
[Re: Mart]
|
backfight
Getting the hang of it
Registered: 2007-01-22
Posts: 61
Loc: Germany
|
Can you help me to integrade 64bit clients?
I need a query that ask if it is a 32bit or 64bit client
and if it is a 64bit client then the client gets the 64bit driver from the 64bit printserver with the 64bit drivers for the printer
can i implement that in my script?
greetz Backfight
Edited by backfight (2010-11-13 09:41 AM)
|
Top
|
|
|
|
#200608 - 2010-11-13 02:39 PM
Re: Does my script runs under Windows 2k8 and 2k8 Active Directory?
[Re: Allen]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
and this is two pieces of code I've used in my scripts for various things when working in a mixed 32/64bit environment.
? @producttype + " " + iif(@onwow64,"64","32") + "bit"
$programfilesx86=iif(@onwow64,"%programfiles(x86)%","%programfiles%")
? $programfilesx86
|
Top
|
|
|
|
#200615 - 2010-11-15 07:31 AM
Re: Does my script runs under Windows 2k8 and 2k8 Active Directory?
[Re: Allen]
|
backfight
Getting the hang of it
Registered: 2007-01-22
Posts: 61
Loc: Germany
|
Two things...
32bit Servers can host 64bit printer drivers and vice versa. The trick is making sure the drivers are named the same. I've found that when sites like HP release their drivers, they release the 32/64bit drivers in tandem. So I always download both and install both at the same time.
More recent versions of kix support the @onwow64 macro to determine 32 or 64bit OS.
Thx for your reply
So do i have to install 2 printers with 1.)64bit and 2.) 32bit
or 1 printer with 32 and 64bit?
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 329 anonymous users online.
|
|
|