Jeg har lagt filnavn.vbs på c:\ og man kan se på ikonet, at der er tilknyttet et program til filen. Når jeg åbner filnavn.vbs skriver den 'scriptprogrammet "VBScript" til scriptet "c:\filnavn.vbs" kunne ikke findes.'
'Hovedobjekter Dim WshShell, FSO, WshNetwork, WMIService
'Info fra Win32_OperatingSystem Dim sOSCaption, sCSDVersion, sOSLanguage, sVersion
'Info fra Win32_Bios Dim sSerialNumber
'Info fra Win32_ComputerSystem Dim sManufacturer, sModel
'Info fra Windows Installer Dim sMSIVersion, aMSIApps, aMSIAppInstDate
'Info fra registry om andre applikationer Dim aOtherApps
'Andre variabler Dim sServerName, sUserName, sTempPath
'Erklæringer Set WshShell = WScript.CreateObject("WScript.Shell") Set FSO = WScript.CreateObject("Scripting.FileSystemObject") Set WshNetwork = WScript.CreateObject("WScript.Network")
If CheckOS Then Set WMIService = GetObject("winmgmts:\\" & sServerName & "\root\cimv2") GetFileNames Set WMIService = Nothing Else WshShell.Popup "Dette værktøj kan kun benyttes på Windows 2000 eller senere.", 7, "Spiritech - Systeminfo", _ vbOKOnly + vbExclamation + vbSystemModal End If
'Oprydning Set WshNetwork = Nothing Set FSO = Nothing Set WshShell = Nothing
Function CheckOS Dim sOSVersion, sRegValue sOSVersion = WshShell.Environment("PROCESS")("OS") CheckOS = False If sOSVersion = "Windows_NT" Then sRegValue = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion") Select Case sRegValue Case "5.0" CheckOS = True Case "5.1" CheckOS = True End Select End If End Function
Sub GetFileNames Dim sFileName, iAnswer GetSystemInfo GetMSIApps GetOtherApps sFileName = sTempPath & sServerName & ".txt" If FSO.FileExists(sFileName) Then FSO.DeleteFile sFileName, True WriteToTDF sFileName ' WshShell.Run "notepad.exe " & sFileName, 1, True ' FSO.DeleteFile sFileName End Sub
Sub GetSystemInfo Dim oMember, i, iArraySize
Dim wmiOperatingSystemSet Set wmiOperatingSystemSet = WMIService.ExecQuery("select * from Win32_OperatingSystem") For Each oMember In wmiOperatingSystemSet With oMember sOSCaption = .Caption sCSDVersion = .CSDVersion If sCSDVersion = "" Then sCSDVersion = "Ingen" sOSLanguage = .OSLanguage Select Case sOSLanguage Case "1033" sOSLanguage = "English" Case "1030" sOSLanguage = "Dansk" Case Else sOSLanguage = "Unkendt!" End Select sVersion = .Version End With Next Set wmiOperatingSystemSet = Nothing
Dim wmiBiosSet Set wmiBiosSet = WMIService.ExecQuery("select * from Win32_Bios") For Each oMember In wmiBiosSet sSerialNumber = oMember.SerialNumber Next Set wmiBiosSet = Nothing
Dim wmiComputerSystemSet Set wmiComputerSystemSet = WMIService.ExecQuery("select * from Win32_ComputerSystem") For Each oMember In wmiComputerSystemSet With oMember sManufacturer = .Manufacturer sModel = .Model End With Next Set wmiComputerSystemSet = Nothing End Sub
Sub GetMSIApps Dim MSIObj, oProductSet, iArraySize, i, sProduct, k, l, sTemp Set MSIObj = Wscript.CreateObject("WindowsInstaller.Installer") If IsObject(MSIObj) Then sMSIVersion = MSIObj.Version Set oProductSet = MSIObj.Products iArraySize = oProductSet.Count - 1 ReDim aMSIApps(iArraySize) ReDim aMSIAppInstDate(iArraySize) i = 0 For Each sProduct In oProductSet aMSIApps(i) = MSIObj.ProductInfo(sProduct, "ProductName") sTemp = MSIObj.ProductInfo(sProduct, "InstallDate") aMSIAppInstDate(i) = Right(sTemp, 2) & "-" & Mid(sTemp, 5, 2) & "-" & Left(sTemp, 4) i = i + 1 Next For k = 0 To iArraySize - 1 For l = k + 1 To iArraySize If LCase(aMSIApps(l)) < LCase(aMSIApps(k)) Then sTemp = aMSIApps(l) aMSIApps(l) = aMSIApps(k) aMSIApps(k) = sTemp sTemp = aMSIAppInstDate(l) aMSIAppInstDate(l) = aMSIAppInstDate(k) aMSIAppInstDate(k) = sTemp End If Next Next Set oProductSet = Nothing Else sMSIVersion = "Ikke installeret" ReDim aMSIApps(0) aMSIApps(0) = "N/A" ReDim aMSIAppInstDate(0) aMSIAppInstDate(0) = "N/A" End If Set MSIObj = Nothing End Sub
Sub GetOtherApps Const sMainKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" Const hDefKey = &H80000002 Dim oRegistry, sKeys, i, j, k, l, bKeyOK, sVal1, sVal2, iArraySize, sTemp Set oRegistry = GetObject("winmgmts:\\" & sServerName & "\root\default:StdRegProv") If IsObject(oRegistry) Then oRegistry.EnumKey hDefKey, sMainKey, sKeys iArraySize = 0 If IsArray(sKeys) Then For i = 0 To UBound(sKeys) bKeyOK = True If Left(sKeys(i), 1) = "{" And Right(sKeys(i), 1) = "}" Then bKeyOK = False If Left(sKeys(i), 1) = "Q" And Len(sKeys(i)) = 7 Then bKeyOK = False If bKeyOK Then sVal1 = "HKEY_LOCAL_MACHINE\" & sMainKey & "\" & sKeys(i) & "\DisplayName" sVal2 = "HKEY_LOCAL_MACHINE\" & sMainKey & "\" & sKeys(i) & "\QuietDisplayName" If ExistValue(sVal1) Or ExistValue(sVal2) Then iArraySize = iArraySize + 1 End If Next iArraySize = iArraySize - 1 ReDim aOtherApps(iArraySize) j = 0 For i = 0 To UBound(sKeys) bKeyOK = True If Left(sKeys(i), 1) = "{" And Right(sKeys(i), 1) = "}" Then bKeyOK = False If Left(sKeys(i), 1) = "Q" And Len(sKeys(i)) = 7 Then bKeyOK = False If bKeyOK Then sVal1 = "HKEY_LOCAL_MACHINE\" & sMainKey & "\" & sKeys(i) & "\DisplayName" sVal2 = "HKEY_LOCAL_MACHINE\" & sMainKey & "\" & sKeys(i) & "\QuietDisplayName" If ExistValue(sVal1) Then aOtherApps(j) = WshShell.RegRead(sVal1) j = j + 1 ElseIf ExistValue(sVal2) Then aOtherApps(j) = WshShell.RegRead(sVal2) j = j + 1 End If End If Next For k = 0 To iArraySize - 1 For l = k + 1 To iArraySize If LCase(aOtherApps(l)) < LCase(aOtherApps(k)) Then sTemp = aOtherApps(l) aOtherApps(l) = aOtherApps(k) aOtherApps(k) = sTemp End If Next Next Else ReDim aOtherApps(0) aOtherApps(0) = "N/A" End If Else ReDim aOtherApps(0) aOtherApps(0) = "Kun tilgængelig i Windows 2000 eller senere" End If Set oRegistry = Nothing End Sub
Function ExistValue(value) Dim sVal On Error Resume Next sVal = WshShell.RegRead(value) If Err.Description = Empty Then ExistValue = True Else ExistValue = False End If End Function
Sub WriteToTDF(sFileName) Dim oTDFFile, i, iArraySize Set oTDFFile = FSO.OpenTextFile(sFileName, ForWriting, True)
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.