6

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>]
  • What is the output on wmic datafile /? Does this apply to your described file? – Ramhound Jan 9 '16 at 19:53
  • @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" – Kevin Fegan Jan 9 '16 at 22:00
  • @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 Jan 9 '16 at 22:06
  • @KevinFegan See my answer. You need to escape a single backslash \ and use \\ instead (as well as use drive and path) – DavidPostill Jan 9 '16 at 22:08
  • @KevinFegan See technet.microsoft.com/en-us/library/cc758713%28v=ws.10%29.aspx for some examples ... – DavidPostill Jan 9 '16 at 22:18
6

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

  • This is more or less where my thought was going with my link – Ramhound Jan 9 '16 at 22:02
  • I tried wmic datafile where name="C:\\Windows\\system32\\notepad.exe" get CreationDate (and even wmic 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? – Kevin Fegan Jan 10 '16 at 1:16
  • @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 a where clause as I understand it. – DavidPostill Jan 10 '16 at 9:44
  • ... wmic datafile get /? That was it. Thanks again. I was trying wmic datafile where /?, which doesn't return anything very useful. – Kevin Fegan Jan 14 '16 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.