Hi all!!
I have created a script that tells a user who's running a special process, the problem is that it only works for one user and not both.
Problem:
User Testadmin is an administrator and user testuser is an regular user.
When user testadmin runs the script an starts process ct8.exe and then user testuser runs the script it works and tells user that testadmin is using the terminal, but if testuser runs the script and starts process ct8.exe and then testadmin runs the script the field for StrNameOfUser is empty i the msgbox.
This is very confusing for me because the user can see the admin process, but the admin cannot see the user process.
What is wrong??
Script:
Option Explicit
Dim objLogon
Set objLogon = CreateObject("LoginAdmin.ImpersonateUser")
objLogon.Logon "custuser", "cust123", "."
Dim strComputer
Dim objWMIService
Dim colProcessList
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = " & "'ct8.exe'")
If colProcessList.Count = 0 Then
MsgBox "Terminal 8 is avaliable, press OK to connect." ,, "Kundterminal"
objLogon.Logoff
Set objLogon = Nothing
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
objWMIService.Create("C:\Program Files\Customers\ct8.exe vmrc://XX.XX.XX.XX:5900/Custterm8")
Else
Dim objProcess
Dim strNameOfUser
Dim colProperties
For Each objProcess in colProcessList
colProperties = objProcess.GetOwner(strNameOfUser)
Wscript.Echo "Terminal is used by" & strNameOfUser & "."
Next
End If
I have created a script that tells a user who's running a special process, the problem is that it only works for one user and not both.
Problem:
User Testadmin is an administrator and user testuser is an regular user.
When user testadmin runs the script an starts process ct8.exe and then user testuser runs the script it works and tells user that testadmin is using the terminal, but if testuser runs the script and starts process ct8.exe and then testadmin runs the script the field for StrNameOfUser is empty i the msgbox.
This is very confusing for me because the user can see the admin process, but the admin cannot see the user process.
What is wrong??
Script:
Option Explicit
Dim objLogon
Set objLogon = CreateObject("LoginAdmin.ImpersonateUser")
objLogon.Logon "custuser", "cust123", "."
Dim strComputer
Dim objWMIService
Dim colProcessList
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = " & "'ct8.exe'")
If colProcessList.Count = 0 Then
MsgBox "Terminal 8 is avaliable, press OK to connect." ,, "Kundterminal"
objLogon.Logoff
Set objLogon = Nothing
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
objWMIService.Create("C:\Program Files\Customers\ct8.exe vmrc://XX.XX.XX.XX:5900/Custterm8")
Else
Dim objProcess
Dim strNameOfUser
Dim colProperties
For Each objProcess in colProcessList
colProperties = objProcess.GetOwner(strNameOfUser)
Wscript.Echo "Terminal is used by" & strNameOfUser & "."
Next
End If