+ Post New Thread
Results 1 to 7 of 7
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 ...
  1. #1
    AyatollahPies's Avatar
    Join Date
    Jan 2008
    Location
    Earth
    Posts
    900
    Thank Post
    48
    Thanked 105 Times in 95 Posts
    Rep Power
    41

    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?

    Ta

    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

  2. #2
    tommccann's Avatar
    Join Date
    Jun 2009
    Posts
    252
    Thank Post
    46
    Thanked 39 Times in 31 Posts
    Rep Power
    0
    reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v ProductName if %1% == "Microsoft Windows XP"

    is what we use

  3. Thanks to tommccann from:

    AyatollahPies (20th July 2010)

  4. #3
    AyatollahPies's Avatar
    Join Date
    Jan 2008
    Location
    Earth
    Posts
    900
    Thank Post
    48
    Thanked 105 Times in 95 Posts
    Rep Power
    41
    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.

  5. #4

    Join Date
    Sep 2006
    Location
    West Midlands
    Posts
    408
    Thank Post
    71
    Thanked 75 Times in 58 Posts
    Rep Power
    43
    Is it case sensitive - "Currentversion" versus "CurrentVersion"??

    mb

  6. #5
    ascott2's Avatar
    Join Date
    Nov 2007
    Posts
    174
    Thank Post
    18
    Thanked 36 Times in 28 Posts
    Rep Power
    20
    You could use WMI take a look at this.

    I think there is even an example of OS Version on the page.

  7. #6
    Chad's Avatar
    Join Date
    May 2007
    Location
    Elgin
    Posts
    74
    Thank Post
    5
    Thanked 20 Times in 19 Posts
    Rep Power
    18
    We use:

    ver | find "Windows XP" > nul

    Would that work, or do you have a specific requirement to read the registry?

  8. #7
    AyatollahPies's Avatar
    Join Date
    Jan 2008
    Location
    Earth
    Posts
    900
    Thank Post
    48
    Thanked 105 Times in 95 Posts
    Rep Power
    41
    It's working now. Cut and pasted my original code into notepad and re-saved.

    No idea why it threw a hissy fit.

SHARE:
+ Post New Thread

Similar Threads

  1. New Router - Where have I gone wrong please?
    By elsiegee40 in forum Windows
    Replies: 7
    Last Post: 10th September 2009, 08:16 PM
  2. New Installation Looks Wrong?
    By 3rdknight in forum EduGeek Joomla 1.5 Package
    Replies: 11
    Last Post: 4th July 2009, 12:48 PM
  3. hosting? or am i doing something wrong?
    By apoth0r in forum EduGeek Joomla 1.0 Package
    Replies: 4
    Last Post: 19th January 2008, 01:17 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •