Click here to Skip to main content
       

C#

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionWMI causing Access is deniedmembervanikanc16 Jan '13 - 3:36 
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!
AnswerRe: WMI causing Access is deniedmvpDave Kreskowiak16 Jan '13 - 3:41 
You haven't specified HOW you're trying to launch this .EXE and what this has to do with WMI.

GeneralRe: WMI causing Access is deniedmembervanikanc16 Jan '13 - 3:56 
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);

GeneralRe: WMI causing Access is deniedmembervanikanc16 Jan '13 - 4:31 
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.
GeneralRe: WMI causing Access is deniedmvpDave Kreskowiak16 Jan '13 - 4:55 
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.

GeneralRe: WMI causing Access is deniedmvpDave Kreskowiak16 Jan '13 - 4:57 
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.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid