Tried to search for something similar but could not find.
I have file on a remote machine which I want to query for it`s details like version, date, etc. How do I do that when I need to enter credentials for that machine? FileVersionInfo does not give option to do so.
Thanks
Update:
As I said above I checked what FIleVersionInfo gives me (and also tried it) and that will not work for me. I also tried using WMI and failed with (although it looked like the direction I need) Here is the WMI code I tried - haven`t got much far:
var computerName = "IP_ADDRESS";
ConnectionOptions conn = new ConnectionOptions();
conn.Username = "username";
conn.Password = "password";
conn.Authority = "ntlmdomain:DOMAIN";
conn.Impersonation = ImpersonationLevel.Impersonate;
conn.EnablePriviledges = true;
var scope = new ManagementScope(String.Format("\\\\{0}\\root\\CIMV2", computerName), conn);
scope.Connect();
string Drive = "c:";
string Path = "\\\\inetpub\\\\wwwroot\\\\FOLDER\\\BIN\\\File.dll";
ObjectQuery Query = new ObjectQuery(string.Format("SELECT * FROM CIM_DataFile Where Drive='{0}' AND Path='{1}' ", Drive, Path));
ManagementObjectSearcher Searcher = new ManagementObjectSearcher(scope, Query);
foreach (ManagementObject WmiObject in Searcher.Get())
{
Console.WriteLine("{0}", (string)WmiObject["Name"]);// String
}
I mainly need the file properties version and date.
Thanks