"No Instance(s) Available" error with the wmic command
I'm getting a "No Instance(s) Available" error with the following wmic command.
G:\>wmic datafile where name="file.txt" get creationdate
You need to provide the full name (including the drive and path) of the file.
Example:
F:\test>wmic datafile where name="C:\\Windows\\system32\\notepad.exe" get CreationDate
CreationDate
20090714005636.838522+060
Note the use of \\
to escape a single \
in the above example name string.
If you wish to include the following special characters in your string, you must first escape the character by prefixing the character with a backslash (\):
- backslash (\\)
- double quotes (\")
- single quotes (\')
Source WHERE Clause
What are the valid keywords (name, path, ...) for the where clause with datafile?
You can get the property list from the command line using:
wmic datafile get /?
Any of the property names can be used in a where clause.
F:\test>wmic datafile get /?
Property get operations.
USAGE:
GET [<property list>] [<get switches>]
NOTE: <property list> ::= <property name> | <property name>, <property list>
The following properties are available:
Property Type Operation
======== ==== =========
Access Rights N/A N/A
Caption N/A N/A
Class Name N/A N/A
Compressed N/A N/A
Compression Method N/A N/A
Computer System Class Name N/A N/A
Computer System Name N/A N/A
Creation Date N/A N/A
Current File Open Count N/A N/A
Description N/A N/A
Drive N/A N/A
Eight Dot Three File Name N/A N/A
Encrypted N/A N/A
Encryption Method N/A N/A
File Extension N/A N/A
File Name N/A N/A
File System Class Name N/A N/A
File System Name N/A N/A
File Type N/A N/A
Hidden N/A N/A
Install Date N/A N/A
Last Accessed N/A N/A
Last Modified N/A N/A
Manufacturer N/A N/A
Name N/A N/A
Path N/A N/A
Readable N/A N/A
Should Be Archived N/A N/A
Size N/A N/A
Status N/A N/A
System File N/A N/A
Version N/A N/A
Writeable N/A N/A
Further Reading
Related videos on Youtube
Kevin Fegan
Updated on September 18, 2022Comments
-
Kevin Fegan almost 2 years
I'm getting a "No Instance(s) Available" error with the wmic command. The command I'm running (from an elevated/administrator cmd.exe window) is:
G:\>wmic datafile where name="file.txt" get creationdate No Instance(s) Available
The file "file.txt" does exist.
I have found some mention of this problem in other SU questions/answers like the answer here:
Windows Command to get all information/properties of a file
but I have not found any mention of how to fix (or even troubleshoot) this problem.
I'm running Windows 7 Home Premium x64.
When I run "wmic datafile /?" I get usage syntax help:G:\>wmic datafile /? DATAFILE - DataFile Management. HINT: BNF for Alias usage. (<alias> [WMIObject] | <alias> [<path where>] | [<alias>] <path where>) [<verb clause>]. USAGE: DATAFILE ASSOC [<format specifier>] DATAFILE CALL <method name> [<actual param list>] DATAFILE CREATE <assign list> DATAFILE DELETE DATAFILE GET [<property list>] [<get switches>] DATAFILE LIST [<list format>] [<list switches>]
-
Ramhound over 8 yearsWhat is the output on
wmic datafile /?
Does this apply to your described file? -
Kevin Fegan over 8 years@Ramhound - That article talks about "Windows Server 2008 R2 configured with failover clustering". I'm running Windows 7 Home Premium x64, so although it is the same error message, I don't think it applies to me. The file is on a partition on my desktop hard drive. It happens with any file I have tried, even something like
C:\Windows\system32\notepad.exe"
-
DavidPostill over 8 years@KevinFegan msdn.microsoft.com/en-us/library/aa394054.aspx: You may use string literals, such as "NTFS", in a WHERE clause. If you wish to include the following special characters in your string, you must first escape the character by prefixing the character with a backslash (\): backslash (\\) double quotes (\") single quotes (\')
-
DavidPostill over 8 years@KevinFegan See my answer. You need to escape a single backslash \ and use \\ instead (as well as use drive and path)
-
DavidPostill over 8 years@KevinFegan See technet.microsoft.com/en-us/library/cc758713%28v=ws.10%29.aspx for some examples ...
-
-
Ramhound over 8 yearsThis is more or less where my thought was going with my link
-
Kevin Fegan over 8 yearsI tried
wmic datafile where name="C:\\Windows\\system32\\notepad.exe" get CreationDate
(and evenwmic datafile where name="C:notepad.exe" get CreationDate
) and well... they work ! (you knew they would). I am sure I tried that before when it was failing, but I probably had something else wrong with the command syntax at the time. Thanks for your help. Do you have a link to info about valid keywords (name, path, ...) for the WHERE clause with DATAFILE? -
DavidPostill over 8 years@KevinFegan No link, but you can get the property list from the command line using
wmic datafile get /?
. Any property name can be used in awhere
clause as I understand it. -
Kevin Fegan over 8 years...
wmic datafile get /?
That was it. Thanks again. I was tryingwmic datafile where /?
, which doesn't return anything very useful.