Classic VB/WMI - How Do I Run a Process On a Remote System?
Using VB and WMI you can run a process on any remote system on your network. The only requirements are that you have WMI on your system and you have Administrative prividgles on the remote system too.
When you run this you will get a return value of 0 for success and a process id which you can verify by logging into the remote system and looking in the task manager process' list.
Dear
Whether i should pass any values to the procedure given.
if not how does this connet to the server i need.
i tried with this code. iget 0.
can u briefly give me the solution.
my problem is to run the vb file exe in the remote server
from my system using vb code
regards
Nagarjuna
Private Sub Command1_Click()
On Error Resume Next
Dim oProcess As Object
Dim lProcessID As Long
Dim lRet As Long
Set oProcess = GetObject("winmgmts:{impersonationLevel=impersonate}!\\MyServer\root\cimv2:Win32_Process")
'Or
'Set oProcess = GetObject("winmgmts:{impersonationLevel=impersonate}!\\MyServer.MyDomain.com\root\cimv2:Win32_Proces s")
lRet = oProcess.Create("Notepad", Null, Null, lProcessID)
MsgBox "Method returned result: " & lRet & vbNewLine & "Id of new process: " & lProcessID, vbOKOnly + vbInformation
Re: Classic VB/WMI - How Do I Run a Process On a Remote System?
You need Administrator permissions on the remote system and no parameters needed to pass.
Change the "MyServer" part to the name of the remote system.
If its returning null then its not executing because of a few different reasons like no permissions, bad computer name, bad file path, etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Re: Classic VB/WMI - How Do I Run a Process On a Remote System?
I believe there is but I cant test it out as my system died and I'm on my server which doesnt have any form of VB on it. I'll post back when its reloaded or post here to remind me.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Re: Classic VB/WMI - How Do I Run a Process On a Remote System?
Originally Posted by RobDog888
I believe there is but I cant test it out as my system died and I'm on my server which doesnt have any form of VB on it. I'll post back when its reloaded or post here to remind me.
Ah, ok, what is this method called? I can look it up myself hopefully
Re: Classic VB/WMI - How Do I Run a Process On a Remote System?
I think its like this...
VB Code:
For each oProcess in GetObject("winmgmts:{impersonationLevel=impersonate}!//MyServer").ExecQuery("select * from Win32_Process where Name='notepad.exe'")
oProcess.Terminate
MsgBox Process.Name & " Terminated"
Next
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Re: Classic VB/WMI - How Do I Run a Process On a Remote System?
Originally Posted by RobDog888
I think its like this...
VB Code:
For each oProcess in GetObject("winmgmts:{impersonationLevel=impersonate}!//MyServer").ExecQuery("select * from Win32_Process where Name='notepad.exe'")
oProcess.Terminate
MsgBox Process.Name & " Terminated"
Next
Ack... all that time it was Terminate. I've tried exit, remove, delete, kill... the list is endless. When i'm back to my machine with a compiler i'll check it out. thanks RD
Re: Classic VB/WMI - How Do I Run a Process On a Remote System?
What type of process/app are you running? Maybe have to write another one to active the window. Then start one process and then start the other process that activates it?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Re: Classic VB/WMI - How Do I Run a Process On a Remote System?
Originally Posted by RobDog888
What type of process/app are you running? Maybe have to write another one to active the window. Then start one process and then start the other process that activates it?
I was trying to open Word actually, but in the end it will be a range of different programs, so i was hoping there was built in support actually.
Re: Classic VB/WMI - How Do I Run a Process On a Remote System?
Sorry, been real busy lately and havent been posting. I have my system up but no apps installed yet so over the weekend I should be able to try some things.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Re: Classic VB/WMI - How Do I Run a Process On a Remote System?
Originally Posted by RobDog888
Sorry, been real busy lately and havent been posting. I have my system up but no apps installed yet so over the weekend I should be able to try some things.
Thankyou RD. Looking forward to seeing what you manage to come up with (if its possible)
Re: Classic VB/WMI - How Do I Run a Process On a Remote System?
Originally Posted by RobDog888
[color=navy]Using VB and WMI you can run a process on any remote system on your network. The only requirements are that you have WMI on your system and you have Administrative prividgles on the remote system too.
How do I know whether WMI is installed in my system?
Re: Classic VB/WMI - How Do I Run a Process On a Remote System?
Hey Guys,
Cant seem to get this working:
Code:
On Error Resume Next
Dim oProcess As Object
Dim lProcessID As Long
Dim lRet As Long
Set oProcess = GetObject("winmgmts:{impersonationLevel=impersonate}!\\the_machine\root\cimv2:Win32_Process")
lRet = oProcess.Create("c:\share\1.zip", Null, Null, lProcessID)
MsgBox "Method returned result: " & lRet & vbNewLine & "Id of new process: " & lProcessID, vbOKOnly + vbInformation
If i just put in the file path "cmd" or "notepad" it work great but as soon as i change the path so somewhere outside the system32 dir it fails
Nothing is Impossible you say?......Try slamming a revolving door!