RE: This script wont run on a workgroup server
- From: "Shane Roberts" <ShaneRoberts@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 28 Sep 2005 14:21:07 -0700
Figured it out. I removed the Getobject and entered the following into the
script;
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer( strComputer, "Root\Default",
strUser, strPassword )
objService.Security_.impersonationlevel = WbemAuthenticationLevelPktPrivacy
Set objRegistry = objService.Get( "StdRegProv" )
"Shane Roberts" wrote:
> I have this script that I use on domain member servers and it runs just fine.
> Using input it gathers username, password and computername, goes to server
> and reads the registry for all installed software, then creates a folder and
> time/date stamped filename into the folder dumps it into a formatted Excel
> spread***. Works great, but I have two dozen DMZ servers that are not
> domain members and workgroup only. It cannot access the registry. If I use
> RUNAS to initiate the script it works, but without RUNAS it doesnt. Looks
> like a problem authenticating as the local user account I am connecting as.
> Any thoughts how I can fix the script to provide this without using RUNAS?
> Script is below (yes, I need to clean it up, I know, I'm a noob)
>
>
> On Error Resume Next
> Const WbemAuthenticationLevelPktPrivacy = 6
>
> Function Fixnumber(Value, Length)
> Const Zeros = "0000"
> If (Length-Len(Value) > 0) Then
> FixNumber = Left(Zeros, Length-Len(Value)) & value
> Else
> Fixnumber = value
> End If
> End Function
>
>
> Set objExplorer = WScript.CreateObject ("InternetExplorer.Application", "IE_")
>
> objExplorer.Navigate "file:///E:\DMZ_Servers.htm"
>
> objExplorer.Document.Title = ""
> objExplorer.ToolBar = 0
> objExplorer.StatusBar = 0
> objExplorer.menubar= 0
> objExplorer.addressbar= 0
> objExplorer.Width = 825
> objExplorer.Height = 750
> objExplorer.Visible = 1
> Do While (objExplorer.Document.Body.All.OKClicked.Value = "")
> WScript.Sleep 250
> Loop
>
> strUser = objExplorer.Document.Body.All.UserName.Value
> strPassword = objExplorer.Document.Body.All.UserPassword.Value
> strComputer = objExplorer.Document.Body.All.OKClicked.Value
> objExplorer.Quit
> WScript.Sleep 350
>
>
> If strComputer = "Cancelled" Then
> WScript.Quit
> End If
>
>
> arrComputers = Split(strComputer, ",")
> For Each strComputer In arrComputers
>
> Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
> Set objWMIService = objwbemLocator.ConnectServer (strComputer, strNamespace,
> strUser, strPassword)
> objWMIService.Security_.authenticationLevel =
> WbemAuthenticationLevelPktPrivacy
>
>
> strPath = ("E:\" & strComputer)
> CurDate = Day(Now) & "-" & MonthName(Month(Now),True) & "-" & Year(Now) &
> "_at_" & FixNumber(Hour(Time),2) & FixNumber(Minute(Time),2)
> SaveAsName = (strPath & "\" & "Applications_Installed_" & "on_" &
> strComputer & "_as_of_" & CurDate & ".xls")
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> If objFSO.FolderExists(strPath & "\" & strComputer) Then
> Else
>
> Set strFolder = objFSO.CreateFolder(strPath)
> End If
>
>
> Set objExcel = CreateObject("Excel.Application")
> objExcel.Workbooks.Add(1)
> objExcel.Visible = False
> Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
> obj***.Name = "Applications Installed"
> objExcel.DisplayAlerts = False
> objExcel.Columns("A:D").Select
> objExcel.Selection.HorizontalAlignment = &hFFFFEFDD ' xlLeft
> objExcel.Rows(2).Select
> objExcel.ActiveWindow.FreezePanes = True
>
> x = 2
> objExcel.Cells(1, 1).value = "Registry Name"
> objExcel.Cells(1, 2).value = "DISPLAY NAME"
> objExcel.Cells(1, 3).value = "VERSION"
> objExcel.Cells(1, 4).value = "INSTALL PATH"
> objExcel.Range("A1:D1").Select
> objExcel.Selection.Font.Bold = True
> objExcel.Selection.Font.Size = 10
> objExcel.Selection.Font.ColorIndex = 1
> objExcel.Selection.Interior.ColorIndex = 6
>
>
> Dim strComputer, strKey, strSubKey
> Dim objRegistry
> Dim arrSubKeys()
> Dim strDisplayName, strDisplayVersion, strInstallLocation
> Const HKEY_LOCAL_MACHINE = &H80000002
>
> strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
>
> Set objRegistry = GetObject("winmgmts:\\" & strComputer &
> "\root\default:StdRegProv")
> objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
>
>
> For Each strSubKey In arrSubKeys
> objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey,
> "DisplayName", strDisplayName
> objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey,
> "DisplayVersion", strDisplayVersion
> objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey,
> "InstallLocation", strInstallLocation
>
> objExcel.Cells(x, 1) = strSubKey
> objExcel.Cells(x, 2) = strDisplayName
> objExcel.Cells(x, 3) = strDisplayVersion
> objExcel.Cells(x, 4) = strInstallLocation
>
> strDisplayName = vbEmpty
> strDisplayVersion = vbEmpty
> strInstallLocation = vbEmpty
>
> x = x + 1
>
> Next
>
>
> Set objRange = objExcel.Range("A1")
> objRange.Activate
> Set objRange = objExcel.ActiveCell.EntireColumn
> objRange.AutoFit()
> Set objRange = objExcel.Range("B1")
> objRange.Activate
> Set objRange = objExcel.ActiveCell.EntireColumn
> objRange.AutoFit()
> Set objRange = objExcel.Range("C1")
> objRange.Activate
> Set objRange = objExcel.ActiveCell.EntireColumn
> objRange.AutoFit()
> Set objRange = objExcel.Range("D1")
> objRange.Activate
> Set objRange = objExcel.ActiveCell.EntireColumn
> objRange.AutoFit()
>
>
> obj***.SaveAs SaveAsName
> obj***.Close
> objExcel.Quit
>
> Next
>
>
> WScript.Echo "Information Retrieval Complete"
> WScript.Quit
>
>
>
.
- References:
- This script wont run on a workgroup server
- From: Shane Roberts
- This script wont run on a workgroup server
- Prev by Date: Re: download an entire directory with a ftp script
- Next by Date: Re: Change DNS ip configuration through script
- Previous by thread: This script wont run on a workgroup server
- Next by thread: Re: find specific files on users' hard drives
- Index(es):