How to determine subsystem of executable?

A

Alex Blekhman

Hello,

I need to determine executable's subsystem from script. I
was thinking about using WMI for that.
Win32_FileSpecification class looks promising
(TargetOperatingSystem property). However, I cannot get
instance of Win32_FileSpecification for individual file.
While CIM_DataFile is easily retrievable, but doesn't
contain subsystem information. Here's short example:

------
strComputer = "."
Set objWMIService = GetObject(_
"winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery( _
"Select * from CIM_Datafile " & _
"WHERE Name='C:\\Windows\\notepad.exe'",,48)
For Each objItem in colItems
For Each prop in objItem.Properties_
Wscript.Echo prop.Name & ": " & prop.Value
Next
Next
 
R

Randy Birch

Hmm ... the results I get for CIM_DataFile don't include the target opsys
property. This is VB code:


Private Sub Command116_Click()

Dim objset As SWbemObjectSet
Dim obj As SWbemObject
Dim ssql As String

ssql = "select * from CIM_DataFile where
Name='C:\\Windows\\explorer.exe'"

Set objset =
GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery(ssql)

For Each obj In objset
Debug.Print obj.GetObjectText_
Next

End Sub

instance of CIM_DataFile
{
AccessMask = 18809343;
Archive = TRUE;
Caption = "c:\\windows\\notepad.exe";
Compressed = FALSE;
CreationClassName = "CIM_LogicalFile";
CreationDate = "20040910194211.359375-240";
CSCreationClassName = "Win32_ComputerSystem";
CSName = "VBNETDEV";
Description = "c:\\windows\\notepad.exe";
Drive = "c:";
EightDotThreeFileName = "c:\\windows\\notepad.exe";
Encrypted = FALSE;
Extension = "exe";
FileName = "notepad";
FileSize = "69120";
FileType = "Application";
FSCreationClassName = "Win32_FileSystem";
FSName = "NTFS";
Hidden = FALSE;
InstallDate = "20040910194211.359375-240";
LastAccessed = "20051226233500.328125-300";
LastModified = "20040804015656.000000-240";
Manufacturer = "Microsoft Corporation";
Name = "c:\\windows\\notepad.exe";
Path = "\\windows\\";
Readable = TRUE;
Status = "OK";
System = FALSE;
Version = "5.1.2600.2180 (xpsp_sp2_rtm.040803-2158)";
Writeable = TRUE;
};


--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/

Please reply to the newsgroups so all can participate.




: Hello,
:
: I need to determine executable's subsystem from script. I
: was thinking about using WMI for that.
: Win32_FileSpecification class looks promising
: (TargetOperatingSystem property). However, I cannot get
: instance of Win32_FileSpecification for individual file.
: While CIM_DataFile is easily retrievable, but doesn't
: contain subsystem information. Here's short example:
:
: ------
: strComputer = "."
: Set objWMIService = GetObject(_
: "winmgmts:\\" & strComputer & "\root\cimv2")
: Set colItems = objWMIService.ExecQuery( _
: "Select * from CIM_Datafile " & _
: "WHERE Name='C:\\Windows\\notepad.exe'",,48)
: For Each objItem in colItems
: For Each prop in objItem.Properties_
: Wscript.Echo prop.Name & ": " & prop.Value
: Next
: Next
: ------
:
: Thanks in advance for any suggestion
: Alex
:
:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top