locked
How to tell difference between windows Vista/7 and windows 2000/XP in a logon script RRS feed

  • Question

  • I have a problem. I need to create a shared shutdown script for 2000/XP machines and Vista/7 machines to install and configure software.

    It's easy enough to install the appropriate x86/x64 msi because I can use the %processor_architecture% variable.

     

    The problem comes when pre-configuring the program settings data, due to the change in application data storage location.

     

    In 2000/XP this was %ALLUSERSPROFILE%\Application Data\PROGRAM-NAME\

    .... Usually C:\Documents and Settings\All Users\Application Data\PROGRAM-NAME\

    In Vista/7 this has become just %ALLUSERSPROFILE%\PROGRAM-NAME

    .... Usually just C:\ProgramData\PROGRAM-NAME\

     

    How can I tell whether the script is running on 2000/XP or Vista/7 ??


    Tuesday, April 26, 2011 6:19 AM

Answers

  • Hi Johnny,

     

    If you run the variable %ALLUSERSPROFILE% on Windows XP, it opens C:\Documents and Settings\All Users. I assume Windows XP is installed on C: drive. If you run the variable %ALLUSERSPROFILE% on Windows 7, it opens C:\ProgramData directly. I assume Windows 7 is installed on C: drive. You need to use different variable\path in Windows XP\2000 and in Windows 7\Vista.

     

    To confirm whether the script works on all Windows XP\2000 and Windows 7\Vista, the easiest way will be running the script on 4 computers with different OS version manually and separately as Scorpio_Milo suggested.

     

    You can also check the OS version on the client first, after that, choose relative variable\path for different OS. Please submit a new thread in the script forum to ask for the script you need. Refer to the following link:

     

    The Official Scripting Guys Forum!

    http://social.technet.microsoft.com/Forums/en-US/ITCG/threads    

     

    Thanks.

    Nina


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Friday, April 29, 2011 2:12 AM
  • There are several places where you can get the info, but you would then have to extract the essence for use with your script. Examples:

    reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v ProductName

    wmic os get caption

    systeminfo | findstr /c:"OS Name:"

    ver

     

    Monday, May 2, 2011 12:43 PM

All replies

  • Hi Johnny,

    There is simple way to know whether the script is running on Windows 2000, Windows XP, Windows Vista and Windows 7.

    Just find 4 computers to test with the script. :)


    Thanks and Regards
    Scorpio_Milo

    MCTS: Windows Vista | Exchange Server 2007
    MCITP: Enterprise Support Technician
    MCITP: Server & Enterprise Administrator
    Microsoft Infrastructure Consultant
    Enterprise Service: Solution Architect
    Contact me
    My Blog
    Tuesday, April 26, 2011 6:54 AM
  • Could you use a query like "if %allusersprofile%==C:\ProgramData"?

     

    Tuesday, April 26, 2011 7:27 AM
  • Thanks Scorpio? 4 ribbons! Were they all gained making similarly helpful comments?

     

    Thanks Eirik nice idea and that would normally work but unfortunately on our network not all of the clients are installed to the default partition.


    Thursday, April 28, 2011 9:44 AM
  • Hi Johnny,

     

    If you run the variable %ALLUSERSPROFILE% on Windows XP, it opens C:\Documents and Settings\All Users. I assume Windows XP is installed on C: drive. If you run the variable %ALLUSERSPROFILE% on Windows 7, it opens C:\ProgramData directly. I assume Windows 7 is installed on C: drive. You need to use different variable\path in Windows XP\2000 and in Windows 7\Vista.

     

    To confirm whether the script works on all Windows XP\2000 and Windows 7\Vista, the easiest way will be running the script on 4 computers with different OS version manually and separately as Scorpio_Milo suggested.

     

    You can also check the OS version on the client first, after that, choose relative variable\path for different OS. Please submit a new thread in the script forum to ask for the script you need. Refer to the following link:

     

    The Official Scripting Guys Forum!

    http://social.technet.microsoft.com/Forums/en-US/ITCG/threads    

     

    Thanks.

    Nina


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Friday, April 29, 2011 2:12 AM
  • There are several places where you can get the info, but you would then have to extract the essence for use with your script. Examples:

    reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v ProductName

    wmic os get caption

    systeminfo | findstr /c:"OS Name:"

    ver

     

    Monday, May 2, 2011 12:43 PM