Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help with vbscript

Status
Not open for further replies.

Svanen

Technical User
Dec 15, 2004
10
SE
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

 
Forgot to say, the script works ok on a Windows 2003 server but not on this Windows 2000 server, and i need the script running on that server.

Thanks!

/Johan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top