473,581 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Post my code for FileNotFoundExe cption problem, help !

I wrote one program which can query processes info., it 's work well in my
local Computer, but failed and got the below error when i query remote host
processes,anybo dy can help me ? that 's when remove "\\\\host00 8" , it 's work
well,when i add "\\\\host008",i t's got error !

"Unhandled Exception: System.IO.FileN otFoundExceptio n: Explorer.EXE
at System.Diagnost ics.FileVersion Info.GetVersion Info(String fileName)
at QueryProcess02. Main()"


/*Wrote by Michael C.,pls. do not modify this code if you are not*/
/*a family in Csharp ! Jan 09 2006 */
using System;
using System.Manageme nt;
using System.Diagnost ics;
using System.Text.Reg ularExpressions ;
public class QueryProcess02 {
public static void Main(){
ManagementObjec tSearcher searcher = new
ManagementObjec tSearcher("\\\\ host008\\root\\ cimv2","Select * from
Win32_Process") ;
foreach (ManagementObje ct process in searcher.Get())
{

//Console.WriteLi ne("Process Caption: "+ process["Caption"]);
//Console.WriteLi ne("Process Description: "+ process["Descriptio n"]);

string[] s= new String[2];
process.InvokeM ethod("GetOWner ",(object[])s);
string prOwner = s[1]+"\\"+s[0];

if (prOwner.Length ==13)
{//Console.WriteLi ne(prOwner);
string prFullPath = process["ExecutablePath "].ToString();

//Console.WriteLi ne(prFullPath);
//prFullPath = "@"+prFullP ath;
// Console.WriteLi ne("Break Point Test01");
// Console.WriteLi ne(prFullPath);

FileVersionInfo myFileVersionIn fo =
FileVersionInfo .GetVersionInfo (@prFullPath);
// Console.WriteLi ne("Break Point Test02");
//Console.WriteLi ne("CompanyName :" + myFileVersionIn fo.CompanyName) ;
//Console.WriteLi ne("FileVersion :" + myFileVersionIn fo.FileVersion) ;
if (myFileVersionI nfo.CompanyName == null)
{//Console.WriteLi ne("None CompanyName in this Process!");
//Console.WriteLi ne("OriginalFil eName: "+
myFileVersionIn fo.OriginalFile name);
continue;
}
else{
Regex r = new
Regex("(Microso ft|Kingsoft|Sym antec|Oracle|IZ Software|Adobe) .*");
if(!r.IsMatch(m yFileVersionInf o.CompanyName))
{
Console.Write(" CompanyName:" + myFileVersionIn fo.CompanyName) ;
Console.Write(" OriginalFileNam e:" +
myFileVersionIn fo.OriginalFile name);
Console.WriteLi ne("you are using illegal software !");

}
}
}

}
}
}
Jan 10 '06 #1
1 1741


