PDA

View Full Version : Get OS


abnrange
12-23-2008, 08:42 PM
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

-- 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

jassing
12-23-2008, 09:50 PM
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

abnrange
12-24-2008, 10:25 AM
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

-- 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\\unatt ended.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\\se tup.exe", "", "", SW_SHOWNORMAL, true);
end

holtgrewe
12-24-2008, 10:36 AM
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

-- 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\\unatt ended.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\\se tup.exe", "", "", SW_SHOWNORMAL, true);
end


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

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

Ulrich
12-24-2008, 10:42 AM
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
if (os_name == "Windows XP") then
or better yet
if (String.Compare(os_name, "Windows XP") == 0) then

Ulrich

abnrange
12-24-2008, 10:42 AM
Added the quotes - I get this error:

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



-- 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\\unatt ended.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\\se tup.exe", "", "", SW_SHOWNORMAL, true);
end

abnrange
12-24-2008, 10:46 AM
This worked if (os_name == "Windows XP") then

Thanks for the help!