Results 1 to 24 of 24

Thread: Classic VB/WMI - How Do I Run a Process On a Remote System?

Threaded View

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Arrow 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.

    VB Code:
    1. Option Explicit
    2. 'Copyright © 2005 by RobDog888 (VB/Office Guru™). All Rights reserved.
    3. '
    4. 'Distribution: You can freely use this code in your own
    5. '              applications provided that this copyright
    6. '              is left unchanged, but you may not reproduce
    7. '              or publish this code on any web site, online
    8. '              service, or distribute as source on any
    9. '              media without express permission.
    10. '
    11. Private Sub Command1_Click()
    12.  
    13.     On Error Resume Next
    14.    
    15.     Dim oProcess As Object
    16.     Dim lProcessID As Long
    17.     Dim lRet As Long
    18.    
    19.     Set oProcess = GetObject("winmgmts:{impersonationLevel=impersonate}!\\MyServer\root\cimv2:Win32_Process")
    20.     'Or
    21.     'Set oProcess = GetObject("winmgmts:{impersonationLevel=impersonate}!\\MyServer.MyDomain.com\root\cimv2:Win32_Process")    
    22.     lRet = oProcess.Create("Notepad", Null, Null, lProcessID)
    23.     MsgBox "Method returned result: " & lRet & vbNewLine & "Id of new process: " & lProcessID, vbOKOnly + vbInformation
    24.  
    25. End Sub
    Gangsta Yoda™ ®
    Attached Files Attached Files
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width