WMI Impersonation Question (Full Version)

All Forums >> [Scripting Technologies] >> VB Script



Message


rmorris -> WMI Impersonation Question (7/1/2003 9:06:53 AM)

I have been using VB Scripts and WMI Impersonation to connect to workstations to obtain information and perform tasks. I noticed that an unusual profile gets created on every workstation that I connect to. Is there something in my code that is incorrect or anyway to prevent this from occurring? Any assistance would be greatly appreciated. Thanks.

*****
Const ForReading = 1
Const ForWriting = 2

On Error Resume Next

Dim objXL
Set objXL = WScript.CreateObject(" Excel.Application" )

objXL.Visible = TRUE

objXL.WorkBooks.Add

objXL.Columns(1).ColumnWidth = 20
objXL.Columns(2).ColumnWidth = 45

objXL.Cells(1, 1).Value = " Workstation Name"
objXL.Cells(1, 2).Value = " MDAC Version"

objXL.Range(" A1:B1" ).Select
objXL.Selection.Font.Bold = True
objXL.Selection.Interior.ColorIndex = 9
objXL.Selection.Interior.Pattern = 1 ' xlSolid
objXL.Selection.Font.ColorIndex = 2

objXL.Columns(" B:B" ).Select
objXL.Selection.HorizontalAlignment = &hFFFFEFDD ' xlLeft

Dim intIndex
intIndex = 2


Dim strComputer, strValue
Dim lRC1, lRC2, lRC3
Dim sPath1
Dim oArgs
Dim IEVer, IEPatch
Dim objSystemSet, objSystem
Dim strInputFileName, strOutputFileName

strInputFileName = InputBox(" Enter the name of the text file with the list of computers" )

strInputFileName = objArgs(0)
strOutputFileName = objArgs(1)

Dim objFSO, objInputFile, objOutputFile
Set objFSO = CREATEOBJECT(" Scripting.FileSystemObject" )
Set objInputFile = objFSO.OpenTextFile(strInputFileName,ForReading,False)
Set objOutputFile = objFSO.OpenTextFile(strOutputFileName,ForWriting,True)

Const HKEY_LOCAL_MACHINE = &H80000002
While Not objInputFile.AtEndOfStream
strOutput = " "
strComputer = Trim(objInputFile.Readline)
Err.Number = 0
Set oReg=GetObject(" winmgmts:\\" & strComputer & " \root\default:StdRegProv" )

If Err.Number <> 0 Then
' WScript.Echo " Error Number is " & Err.Number & " connecting to " & strComputer
strValue = " Could not access Registry Provider"
Call Show
Else
sPath1 = " SOFTWARE\Microsoft\DataAccess"
lRC1 = oReg.GetStringValue(HKEY_LOCAL_MACHINE, sPath1, " FullInstallVer" , oVer)
If (lRC1 = 0) Then
strOutput = strOutput & strComputer & vbTab & oVer & " 1"
' WScript.Echo strOutput
strValue = oVer
Call Show
Else
strOutput = strOutput & strComputer & vbTab & " 4"
' WScript.Echo strOutput
strValue = " Can' t determine version from registry"
Call Show
End If

End If
Wend

Sub Show
objXL.Cells(intIndex, 1).Value = strComputer
objXL.Cells(intIndex, 2).Value = strValue
intIndex = intIndex + 1
objXL.Cells(intIndex, 1).Select
End Sub

WScript.Quit
*****




ggreen681 -> RE: WMI Impersonation Question (7/1/2003 1:13:35 PM)

Does the profile look like boxes or some type of weird character set?




rmorris -> RE: WMI Impersonation Question (7/1/2003 1:20:19 PM)

It sure does.




ggreen681 -> RE: WMI Impersonation Question (7/1/2003 1:58:23 PM)

I have seen this also, but I could never put my finger on it. Let' s try this test. Hopefully you have a Win2K Pro box to test on.

1. Get a clean machine that you have NEVER logged onto.
2. Run your script logged on under your user account
3. Check and see if the profile is created

I hope you have a machine that you have never logged onto because I think this is key to a solution.




rmorris -> RE: WMI Impersonation Question (7/1/2003 2:20:56 PM)

I ran the script from my production workstation to obtain the MDAC information on a newly built Windows 2000 Professional test workstation that has never been logged into. The unusual profile showed up on the test workstation. Is that what you wanted me to do? If not, I have plenty of other test workstations at my disposal to run additional tests. Please let me know either way. Thanks.




ggreen681 -> RE: WMI Impersonation Question (7/1/2003 2:36:15 PM)

Yes, this is exactly what I wanted you to do. I am not sure but I think there is a bug when accessing the registry remotely on machines you have never logged onto. I think if we try this same test again with a machine that you have logged onto successfully you will not see the issue because you have a good profile already on that machine. You can try that and let everyone know the results

Also, did you know that if you hit ' Cancel' instead of entering a file name that your script enters an infinite loop?




rmorris -> RE: WMI Impersonation Question (7/3/2003 7:44:21 AM)