"roopeman" <ro******@discu ssions.microsof t.com> wrote in message
news:F7******** *************** ***********@mic rosoft.com...
|I wrote one program which can query processes info., it 's work well in my
| local Computer, but failed and got the below error when i query remote
host
| processes,anybo dy can help me ? that 's when remove "\\\\host00 8" , it 's
work
| well,when i add "\\\\host008",i t's got error !
|
| "Unhandled Exception: System.IO.FileN otFoundExceptio n: Explorer.EXE
| at System.Diagnost ics.FileVersion Info.GetVersion Info(String fileName)
| at QueryProcess02. Main()"
|
|
|
|
| /*Wrote by Michael C.,pls. do not modify this code if you are not*/
| /*a family in Csharp ! Jan 09 2006 */
| using System;
| using System.Manageme nt;
| using System.Diagnost ics;
| using System.Text.Reg ularExpressions ;
| public class QueryProcess02 {
| public static void Main(){
| ManagementObjec tSearcher searcher = new
| ManagementObjec tSearcher("\\\\ host008\\root\\ cimv2","Select * from
| Win32_Process") ;
| foreach (ManagementObje ct process in searcher.Get())
| {
|
| //Console.WriteLi ne("Process Caption: "+ process["Caption"]);
| //Console.WriteLi ne("Process Description: "+ process["Descriptio n"]);
|
| string[] s= new String[2];
| process.InvokeM ethod("GetOWner ",(object[])s);
| string prOwner = s[1]+"\\"+s[0];
|
| if (prOwner.Length ==13)
| {//Console.WriteLi ne(prOwner);
| string prFullPath = process["ExecutablePath "].ToString();
|
| //Console.WriteLi ne(prFullPath);
| //prFullPath = "@"+prFullP ath;
| // Console.WriteLi ne("Break Point Test01");
| // Console.WriteLi ne(prFullPath);
|
| FileVersionInfo myFileVersionIn fo =
| FileVersionInfo .GetVersionInfo (@prFullPath);
| // Console.WriteLi ne("Break Point Test02");
| //Console.WriteLi ne("CompanyName :" +
myFileVersionIn fo.CompanyName) ;
| //Console.WriteLi ne("FileVersion :" +
myFileVersionIn fo.FileVersion) ;
|
|
| if (myFileVersionI nfo.CompanyName == null)
| {//Console.WriteLi ne("None CompanyName in this Process!");
| //Console.WriteLi ne("OriginalFil eName: "+
| myFileVersionIn fo.OriginalFile name);
| continue;
| }
| else{
| Regex r = new
| Regex("(Microso ft|Kingsoft|Sym antec|Oracle|IZ Software|Adobe) .*");
| if(!r.IsMatch(m yFileVersionInf o.CompanyName))
| {
| Console.Write(" CompanyName:" +
myFileVersionIn fo.CompanyName) ;
| Console.Write(" OriginalFileNam e:" +
| myFileVersionIn fo.OriginalFile name);
| Console.WriteLi ne("you are using illegal software !");
|
| }
| }
|
|
| }
|
| }
| }
| }
|
|
This can never work.

FileVersionInfo myFileVersionIn fo =
FileVersionInfo .GetVersionInfo (@prFullPath);

"@prFullPat h" is the local (host008) file path! but your code doesn't run on
host008 so you need the UNC path in your call to GetVersionInfo.

Willy.

Jan 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3527
by: sammmista | last post by:
hello experts, Plz dont treat this as another newbie query , i did my homework but still getting nowhere :( :( :( Trying to learn PHP on Fedora core 1 (PHP 4.3,MySQL,HTTPD).Unable to post data from html form to php file(connecting to mysql database and inserting into a table) . This seemingly simple problem is making me go mad !!! I...
0
2037
by: Andreas Suurkuusk | last post by:
Hi, I just noticed your post in the "C# memory problem: no end for our problem?" thread. In the post you implied that I do not how the garbage collector works and that I mislead people. Since the thread is over a month old, I decided to start a new one with my response. Please see my comments inline.
5
3018
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I need to send data from my server via the post method to the payment server. The payment server does not run asp.net. I dont know what they run. The...
0
3866
by: WIWA | last post by:
Hi, I want to login to a password protected website and fetch the content of the page behind. I have based my code on http://weblogs.asp.net/jdennany/archive/2005/04/23/403971.aspx. When I use tools like ieHTTPHeaders v1.6, and I perform a normal login (using the normal website), I see that the viewstate is...
0
2005
by: deacon57 | last post by:
FYI - If you are a computer scientist (or geek), this post may be for you. I wanted to log any search keywords, etc that are used on my site. I created a simple program that logs search terms into a log file. The problem I experienced was that I was getting double entries in the log... that is, when writing to the file, each line I wrote to...
3
2113
by: bb nicole | last post by:
Below is my job post code, it cannot post into database... WHAT IS THE PROBLEM OF IT?? <?php session_start(); ob_start(); //connect to server and select database
3
2068
by: Vic Spainhower | last post by:
Hello, I have an HTML table that is being constructed from a MySQL table and displays a form that includes a check box on 1 of the fields on the form for each record. I have included in this PHP program a javascript routine called sorttable.js which is something I found on the internet for sorting tables and works quite well. The HTML...
7
2913
by: php_mysql_beginer911 | last post by:
Hi .. hope someone will help i am trying to figure it out why i cannot post string "union select" every time i try to post data which content union and select .. the page doesn't get posted and it shows error page not found on this server i googled and found some people use union and select to hack sites (mysql injection) i guess the...
0
8304
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6553
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5674
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5364
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3827
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1403
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1138
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.