Hi,
I downloaded the script script_149.kix(Add Computer Info to Registry) from the AdminScriptEditor.com web site in order to extract S/N, Model, constructor .
I modified the script in order to test the presence of a file to determine wether lotus is installed or not on the remote machine (I can also by the way identify the version).
The problem is that the file I want to test is not located in a shared directory, then how to test his presence???
In my opinion the test should look like
IF EXIST ("\\"+$computer+"\lotus\notes\data\desktop.dsk")
But I don't think this will work.
Here is the script I modified, the code to modify begin a line 52.
And the same tests are performed in the "Single" function.
Thank's for the answer.
Code:
;===================================
;**** Last Modified on 19/10/05 ****
;===================================
Break on
; the default skip is 6
$Skip = 6
$Count = $skip
$Count2 = 1
$Answer = MessageBox("Do you want to manually update one at a time?","How do you want to update?",4)
If $Answer = 6
$RC = single()
Exit
EndIf
For Each $machine in netview("@LDOMAIN")
? "$MACHINE"
$Count = $Count + 1
$computer = $machine
$Comp = ""
$Model= ""
$Sernum =""
$Cpu = ""
$Mem = ""
$Computer2 = "\\"+$computer
$Found=0
$LOTUSVER="NO LOTUS INSTALLED"
ReDim $MEM2,$DIMM
If KeyExist($Computer2 + "\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions")
$REG = ReadValue ($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE","SerialNumber")
If $REG = ""
$Sernum = Rtrim(WMIQuery("SerialNumber","Win32_BIOS"))
$SERNUM = CHECKREG($SERNUM,"SerialNumber")
$Comp = Rtrim(WMIQuery("Manufacturer","Win32_ComputerSystem"))
$Comp = CHECKREG($COMP,"MANUFACTURER")
$Model = Rtrim(WMIQuery("Model","Win32_ComputerSystem"))
$Model = CHECKREG($MODEL,"MODEL")
$CPU = Rtrim(WMIQuery("CurrentClockSpeed","Win32_Processor"))
$CPU = checkREG($CPU,"CurrentClockSpeed")
$Mem = Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024
$MEM = CHECKREG($MEM,"TotalPhysicalMemory")
$smbios = Rtrim(WMIQuery("SMBIOSBIOSVersion","Win32_BIOS"))
$Smbiosdate = Rtrim(WMIQuery("Version","Win32_BIOS"))
$Modem = Rtrim(WMIQuery("Description","Win32_POTSModem"))
$Mem2 = Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024
For Each $dimm in Split(WMIQuery("Capacity","Win32_PhysicalMemory"),"|")
$MEM2 = "" + $MEM2 + "|" + Ucase(Val($dimm) / 1048576)
Next
IF EXIST ("c:\notes\data\desktop5.dsk")
$LOTUSVER="LOTUS V 5"
$Found=1
ENDIF
IF EXIST ("c:\notes\data\desktop.dsk") and $Found=1
ELSE
IF EXIST ("c:\notes\data\desktop.dsk") and $Found=0
$LOTUSVER="LOTUS V 4.6"
ENDIF
ENDIF
IF EXIST ("c:\lotus\notes\data\desktop5.dsk")
$LOTUSVER="LOTUS V 5"
$Found=1
ENDIF
IF EXIST ("c:\lotus\notes\data\desktop.dsk") and $Found=1
ELSE
IF EXIST ("c:\lotus\notes\data\desktop.dsk") and $Found=0
$LOTUSVER="LOTUS V 4.6"
ENDIF
ENDIF
$x = loginfo("c:\COMINFO.txt","@DATE @TIME,$count,$Machine,$Comp,$Model,$Sernum,$Cpu Mhz,$Mem MB,$MEM2 MB,$SMBIOS,$SMBIOSDATE,$MODEM,$LOTUSVER")
$count2 = $count2 + 1
"....DONE at @TIME"
EndIf
EndIf
:out
Next
Exit 1
Function Single()
;For single machines make sure you rem out the For Each AND unrem the Six below.
? "Machine name? " Gets $machine
While $machine <> "Exit"
$computer = $machine
$Comp = ""
$Model= ""
$Sernum =""
$Cpu = ""
$Mem = ""
$Computer2 = "\\"+$computer
$Found=0
$LOTUSVER="NO LOTUS INSTALLED"
Shell '%comspec% /c ping -n 2 "$Machine" | find /i "ttl" >nul 2>nul'
If NOT @ERROR
ReDim $MEM2,$DIMM
"$Count, "
$Sernum = Rtrim(WMIQuery("SerialNumber","Win32_BIOS"))
$SERNUM = CHECKREG($SERNUM,"SerialNumber")
"A, "
$Comp = Rtrim(WMIQuery("Manufacturer","Win32_ComputerSystem"))
$Comp = CHECKREG($COMP,"MANUFACTURER")
"B, "
$Model = Rtrim(WMIQuery("Model","Win32_ComputerSystem"))
$Model = CHECKREG($MODEL,"MODEL")
"C, "
$CPU = Rtrim(WMIQuery("CurrentClockSpeed","Win32_Processor"))
$CPU = checkREG($CPU,"CurrentClockSpeed")
"D, "
$Mem = Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024
$MEM = CHECKREG($MEM,"TotalPhysicalMemory")
"E, "
$smbios = Rtrim(WMIQuery("SMBIOSBIOSVersion","Win32_BIOS"))
"F, "
$Smbiosdate = Rtrim(WMIQuery("Version","Win32_BIOS"))
"G, "
$Modem = Rtrim(WMIQuery("Description","Win32_POTSModem"))
"H, "
$Mem2 = Val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024
For Each $dimm in Split(WMIQuery("Capacity","Win32_PhysicalMemory"),"|")
$MEM2 = "" + $MEM2 + "|" + Ucase(Val($dimm) / 1048576)
Next
IF EXIST ("c:\notes\data\desktop5.dsk")
$LOTUSVER="LOTUS V 5"
$Found=1
ENDIF
IF EXIST ("c:\notes\data\desktop.dsk") and $Found=1
ELSE
IF EXIST ("c:\notes\data\desktop.dsk") and $Found=0
$LOTUSVER="LOTUS V 4.6"
ENDIF
ENDIF
IF EXIST ("c:\lotus\notes\data\desktop5.dsk")
$LOTUSVER="LOTUS V 5"
$Found=1
ENDIF
IF EXIST ("c:\lotus\notes\data\desktop.dsk") and $Found=1
ELSE
IF EXIST ("c:\lotus\notes\data\desktop.dsk") and $Found=0
$LOTUSVER="LOTUS V 4.6"
ENDIF
ENDIF
"End."
$x = loginfo("c:\COMINFO.txt","@DATE @TIME,$count,$Machine,$Comp,$Model,$Sernum,$Cpu Mhz,$Mem MB,$MEM2 MB,$SMBIOS,$SMBIOSDATE,$MODEM,$LOTUSVER")
Else
? "Cannot find Computer"
EndIf
? "Machine name? "
Gets $machine
Loop
Exit
EndFunction
;Used to make login script log files.
;Example LogInfo("\\server\log$\VERSION.LOG","@DATE @TIME,@WKSTA,@USERID,$Macver,$regver,$engver")
Function LOGINFO($FILE,$STRING)
$junk = ReDirectOutput($file)
$string ?
$junk = ReDirectOutput("")
EndFunction
Function CHECKREG($VALUE,$WHERE)
$REG = ReadValue ($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE", "$WHERE")
If $value = " " OR Len($Value) = 0
$Checkreg = $reg
Else
If NOT KeyExist($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE")
$ReturnCode = AddKey($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE")
EndIf
$X = WriteValue ($Computer2 + "\HKEY_LOCAL_MACHINE\SOFTWARE\CWOPA\MACHINE", "$WHERE","$value","REG_SZ")
$CHECKREG = $VALUE
EndIf
Return
EndFunction
Function WMIQuery($what,$where,)
Dim $strQuery, $objEnumerator, $value
$strQuery = "Select $what From $where"
$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//$computer")
If VarType($systemSet) <> 9 AND @error <> 0 Exit(@error) EndIf
$objEnumerator = $SystemSet.ExecQuery($strQuery)
For Each $objInstance in $objEnumerator
;If @Error = 0 AND $objInstance <> ""
$junk=Execute("$$value = $$objInstance.$what")
$WMIQuery="$value"+"|"+"$WMIQuery"
;EndIf
Next
$WMIQuery=Left($WMIQuery,Len($WMIQuery)-1)
$Systemset = nothing
Exit @error
EndFunction
Function netview(optional $domain)
Dim $array[255]
Dim $ReDim $ReDim = 255
Dim $i $i = 0
Dim $j $j = 0
Dim $tempfile $tempfile = "%temp%\netview2.tmp"
If $domain
$domain = "/domain:$domain"
EndIf
If Exist("$tempfile")
Del "$tempfile"
EndIf
Shell '%comspec% /c net view $domain >"$tempfile"'
If @error = 0
If Open(10,$tempfile) = 0
For $j = 1 to $Skip
$line = ReadLine(10) ; skip headings
Next
While @error = 0
$array[$i] = Rtrim(SubStr($line,3,InStr($line," ")-1))
$i=$i+1
If $i = $ReDim
$ReDim=$ReDim*2
ReDim preserve $array[$ReDim]
EndIf
$line = ReadLine(10)
Loop
$=Close(10)
Del "$tempfile"
If $i
ReDim preserve $array[$i-4]
$netview = $array
Exit @error
EndIf
EndIf
EndIf
$netview = 0
Exit @error
EndFunction