Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. InvokeMethod ????????????

InvokeMethod ????????????

Scheduled Pinned Locked Moved C#
helpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Saaaaz
    wrote on last edited by
    #1

    I am doing following to run a remote-machine's process on that remote-machine: ConnectionOptions objConnectionOptions = new ConnectionOptions(); objConnectionOptions.Impersonation = ImpersonationLevel.Impersonate; objConnectionOptions.EnablePrivileges = true; objConnectionOptions.Username = strUserName; objConnectionOptions.Password = strPassword; ManagementScope objManagementScope = new ManagementScope(@"\\remote-machine-name\ROOT\CIMV2", objConnectionOptions); objManagementScope.Connect(); ManagementClass processClassFinal = new ManagementClass(objManagementScope, new ManagementPath("Win32_Process"), null); ManagementBaseObject inParamsFinal = processClassFinal.GetMethodParameters("Create"); inParamsFinal["CommandLine"] = @"\\remote-machine-name\some-directory\someProgram.exe"; ManagementBaseObject outParamsFinal = processClassFinal.InvokeMethod("Create", inParamsFinal, null); But for some reason it does not work and I don't know why??????? outParamsFinal["processId"] returns null, instead of a valid processId. Is there any one who could help me in that.............. Thanks Sarfraz

    D 1 Reply Last reply
    0
    • S Saaaaz

      I am doing following to run a remote-machine's process on that remote-machine: ConnectionOptions objConnectionOptions = new ConnectionOptions(); objConnectionOptions.Impersonation = ImpersonationLevel.Impersonate; objConnectionOptions.EnablePrivileges = true; objConnectionOptions.Username = strUserName; objConnectionOptions.Password = strPassword; ManagementScope objManagementScope = new ManagementScope(@"\\remote-machine-name\ROOT\CIMV2", objConnectionOptions); objManagementScope.Connect(); ManagementClass processClassFinal = new ManagementClass(objManagementScope, new ManagementPath("Win32_Process"), null); ManagementBaseObject inParamsFinal = processClassFinal.GetMethodParameters("Create"); inParamsFinal["CommandLine"] = @"\\remote-machine-name\some-directory\someProgram.exe"; ManagementBaseObject outParamsFinal = processClassFinal.InvokeMethod("Create", inParamsFinal, null); But for some reason it does not work and I don't know why??????? outParamsFinal["processId"] returns null, instead of a valid processId. Is there any one who could help me in that.............. Thanks Sarfraz

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Perhaps a review of the Win32_Process.Create[^] are in order: The Create WMI class method creates a new process. A fully-qualified path must be specified in cases where the program to be launched is not in the search path of Winmgmt.exe. If the newly created process attempts to interact with objects on the target system without the appropriate access privileges, it is terminated without notification to this method. For security reasons the Win32_Process.Create method cannot be used to start an interactive process remotely.

      Dave Kreskowiak Microsoft MVP - Visual Basic

      S 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Perhaps a review of the Win32_Process.Create[^] are in order: The Create WMI class method creates a new process. A fully-qualified path must be specified in cases where the program to be launched is not in the search path of Winmgmt.exe. If the newly created process attempts to interact with objects on the target system without the appropriate access privileges, it is terminated without notification to this method. For security reasons the Win32_Process.Create method cannot be used to start an interactive process remotely.

        Dave Kreskowiak Microsoft MVP - Visual Basic

        S Offline
        S Offline
        Saaaaz
        wrote on last edited by
        #3

        So... What exactly I am going to have to do in order to achieve my goal???? Sarfraz

        D 1 Reply Last reply
        0
        • S Saaaaz

          So... What exactly I am going to have to do in order to achieve my goal???? Sarfraz

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          PSEXEC[^]. But, the down side is that most virus scanning software considers this app to be an "unwanted" .exe. If the virus scanner sees it and doesn't like it, the scanner will stop PSEXEC from running.

          Dave Kreskowiak Microsoft MVP - Visual Basic

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups