Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Eventlog on remote machine

Posted on 2008-11-08
Medium Priority
Last Modified: 2013-12-17
Sorry i get RPC connection exception. Please help.
using System;
using System.Management;
using System.IO;
class App {
private static void Main(string[] args)
// Beware! the account used to connect must have remote WMI privileges on the remote server.
RunProcess M = new RunProcess("c3c3d", "#####", "333");
sealed class RunProcess
private ConnectionOptions co;
private ManagementScope scope;
public RunProcess(string ConnectionUser, string ConnectionPassword, string
Machine )
co = new ConnectionOptions();
co.Username = ConnectionUser;
co.Password = ConnectionPassword;
co.Impersonation = ImpersonationLevel.Impersonate;
scope = new ManagementScope(@"\\" + Machine + @"\root\cimv2", co);
public void Run()
string logFileName = "SYSTEM";
// default blocksize = 1, larger value may increase network throughput
EnumerationOptions opt = new EnumerationOptions();
opt.BlockSize = 1000;
// Get only Logon/LogOff category from security log
SelectQuery query = new SelectQuery("select CategoryString,TimeGenerated, User, Type from Win32_NtLogEvent where Logfile ='System'");
using(ManagementObjectSearcher searcher = new
ManagementObjectSearcher(scope, query, opt))
foreach (ManagementObject mo in searcher.Get()) {
string logInfo = String.Format("{0} - {1} - {2}", mo["Type"],
mo["CategoryString"], mo["User"]);

Open in new window

Question by:sonu002
  • 2
  • 2
LVL 41

Accepted Solution

graye earned 2000 total points
ID: 22919092
I would suspect this is a firewall issue....  On the remote PC, try the following:

netsh firewall set service RemoteAdmin enable
netsh advfirewall firewall set rule group="windows management instrumentation (wmi)" new enable=yes  

Author Comment

ID: 22919134
How do we change this setting please help
LVL 41

Assisted Solution

graye earned 2000 total points
ID: 22921490
....by typing the commands that I provided
The top one is for WinXP, the bottom for Vista

Author Comment

ID: 22928593
Thanks it worked for me!!!

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
How to install and configure Citrix XenApp 6.5 - Part 1. In this video tutorial we have explained step by step installation of Citrix XenApp 6.5 Server on Windows Server 2008 R2 is explained in this video. We have explained the difference between…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question