This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Detect Logged in Users
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 12, 2009
11:48 AM
Detect Logged in Users
Does anyone know how to detect the users logged into Windows? I can only have the current user user logged in and need to display a message to log all other users out (if I detect more than one is logged in).
If there's a default installscript action that would be great but I could just as easily use a windows function in my installscript.
Thanks!
If there's a default installscript action that would be great but I could just as easily use a windows function in my installscript.
Thanks!
(2) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 14, 2009
09:19 AM
Anyone??? I have a vbscript that I found that I could create a custom action with, but it only seems to detect the person that is logged on currently, not all users on the windows machine.
Option Explicit
Dim objWMIService, objComputer, colComputer, strComputer, counter
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
counter = counter + 1
Wscript.Echo objComputer.UserName & " is logged on"
Wscript.Echo counter & " is the number of users I found"
Next
Option Explicit
Dim objWMIService, objComputer, colComputer, strComputer, counter
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
counter = counter + 1
Wscript.Echo objComputer.UserName & " is logged on"
Wscript.Echo counter & " is the number of users I found"
Next
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 14, 2009
01:56 PM
thanks for nothing 🙂
well in case anyone was wondering...here's what i found and it seems to do the trick. check your LogonType here: http://msdn.microsoft.com/en-us/library/aa394189(VS.85).aspx or remove it all together (remove 'Where LogonType = 2' if you want all logged on users)
Option Explicit
Dim objWMIService, objComputer, colComputer, strComputer, numUsers
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery("Select * from Win32_LogonSession Where LogonType = 2")
For Each objComputer in colComputer
numUsers = numUsers + 1
'Wscript.Echo "LogonId: " & objComputer.LogonId & VbCr _
' & "Name: " & objComputer.Name & VbCr _
' & "LogonType: " & objComputer.LogonType & VbCr _
' & "Description: " & objComputer.Description & VbCr _
' & "Description: " & objComputer.Description & VbCr _
' & "Status: " & objComputer.Status
Next
Wscript.Echo numUsers
well in case anyone was wondering...here's what i found and it seems to do the trick. check your LogonType here: http://msdn.microsoft.com/en-us/library/aa394189(VS.85).aspx or remove it all together (remove 'Where LogonType = 2' if you want all logged on users)
Option Explicit
Dim objWMIService, objComputer, colComputer, strComputer, numUsers
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery("Select * from Win32_LogonSession Where LogonType = 2")
For Each objComputer in colComputer
numUsers = numUsers + 1
'Wscript.Echo "LogonId: " & objComputer.LogonId & VbCr _
' & "Name: " & objComputer.Name & VbCr _
' & "LogonType: " & objComputer.LogonType & VbCr _
' & "Description: " & objComputer.Description & VbCr _
' & "Description: " & objComputer.Description & VbCr _
' & "Status: " & objComputer.Status
Next
Wscript.Echo numUsers