Click here to Skip to main content
15,867,895 members
Home / Discussions / C#
   

C#

 
GeneralRe: about database updation in C# Pin
DX Roster9-Mar-10 0:31
DX Roster9-Mar-10 0:31 
GeneralRe: about database updation in C# Pin
OriginalGriff9-Mar-10 0:52
mveOriginalGriff9-Mar-10 0:52 
GeneralRe: about database updation in C# Pin
DX Roster9-Mar-10 1:23
DX Roster9-Mar-10 1:23 
GeneralRe: about database updation in C# Pin
loyal ginger9-Mar-10 3:36
loyal ginger9-Mar-10 3:36 
AnswerRe: about database updation in C# Pin
OriginalGriff9-Mar-10 0:23
mveOriginalGriff9-Mar-10 0:23 
AnswerRe: about database updation in C# Pin
DX Roster9-Mar-10 0:32
DX Roster9-Mar-10 0:32 
AnswerRe: about database updation in C# Pin
dybs9-Mar-10 14:23
dybs9-Mar-10 14:23 
QuestionRemote access with WMI Pin
kebedetesema8-Mar-10 22:44
kebedetesema8-Mar-10 22:44 
Hi,
I want to run some processes on a remote PC using WMI and C#. One of the PC runs XP SP3 and the other PC runs XP SP2. But I keep getting "access denied" errors. some of the errors are:

1. Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

2."error Logon failure:the user has not been granted the requested logon type at this computer."

Both computers are workgroup computers.i have tried the following with no avail.

I use a login with administrative privileges. In addition I have enabled this account to be remote enabled using
dcomcnfg >DCOM Config >Windows Management Instrumentation > properties on the remote computer.

From security options, I changed "Network access:Sharing and security options for local accounts"
to "Classic: Local users authenticate as themselves." on the remote computer
Disabled the fire wall
Note that code works fine on local host.

Can anybody help?



Here is the code I am using

using System;
using System.Collections.Generic;
using System.Text;
using System.Management;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //Local Machine
            // ProcessLocal process = new ProcessLocal();

            //Remote Machine
            string userName = "sara";
            string password = "titina";
            string domain = null;
            string machineName = "192.168.12.20";
            ConnectionOptions options = new ConnectionOptions();

            if (domain != null)
            {
                options.Username = domain + "\\" + userName;

            }
            options.Username = userName;
            options.Password = password;


            options.Impersonation = ImpersonationLevel.Impersonate;
            options.Authentication = AuthenticationLevel.Packet;

            options.EnablePrivileges = true;


            ManagementScope connectScope = new ManagementScope();
            connectScope.Path = new ManagementPath(@"\\" + machineName + @"\root\CIMV2");
            connectScope.Options = options;

            try
            {
                connectScope.Connect();
            }
            catch (ManagementException e)
            {
                Console.WriteLine("An Error Occurred: " + e.Message.ToString());
            }
            catch (AccessViolationException ee)
            {



                string processName = "notepad.exe";
                Console.WriteLine("Creating Process: " + processName);
                Console.WriteLine(process.CreateProcess(processName));

                Console.WriteLine("Killing Process: " + processName);
                //process.TerminateProcess(processName);
                Console.WriteLine("Process Terminated");
                Console.ReadLine();


            }
        }
    }
}

AnswerRe: Remote access with WMI Pin
Gerrit4449-Mar-10 0:49
Gerrit4449-Mar-10 0:49 
GeneralRe: Remote access with WMI Pin
kebedetesema10-Mar-10 19:01
kebedetesema10-Mar-10 19:01 
Questiondisplay progress bar Pin
jadhavShubhangi8-Mar-10 22:37
jadhavShubhangi8-Mar-10 22:37 
AnswerRe: display progress bar Pin
DX Roster8-Mar-10 23:40
DX Roster8-Mar-10 23:40 
GeneralRe: display progress bar Pin
jadhavShubhangi9-Mar-10 0:21
jadhavShubhangi9-Mar-10 0:21 
GeneralRe: display progress bar Pin
DX Roster9-Mar-10 0:36
DX Roster9-Mar-10 0:36 
Questionconnection problem Pin
jadhavShubhangi8-Mar-10 22:33
jadhavShubhangi8-Mar-10 22:33 
AnswerRe: connection problem My vote of 5 Pin
Keith Barrow8-Mar-10 22:43
professionalKeith Barrow8-Mar-10 22:43 
GeneralRe: connection problem My vote of 5 Pin
jadhavShubhangi8-Mar-10 23:02
jadhavShubhangi8-Mar-10 23:02 
GeneralRe: connection problem My vote of 5 Pin
Luc Pattyn9-Mar-10 0:24
sitebuilderLuc Pattyn9-Mar-10 0:24 
Questiondisplaying updated datagridview Pin
jadhavShubhangi8-Mar-10 22:20
jadhavShubhangi8-Mar-10 22:20 
AnswerMy vote of 1 [again] Pin
Keith Barrow8-Mar-10 22:37
professionalKeith Barrow8-Mar-10 22:37 
AnswerRe: displaying updated datagridview Pin
DX Roster9-Mar-10 0:00
DX Roster9-Mar-10 0:00 
Questionclick on dtagridview display result in relative textbox Pin
jadhavShubhangi8-Mar-10 22:17
jadhavShubhangi8-Mar-10 22:17 
AnswerMy vote of 1 Pin
Keith Barrow8-Mar-10 22:36
professionalKeith Barrow8-Mar-10 22:36 
GeneralRe: My vote of 1 Pin
jadhavShubhangi8-Mar-10 22:39
jadhavShubhangi8-Mar-10 22:39 
GeneralRe: My vote of 1 Pin
OriginalGriff8-Mar-10 22:58
mveOriginalGriff8-Mar-10 22:58 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.