AyatollahPies Posted July 20, 2010 Posted July 20, 2010 (edited) 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? Ta Edit: These values are in the registry and I'm definitely running it on XP :-) Edited July 20, 2010 by AyatollahPies Missed out some vital info
tommccann Posted July 20, 2010 Posted July 20, 2010 reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v ProductName if %1% == "Microsoft Windows XP" is what we use 1
AyatollahPies Posted July 20, 2010 Author Posted July 20, 2010 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.
Martin Posted July 20, 2010 Posted July 20, 2010 Is it case sensitive - "Currentversion" versus "CurrentVersion"?? mb
ascott2 Posted July 20, 2010 Posted July 20, 2010 You could use WMI take a look at this. I think there is even an example of OS Version on the page.
Chad Posted July 20, 2010 Posted July 20, 2010 We use: ver | find "Windows XP" > nul Would that work, or do you have a specific requirement to read the registry?
AyatollahPies Posted July 21, 2010 Author Posted July 21, 2010 It's working now. Cut and pasted my original code into notepad and re-saved. No idea why it threw a hissy fit.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now