'SELECT' is not recognized as an internal or external command
Solution 1
I know this has something to do with environmental variables
Wherever that knowledge came from, it is wrong.
Your SELECT
statement is a WMI query, in a language named WQL (a subset of SQL). You don't just type it in at the prompt of the cmd
command interpreter. cmd
interprets a completely different language. You cannot go randomly giving commands in one computer language to a tool that speaks another completely different one. That's not how computers work.
Further reading
- "WMI Queries". .NET 2.0 Framework. TechNet. Microsoft corporation.
- "Using WMI". MSDN Library. Microsoft corporation.
Solution 2
It is as JdeBP has stated. You need to use a tool that can handle your WQL (sql-like) statement. You could switch from using the cmd.exe command shell and use the powershell.exe command shell to run your query. It offers a cmdlet that allows for processing of WQL statements. Try this:
Open your command window and type in Powershell
and hit enter. This will cause an instance of powershell to run inside of your current cmd session. Now that you are in powershell, you can use the Get-WmiObject commandlet to query for your information:
get-wmiobject -query "select * from win32_processor where addresswidth='64'"
and hit enter. This should return you the information you are trying to get at. Once you are done, you can type exit
to end the powershell session you were running inside of your cmd session.
Note that you also can open Powershell directly instead of going thru cmd.exe. just type "Powershell" in the Run box or the search field at the bottom of the start menu, and a powershell window will open up on your screen, just like if you use cmd.exe.
If for some reason you are unable to bring up powershell, you could check and make sure it is installed. On my Win 7 install it lives here:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Hope this helps,
Related reading:
About the Get-WmiObject cmdlet
Related videos on Youtube
user3311261
Updated on September 18, 2022Comments
-
user3311261 over 1 year
I'm trying to apply a wmi filter to a group policy using this command:
Select * from Win32_Processor where AddressWidth = '64'
This will only apply the GPO to 64 bit machines (all of our machines are Windows 7) when the filter is linked. However, the GPO is not applying and when I run the select statement on the machine I get:
Select is not recognized as an internal or external command, operable program, or batch file.
I know this has something to do with environmental variables, however I'm not sure how to assign this particular one if that is the case.
Any help would be greatly appreciated!
-
user3311261 about 10 yearsThanks, that makes sense. Apparently the issue is elsewhere on my WMI filter.
-
Debra about 10 yearsWMI commands can be run from CMD by prefacing with the command interpreter, i.e. "WMIC <command>". See technet.microsoft.com/en-us/library/bb742610.aspx#ECAA for easy help. However, your SELECT is WMI SQL -- see msdn.microsoft.com/en-us/library/aa394606%28v=vs.85%29.aspx for how to use WMI SQL (WQL). The first cite gives specific info on using WMIC to determine processor, which seems your goal. These work similar to the way you can run a Powershell cmdlet or script from the command line, i.e. by prefacing with "powershell.exe" and appropriate switches and parameters.