Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 7 of 7

Thread: Get OS

  1. #1
    Join Date
    Feb 2006
    Posts
    346

    Get OS

    Hello,

    How can I detect OS and run and exe by OS name? if OS = XP file.run "test.exe" or if OS = Vista file.run "test2.exe". Any help would be great. thanks

    Code:
    -- Get the name of the OS.
    os_name = System.GetOSName();
    if os_name = XP then
    Dialog.Message("Information", "Installing application for "..os_name..".", MB_OK, MB_ICONINFORMATION);
    File.run "Test.exe"
    elseif
    os_name = Vista then
    Dialog.Message("Information", "Installing application for "..os_name..".", MB_OK, MB_ICONINFORMATION);
    File.run "Test1.exe"
    end

  2. #2
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    You've almost got it -- did you look at the help file?
    The names of the os are listed there...

    Windows Vista

    Windows Server 2008

    Windows XP

    Windows Server 2003

    Windows 2000

    Windows NT 4

    Windows NT 3

    Windows ME

    Windows 98

    Windows 95


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  3. #3
    Join Date
    Feb 2006
    Posts
    346
    Yes, I did look at the help. Still having problems with line 2 (if os_name = Windows XP then) - Not sure if this is the right syntax. Help Please! Thanks

    Code:
    -- Get the name of the OS.
    os_name = System.GetOSName();
    if os_name = Windows XP then
    Dialog.Message("Information", "Installing application for "..os_name..".", MB_OK, MB_ICONINFORMATION);
    File.Run("C:\\Program Files\\IFD\\AutoPlay\\SoftwareDIS\\NWClient\\unattended.bat", "", "", SW_SHOWNORMAL, true);
    elseif
    os_name = Windows Vista then
    Dialog.Message("Information", "Installing application for "..os_name..".", MB_OK, MB_ICONINFORMATION);
    File.Run("C:\\Program Files\\IFD\\AutoPlay\\SoftwareDIS\\VistaClient\\setup.exe", "", "", SW_SHOWNORMAL, true);
    end

  4. #4
    Join Date
    Jul 2002
    Location
    Just South of Reality
    Posts
    778
    Quote Originally Posted by abnrange View Post
    Yes, I did look at the help. Still having problems with line 2 (if os_name = Windows XP then) - Not sure if this is the right syntax. Help Please! Thanks

    Code:
    -- Get the name of the OS.
    os_name = System.GetOSName();
    if os_name = Windows XP then
    Dialog.Message("Information", "Installing application for "..os_name..".", MB_OK, MB_ICONINFORMATION);
    File.Run("C:\\Program Files\\IFD\\AutoPlay\\SoftwareDIS\\NWClient\\unattended.bat", "", "", SW_SHOWNORMAL, true);
    elseif
    os_name = Windows Vista then
    Dialog.Message("Information", "Installing application for "..os_name..".", MB_OK, MB_ICONINFORMATION);
    File.Run("C:\\Program Files\\IFD\\AutoPlay\\SoftwareDIS\\VistaClient\\setup.exe", "", "", SW_SHOWNORMAL, true);
    end

    Try it with quotes around ..."Windows XP"; "Windows Vista"

    e.g.:
    if os_name = "Windows XP" then

  5. #5
    Join Date
    Apr 2005
    Location
    São Paulo, Brazil
    Posts
    2,539
    Quote Originally Posted by holtgrewe View Post
    Try it with quotes around ..."Windows XP"; "Windows Vista"
    e.g.:
    if os_name = "Windows XP" then
    Furthermore, it might help using the correct syntax for comparisons, like
    Code:
    if (os_name == "Windows XP") then
    or better yet
    Code:
    if (String.Compare(os_name, "Windows XP") == 0) then
    Ulrich

  6. #6
    Join Date
    Feb 2006
    Posts
    346
    Added the quotes - I get this error:

    Line=3: 'then' expected near '='



    Code:
    -- Get the name of the OS.
    os_name = System.GetOSName();
    if os_name = "Windows XP" then
    Dialog.Message("Information", "Installing application for "..os_name..".", MB_OK, MB_ICONINFORMATION);
    File.Run("C:\\Program Files\\IFD\\AutoPlay\\SoftwareDIS\\NWClient\\unattended.bat", "", "", SW_SHOWNORMAL, true);
    elseif
    os_name = "Windows Vista" then
    Dialog.Message("Information", "Installing application for "..os_name..".", MB_OK, MB_ICONINFORMATION);
    File.Run("C:\\Program Files\\IFD\\AutoPlay\\SoftwareDIS\\VistaClient\\setup.exe", "", "", SW_SHOWNORMAL, true);
    end

  7. #7
    Join Date
    Feb 2006
    Posts
    346
    This worked if (os_name == "Windows XP") then

    Thanks for the help!

Posting Permissions

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