Correct. If I already have a profile on the workstation it doesn' t create the unusual profile. However, I noticed that if I log onto the workstation that has the unusual profile for my userid for the first time, there are issues with that profile. That really isn' t a big deal since I don' t log onto that many remote workstations. I just wanted to verify that the unusual profiles don' t have a negative effect on the workstation. Is there a good way to clean them from the workstation? I imagine there would be an issue since they have the unusual name.

Thanks again for the feedback. I' m just glad that I' m not the only one with the unusual profile issue.




gramsey -> RE: RE: WMI Impersonation Question (7/3/2003 7:47:44 AM)

Just to add to the mix, I see the same issue as well in my environment. I also see files in %system32% that look something like this " 뻈źcurity=impersonation dynamic false"





ehoush -> RE: WMI Impersonation Question (7/3/2003 8:23:15 AM)

This is a bug Uh Uh I mean feature with WMI..... The WMI team is working on a solution. It does not harm anything, it' s just ugly.





rmorris -> RE: WMI Impersonation Question (7/3/2003 8:34:36 AM)

Sounds good to me. I' m glad I' m not the only one experiencing the issue.




ggreen681 -> RE: WMI Impersonation Question (7/9/2003 7:17:11 AM)

Sorry it took so long to respond but I was out for a couple of days. Anyway here is a workaround that I intend to use in my environment. Connect to the PC using the local administrator account. In my environment that account is on 99% of all our desktops so I just use that account to connect. I have highlighted the changes I made to your script.


Const ForReading = 1
Const ForWriting = 2

On Error Resume Next

Dim objXL
Set objXL = WScript.CreateObject(" Excel.Application" )

objXL.Visible = TRUE

objXL.WorkBooks.Add

objXL.Columns(1).ColumnWidth = 20
objXL.Columns(2).ColumnWidth = 45

objXL.Cells(1, 1).Value = " Workstation Name"
objXL.Cells(1, 2).Value = " MDAC Version"

objXL.Range(" A1:B1" ).Select
objXL.Selection.Font.Bold = True
objXL.Selection.Interior.ColorIndex = 9
objXL.Selection.Interior.Pattern = 1 ' xlSolid
objXL.Selection.Font.ColorIndex = 2

objXL.Columns(" B:B" ).Select
objXL.Selection.HorizontalAlignment = &hFFFFEFDD ' xlLeft

Dim intIndex
intIndex = 2


Dim strComputer, strValue
Dim lRC1, lRC2, lRC3
Dim sPath1
Dim oArgs
Dim IEVer, IEPatch
Dim objSystemSet, objSystem
Dim strInputFileName, strOutputFileName

strInputFileName = InputBox(" Enter the name of the text file with the list of computers" )

strInputFileName = objArgs(0)
strOutputFileName = objArgs(1)

Dim objFSO, objInputFile, objOutputFile
Set objFSO = CREATEOBJECT(" Scripting.FileSystemObject" )
Set objInputFile = objFSO.OpenTextFile(strInputFileName,ForReading,False)
Set objOutputFile = objFSO.OpenTextFile(strOutputFileName,ForWriting,True)

Const HKEY_LOCAL_MACHINE = &H80000002
While Not objInputFile.AtEndOfStream
strOutput = " "
strComputer = Trim(objInputFile.Readline)
Err.Number = 0

Set oServices = WScript.CreateObject(" WbemScripting.SWbemLocator" )
Set oConn = oServices.ConnectServer(strComputer, " root\default" , _
strComputer & " \Administrator" , " Password Here" )
Set oReg = oConn.Get(" StdRegProv" )


If Err.Number <> 0 Then
' WScript.Echo " Error Number is " & Err.Number & " connecting to " & strComputer
strValue = " Could not access Registry Provider"
Call Show
Else
sPath1 = " SOFTWARE\Microsoft\DataAccess"
lRC1 = oReg.GetStringValue(HKEY_LOCAL_MACHINE, sPath1, " FullInstallVer" , oVer)
If (lRC1 = 0) Then
strOutput = strOutput & strComputer & vbTab & oVer & " 1"
' WScript.Echo strOutput
strValue = oVer
Call Show
Else
strOutput = strOutput & strComputer & vbTab & " 4"
' WScript.Echo strOutput
strValue = " Can' t determine version from registry"
Call Show
End If

End If
Wend

Sub Show
objXL.Cells(intIndex, 1).Value = strComputer
objXL.Cells(intIndex, 2).Value = strValue
intIndex = intIndex + 1
objXL.Cells(intIndex, 1).Select
End Sub

WScript.Quit




rmorris -> RE: WMI Impersonation Question (7/9/2003 7:21:13 AM)

Thanks. I' ll try it out.




mmathan -> RE: RE: WMI Impersonation Question (7/25/2003 6:57:33 AM)

MS Has released a fix for the " profile with Boxes" that is created when remotely managing a computer using WMI.

http://support.microsoft.com/default.aspx?kbid=816740

Manohar Mathan




rmorris -> RE: WMI Impersonation Question (7/25/2003 7:04:59 AM)

Thanks Manohar. I will get it from PSS.




janebush08 -> RE: WMI Impersonation Question (8/22/2008 12:29:40 AM)

Thanks fo the link  Manohar... 




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.25