getting process on a network pc
Hi guys,
I get the below from the other thread. now I get it working in my local computer, but i want is to get the process of the other computer. I know that it has the capability to do so but the problem is it can't get the processes on a computer that has a password. Kindly help please.
Thanks and God bless
ProcessID Code:
Option Explicit
Private Sub Form_Load()
Dim strComputer As String
Dim sReturn As String
Dim strNameOfUser As Variant
Dim colProcesses As Object
Dim objProcess As Object
strComputer = "." '"." local or "\\ComputerName"
Set colProcesses = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2").ExecQuery("Select * from Win32_Process")
For Each objProcess In colProcesses
sReturn = objProcess.GetOwner(strNameOfUser)
If sReturn <> 0 Then
MsgBox "Could not get owner info for process " & objProcess.Name & vbNewLine & "Error = " & sReturn
Else
MsgBox "Process " & objProcess.Name & " is owned by " & "\" & strNameOfUser & "."
End If
Next
End Sub
Re: getting process on a network pc
Have you tried feeding it the password?
Re: getting process on a network pc
No, sad say i don't kno how:( :blush:
Re: getting process on a network pc
If you don't know the password, then you shouldn't be accessing the machine in the first place.
Re: getting process on a network pc
i mean is i don't know how to feed the password through that code but i know the password of the pc. i have the access to the pc and i have the administrator account since we are on the development team. i just couldn't get the process on a pc with a password.
Re: getting process on a network pc
Re: getting process on a network pc
i am getting a dead end on this. Is it possible to suppy a password with the above code?
Re: getting process on a network pc
You need to have administrator permissions or it will fail.
See my CodeBank thread on the subject
http://vbforums.com/showthread.php?t=358108
Re: getting process on a network pc
so i need to log as administrator on my machine or is there anything i need to setup on the remote pc to give me an admistrator account?
Re: getting process on a network pc
You need to be in the Administraotrs group on your network.
Re: getting process on a network pc
sorry Rob for being a slow @%%, please bear with me.
now, with regards with the network, we do only have a simple workgroup. How can i set my account as administrator? The account of the pc that i am using is Adminstrator. now i tried to add an account to my remote pc and put the same password as on my pc but to no avail i always get permission denied.
Re: getting process on a network pc
No prob ;) I think with a workgroup it will be different as each computer doesnt know what accounts are on the other computers. You may need to create an administrator account on the other system with the same credientials as yours. Then it may carry over but not 100% sure.
Re: getting process on a network pc
will different os will be an issue? I am having a win2003 and the pc that i am trying to connect is xp. Now, what i did is i used the administrator account on my pc and changed its password with the password of the remote. but to no avail, i got the same error. thanks
Re: getting process on a network pc
Hmm, maybe its prefixed with the machine name.
user: \\somemachinename\administrator
pwd: *******
Re: getting process on a network pc
How will i put that on code|?
Re: getting process on a network pc
No, I was just stating that the two accounts may still be seen as different. There is no place for passing logon credentials with WMI in this code. I dont think its possible with a workgroup.
Re: getting process on a network pc
thanks rob, sad that i can't used it as of now. anyway your code is a beauty though.
Re: getting process on a network pc
Thanks but dont give up searching as I may be wrong, it happens from time to time :D.