Fix for Windows 7 & wmic: Invalid XSL format (or) file name
Posted: October 19, 2011 at 2:48 pm | Tags: fix Invalid XSL format (or) file name, Invalid XSL format, Invalid XSL format (or) file name, windows 7 Invalid XSL format, wmic, wmic csv, wmic format, wmic format error, wmic hform, wmic htable, wmic Invalid XSL format, wmic mof, wmic windows 7, wmic windows 7 format, wmic xmlIn Windows 7, there is a bug with wmic and the /format switch. When using the /format switch, you will get the error “Invalid XSL format (or) file name.”
1. Example:
C:\Tmp>wmic /output:C:\tmp\procinfo.html CPU get Description, DeviceID, Manufacturer, MaxClockSpeed, Name, Status, SystemName /format:hform.xsl Invalid XSL format (or) file name.
2. Cause:
Windows looks for the XSL stylesheets but cannot find them, which produces the error above.
3. Resolution:
Copy *.xsl from x:\Windows\system32\wbem\en-US\ to x:\Windows\system32 – this can be done quicky from command prompt:
copy /y %WINDIR%\system32\wbem\en-US\*.xsl %WINDIR%\system32\
If you run your original wmic command (example in Section 1), there will be no errors and wmic will export data in the format required.
The Discussion
see what everyone is saying
Still won’t work…
@IsaacM – did you get any errors when entering the commands in this post? I have just updated this post so that the command applies to Windows installed on any drive, other than C:\
If the *.xsl files exist in %WINDIR%\system32\ and it still doesn’t work, try restart Windows and then test again.
Did not work for me as well. Windows 7 64 bit version.
Thanks a million bro.. this worked like clockwork..
@Jordan, I had the same problem also on Windows 7 64 bits. It worked for my user account and Administrator account, but not for the local system account. For some reason I had to use it under the local system account. A search on the internet, as mentioned above, only gave the solution to copy the csv.xsl file into the system32 directory which didn’t help. Also adjusting the PATH variable for the local system user didn’t help.
But I noticed there was another format which did work. I did a search from the c:\windows directory to find this format.xsl file. The file was found in 4 different directories and it turned out that the file csv.xsl needed to be available in c:\windows\SysWOW64!? Don’t ask me why, but now it’s working as documented.
The files are already in the C:\Windows\SysWOW64\wbem\en-US and they need to be in the system32 folder on a 64bit system. I copied the 5 files into the c:\windows\system32 folder and it worked straight away.
The listed solution worked fine for me under Win7 64bit
Though I had to run the copy as Asministrator