myITforum.com Community Forum myITforum.com Community Forum

Home  Forums  Blogs  Live Support chat  Search Articles  Wiki  FAQ  Email Lists  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Photo Gallery  Member List  Search  Calendars  FAQ  Ticket List  Log Out

All Forums RSS Feed Subscription:


  


WMI Impersonation Question

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
  Printable Version
All Forums >> [Scripting Technologies] >> VB Script >> WMI Impersonation Question Page: [1]
Login
Message << Older Topic   Newer Topic >>
WMI Impersonation Question - 7/1/2003 9:06:53 AM   
rmorris

 

Posts: 55
Score: 0
Joined: 10/23/2001
Status: offline
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
*****

_____________________________

Rob
Post #: 1
RE: WMI Impersonation Question - 7/1/2003 1:13:35 PM   
ggreen681


Posts: 53
Score: 3
Joined: 9/24/2001
From: Cleveland, OH
Status: offline
Does the profile look like boxes or some type of weird character set?

_____________________________

You mean that was a PRODUCTION server?!

(in reply to rmorris)
Post #: 2
RE: WMI Impersonation Question - 7/1/2003 1:20:19 PM   
rmorris

 

Posts: 55
Score: 0
Joined: 10/23/2001
Status: offline
It sure does.


_____________________________

Rob

(in reply to rmorris)
Post #: 3
RE: WMI Impersonation Question - 7/1/2003 1:58:23 PM   
ggreen681


Posts: 53
Score: 3
Joined: 9/24/2001
From: Cleveland, OH
Status: offline
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.

_____________________________

You mean that was a PRODUCTION server?!

(in reply to rmorris)
Post #: 4
RE: WMI Impersonation Question - 7/1/2003 2:20:56 PM   
rmorris

 

Posts: 55
Score: 0
Joined: 10/23/2001
Status: offline
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.

_____________________________

Rob

(in reply to rmorris)
Post #: 5
RE: WMI Impersonation Question - 7/1/2003 2:36:15 PM   
ggreen681


Posts: 53
Score: 3
Joined: 9/24/2001
From: Cleveland, OH
Status: offline
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?

_____________________________

You mean that was a PRODUCTION server?!

(in reply to rmorris)
Post #: 6
RE: WMI Impersonation Question - 7/3/2003 7:44:21 AM   
rmorris

 

Posts: 55
Score: 0
Joined: 10/23/2001
Status: offline
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.

_____________________________

Rob

(in reply to rmorris)
Post #: 7
RE: RE: WMI Impersonation Question - 7/3/2003 7:47:44 AM   
gramsey
")

Posts: 296
Score: 31
Joined: 10/16/2002
From: Austin, TX
Status: offline
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"


(in reply to rmorris)
Post #: 8
RE: WMI Impersonation Question - 7/3/2003 8:23:15 AM  1 votes
ehoush


Posts: 484
Score: 58
Joined: 11/15/2002
Status: offline
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.



_____________________________

-Evan

Please rate my post so I look smart.

The only difference between you and me is I KNOW that I don' t know anything.

(in reply to rmorris)
Post #: 9
RE: WMI Impersonation Question - 7/3/2003 8:34:36 AM   
rmorris

 

Posts: 55
Score: 0
Joined: 10/23/2001
Status: offline
Sounds good to me. I' m glad I' m not the only one experiencing the issue.

_____________________________

Rob

(in reply to rmorris)
Post #: 10
RE: WMI Impersonation Question - 7/9/2003 7:17:11 AM   
ggreen681


Posts: 53
Score: 3
Joined: 9/24/2001
From: Cleveland, OH
Status: offline
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

_____________________________

You mean that was a PRODUCTION server?!

(in reply to rmorris)
Post #: 11
RE: WMI Impersonation Question - 7/9/2003 7:21:13 AM   
rmorris

 

Posts: 55
Score: 0
Joined: 10/23/2001
Status: offline
Thanks. I' ll try it out.

_____________________________

Rob

(in reply to rmorris)
Post #: 12
RE: RE: WMI Impersonation Question - 7/25/2003 6:57:33 AM   
mmathan

 

Posts: 84
Score: 0
Joined: 6/6/2001
Status: offline
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

(in reply to rmorris)
Post #: 13
RE: WMI Impersonation Question - 7/25/2003 7:04:59 AM   
rmorris

 

Posts: 55
Score: 0
Joined: 10/23/2001
Status: offline
Thanks Manohar. I will get it from PSS.

_____________________________

Rob

(in reply to rmorris)
Post #: 14
RE: WMI Impersonation Question - 8/22/2008 12:29:40 AM  1 votes
janebush08

 

Posts: 3
Score: -2
Joined: 8/22/2008
Status: offline
Thanks fo the link  Manohar... 

_____________________________

Microsoft CRM

(in reply to rmorris)
Post #: 15
Page:   [1]
All Forums >> [Scripting Technologies] >> VB Script >> WMI Impersonation Question Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts



  
Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.469