473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to access files' version numbers on remote servers -WMI, .Net

Hi

The only file information I need to access for a bunch of files (dlls &
exe) on several remote servers is "file version number". Using the code
below, I appear to be able to access all information (properties)
other than file version - using (System.Management Namespace - WMI).
Can anyone assist me how to access file version. I see that for a local
PC, one can use the System.Diagnositcs.FileVersionInfo class (rather
than simply the FileInfo Class which access most other file
information). This leads me to believe that using the CIM_DataFile
Class as per my code equates to using FileInfo class rather than an
equivalent WMI Class for FileVersionInfo.

I am not permitted to use mapped network drives and therefore I believe
that I cannot use the .Net Directory and FileVersionInfo classes to
interogate files in specific direcories on remote servers (Code Below -
aswell)?

//This is code to use for accessing files on Remote Server
string directoryName =
"D:\\Tutorial\\Microsoft.Sdc.Configuration.Tutoria l.Business\\bin\\Debug";
string sql = "ASSOCIATORS OF " +
"{Win32_Directory='" + directoryName + "'} " +
"WHERE " +
"AssocClass=CIM_DirectoryContainsFile " +
"ResultClass=CIM_DataFile " +
"ResultRole=PartComponent " +
"Role=GroupComponent";

string computername = "RemoteTestServer";
string path = "\\root\\cimv2";
ConnectionOptions oConn = new ConnectionOptions();
oConn.Username = "SomeUser";
oConn.Password = "SomePassword";

ManagementScope scope = new System.Management.ManagementScope("\\\\" +
computername + path, oConn);
System.Management.RelatedObjectQuery oQuery = new
System.Management.RelatedObjectQuery(sql);
ManagementObjectSearcher oSearcher = new
ManagementObjectSearcher(scope, oQuery);
ManagementObjectCollection oFiles = oSearcher.Get();

foreach(ManagementObject oFile in oFiles)
{
Console.WriteLine("File Caption: " +
Convert.ToString(oFile["Caption"]));
Console.WriteLine("File Version: " +
Convert.ToString(oFile["version"])); //DRATS ALWAYS NO VALUE!!!!!!!!!
Console.WriteLine("Archive: " + Convert.ToString(oFile["Archive"]));
Console.WriteLine("Compressed: " +
Convert.ToString(oFile["Compressed"]));
Console.WriteLine("File Name: " +
Convert.ToString(oFile["FileName"]));
Console.WriteLine("File Extension: " +
Convert.ToString(oFile["Extension"]));
Console.WriteLine("File Size: " +
Convert.ToString(oFile["FileSize"]));
Console.WriteLine("File Type: " +
Convert.ToString(oFile["FileType"]));
Console.WriteLine("Last Modified: " +
Convert.ToString(oFile["LastModified"]));
Console.WriteLine("File Size: " +
Convert.ToString(oFile["FileSize"]));
Console.WriteLine("Name: " + Convert.ToString(oFile["Name"]));
Console.WriteLine("Path: " + Convert.ToString(oFile["Path"]));
Console.WriteLine("Name: " + Convert.ToString(oFile["Name"]));
Console.WriteLine("System: " + Convert.ToString(oFile["System"]));
Console.WriteLine("Manufaturer: " +
Convert.ToString(oFile["Manufacturer"]));
}
//This is code to acces File version on local System
System.Diagnostics.FileVersionInfo flInfoVer =
System.Diagnostics.FileVersionInfo.GetVersionInfo( stringFileName);
version = flInfoVer.FileVersion;

Thanks in advance.

Nov 1 '06 #1
0 1559

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

Similar topics

0
by: Todd Calhoun | last post by:
Hi, I've got a MySQL database being hosted by a company. The site has phpMyAdmin for external administration, but I'd like to use a program like EMS MySQL manager, or maybe even an OBDC...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
5
by: premmehrotra | last post by:
I currently have a multi-user access database which is put on a shared drive L: on a Windows Servers. Entire database is one file premdb.mdb. Users access this database from their laptops....
6
by: Terry Bell | last post by:
We've had a very large A97 app running fine for the last seven years. I've just converted to SQL Server backend, which is being tested, but meanwhile the JET based version, running under terminal...
3
by: Lyle Fairfield | last post by:
In a recent thread there has been discussion about Data Access Pages. It has been suggested that they are not permitted on many or most secure sites. Perhaps, that it is so, although I know of no...
0
by: bettervssremoting | last post by:
To view the full article, please visit http://www.BetterVssRemoting.com Better VSS Remote Access Tool including SourceOffSite, SourceAnyWhere and VSS Remoting This article makes a detailed...
17
by: DaveG | last post by:
Hi all I am planning on writing a stock and accounts program for the family business, I understand this is likely to take close to 2 years to accomplish. The stock is likely to run into over a...
7
by: Allison | last post by:
Hi -- we are a small manufacturing looking for a multi-user database to take customer orders (nothing too complicated, with 3 users total). We think we should be using Access, but are wondering...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
25
by: p byers | last post by:
Good Morning Folks I have a LAN Among the several connections to it are the following four devices: A MAXSTOR network Storage Device A PC running Microsoft Windows 2000 Server 5.0.2195 (SP4) A...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.