Scripts Thread, Can't see what is wrong with this in Coding and Web Development; I'm writing a batch file that involves querying the OS to see if it is running Windows XP.
The failing ...
20th July 2010, 09:28 AM #1
Can't see what is wrong with this
I'm writing a batch file that involves querying the OS to see if it is running Windows XP.
The failing bit of code is as follows:
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion" /v ProductName | FIND "Microsoft Windows XP"
When I run this, I get the following error:
ProductName REG_SZ Microsoft Windows XP
Error: They system was unable to find the specified registry key or value
I cannot see what is wrong with the command? Any pointers? Is it a stupid little spelling mistake?
Edit: These values are in the registry and I'm definitely running it on XP :-)
Last edited by AyatollahPies; 20th July 2010 at 09:31 AM.
Reason: Missed out some vital info
IDG Tech News
20th July 2010, 09:30 AM #2
reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v ProductName if %1% == "Microsoft Windows XP"
is what we use
Thanks to tommccann from:
AyatollahPies (20th July 2010)
20th July 2010, 09:47 AM #3
Just tried this and it's telling me there are too many command-line parameters.
This is a fresh build I'm testing on too.
Think I need to try another workstation.
Cheers for the help.
20th July 2010, 10:23 AM #4
Is it case sensitive - "Currentversion" versus "CurrentVersion"??
20th July 2010, 02:44 PM #5
You could use WMI take a look at this.
I think there is even an example of OS Version on the page.
20th July 2010, 03:24 PM #6
ver | find "Windows XP" > nul
Would that work, or do you have a specific requirement to read the registry?
21st July 2010, 01:18 PM #7
It's working now. Cut and pasted my original code into notepad and re-saved.
No idea why it threw a hissy fit.
By elsiegee40 in forum Windows
Last Post: 10th September 2009, 08:16 PM
By 3rdknight in forum EduGeek Joomla 1.5 Package
Last Post: 4th July 2009, 12:48 PM
By apoth0r in forum EduGeek Joomla 1.0 Package
Last Post: 19th January 2008, 01:17 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)