Login | |
|
 |
RE: about user logged out with "switch user" - 7/2/2007 2:53:40 AM
|
|
 |
|
| |
ebgreen
Posts: 5035
Score: 31
Joined: 7/12/2005
Status: online
|
Well, I do not have a solution for your problem but I can tell you why you have the problem. When you use "Switch User" the current user is not logged out so you would never see them as a logged out user.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: about user logged out with "switch user" - 7/2/2007 6:10:07 PM
|
|
 |
|
| |
whatwhatkit
Posts: 8
Score: 0
Joined: 7/2/2007
Status: offline
|
As I have said,I am new to VBS. I search from google and finally get something close to the answer. However,it return the process owner of ALL process! I made some changes and everything works fine,I have made the code returning only the owner of "explore.exe" and thus the user that are switched in the msgbox solution 1: return the process owner of ALL process in the msgbox (from: http://www.microsoft.com/technet/scriptcenter/guide/sas_prc_fywf.mspx?mfr=true ) strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery _ ("SELECT * FROM Win32_Process") For Each objProcess in colProcessList colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain) Wscript.Echo "Process " & objProcess.Name & " is owned by " _ & strUserDomain & "\" & strNameOfUser & "." Next solution 2: return only the owner of "explore.exe" and thus the user that are switched in the msgbox( modified from solution 1 by try and error^^) strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery _ ("SELECT * FROM Win32_Process") For Each objProcess in colProcessList colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain) if objProcess.Name = "explorer.exe" Then Wscript.Echo "Process " & objProcess.Name & " is owned by " _ & strUserDomain & "\" & strNameOfUser & "." end If Next Up to here, the problem can be considered to be solved. But, for my understanding, would someone explan the code to me? I know nearly nothing about the code, and my solution 2 seems doing a lot of unnessary thing. ^^ Thank you! p.s. Set colProcessList = objWMIService.ExecQuery _ ("SELECT * FROM Win32_Process") It seems that * is too much, I tried the code below and errors. Set colProcessList = objWMIService.ExecQuery _ ("SELECT "explore.exe" FROM Win32_Process"
< Message edited by whatwhatkit -- 7/2/2007 6:17:33 PM >
|
|
| |
|
|
|
 |
RE: about user logged out with "switch user" - 7/3/2007 3:45:36 AM
|
|
 |
|
| |
ebgreen
Posts: 5035
Score: 31
Joined: 7/12/2005
Status: online
|
What you get back from the query is a collection of items. The only way to do something with all of the items is to loop through doing it with each item in turn.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
|
|