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. WMI causing Access is denied

WMI causing Access is denied

Scheduled Pinned Locked Moved C#
sysadminquestion
6 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.
  • V Offline
    V Offline
    vanikanc
    wrote on last edited by
    #1

    Hi, I created a new account on the remote server and gave it Admin priviledges. I am trying to execute an exe using this new account and it comes back with Access is Denied. Is this something to do with this newly created account? Thanks so much!

    D 1 Reply Last reply
    0
    • V vanikanc

      Hi, I created a new account on the remote server and gave it Admin priviledges. I am trying to execute an exe using this new account and it comes back with Access is Denied. Is this something to do with this newly created account? Thanks so much!

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

      You haven't specified HOW you're trying to launch this .EXE and what this has to do with WMI.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      V 1 Reply Last reply
      0
      • D Dave Kreskowiak

        You haven't specified HOW you're trying to launch this .EXE and what this has to do with WMI.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak

        V Offline
        V Offline
        vanikanc
        wrote on last edited by
        #3

        ConnectionOptions opts = new ConnectionOptions();
        opts.Username = "my_username"
        opts.Password = "my_pwd";

        ManagementPath path = new ManagementPath(@"\\<myserver>\root\cimv2:Win32_Process");
        ManagementScope scope = new ManagementScope(path, opts);
        scope.Connect();
        ObjectGetOptions getopts = new ObjectGetOptions();
        ManagementClass mgClass = new ManagementClass(scope, path, getopts);
        ManagementBaseObject inParams = mgClass.GetMethodParameters("Create");

        //Fill in input parameter values
        inParams["CommandLine"] = @"\\<myprogramlocation>\myprogram.exe";

        //Execute the method
        ManagementBaseObject outParams = mgClass.InvokeMethod("Create", inParams, null);

        V D 2 Replies Last reply
        0
        • V vanikanc

          ConnectionOptions opts = new ConnectionOptions();
          opts.Username = "my_username"
          opts.Password = "my_pwd";

          ManagementPath path = new ManagementPath(@"\\<myserver>\root\cimv2:Win32_Process");
          ManagementScope scope = new ManagementScope(path, opts);
          scope.Connect();
          ObjectGetOptions getopts = new ObjectGetOptions();
          ManagementClass mgClass = new ManagementClass(scope, path, getopts);
          ManagementBaseObject inParams = mgClass.GetMethodParameters("Create");

          //Fill in input parameter values
          inParams["CommandLine"] = @"\\<myprogramlocation>\myprogram.exe";

          //Execute the method
          ManagementBaseObject outParams = mgClass.InvokeMethod("Create", inParams, null);

          V Offline
          V Offline
          vanikanc
          wrote on last edited by
          #4

          It is an account issue, the account set up on the remote server needs to be a domain account. An account specific to that computer is not working.

          D 1 Reply Last reply
          0
          • V vanikanc

            It is an account issue, the account set up on the remote server needs to be a domain account. An account specific to that computer is not working.

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

            It doesn't need to be a domain account... It just needs to be an account that your code knows about and can pass credentials for.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            1 Reply Last reply
            0
            • V vanikanc

              ConnectionOptions opts = new ConnectionOptions();
              opts.Username = "my_username"
              opts.Password = "my_pwd";

              ManagementPath path = new ManagementPath(@"\\<myserver>\root\cimv2:Win32_Process");
              ManagementScope scope = new ManagementScope(path, opts);
              scope.Connect();
              ObjectGetOptions getopts = new ObjectGetOptions();
              ManagementClass mgClass = new ManagementClass(scope, path, getopts);
              ManagementBaseObject inParams = mgClass.GetMethodParameters("Create");

              //Fill in input parameter values
              inParams["CommandLine"] = @"\\<myprogramlocation>\myprogram.exe";

              //Execute the method
              ManagementBaseObject outParams = mgClass.InvokeMethod("Create", inParams, null);

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

              You get Access Denied because the account your code is running under does not have permissions to the remote machine. By default, if you don't specify any account information in the Management connection objects, it'll use the account your code is running under. If that account doesn't have permissions on the remote machine, it'll fail.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak

              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