Code to tell under which version of Windows mdb is running?

User avatar
Carol W.
3StarLounger
Posts: 390
Joined: 26 Jan 2010, 16:02
Location: Las Vegas, NV

Code to tell under which version of Windows mdb is running?

Post by Carol W. »

I have the following code:

Code: Select all

MsgBox "This function is now being performed in GroupMail. All information has been prepared for GroupMail. The Membership database will now close and GroupMail will open automatically."
Shell "C:\Program Files\GroupMail 5\GMMain.exe", vbMaximizedFocus
Quit
The mdb in which this code is located can either run on Win XP or Win 7 (64 bit) (Files are shared across a network). Under Win 7, the folder in which Gmmain.exe is installed is not the same as it is under Win XP.

I would like to put an If statement in the code to execute the above Shell command if running under Win XP and a modified Shell command (reflecting the correct folder) if running under Win 7.

How do I construct the If statement?

Thank you, in advance.
Carol W.

JohnH
3StarLounger
Posts: 287
Joined: 09 Mar 2010, 23:16
Location: Canberra Australia

Re: Code to tell under which version of Windows mdb is runni

Post by JohnH »

Instead of testing for the version of Windows, you could just Dir to test for the existence of GMMain.exe if the required location.

Code: Select all

Dim strCommandline as String
if Dir("C:\Program Files\GroupMail 5\GMMain.exe") <> "" then
     strCommandLine ="C:\Program Files\GroupMail 5\GMMain.exe"
elseif if Dir("C:\alt location\GMMain.exe") <> "" then
    strCommandLine ="C:\alt location\GMMain.exe"
else
    strCommandLine =""
end if

if len(strCommandLine) >0 then
   MsgBox "This function is now being performed in GroupMail. All information has been prepared for GroupMail. The Membership database will now close and     GroupMail will open automatically."
    Shell strCommandLine, vbMaximizedFocus
  Quit
else
MsgBox "GroupMail is not available"

end if

Regards

John

User avatar
Carol W.
3StarLounger
Posts: 390
Joined: 26 Jan 2010, 16:02
Location: Las Vegas, NV

Re: Code to tell under which version of Windows mdb is runni

Post by Carol W. »

Thanks, John.

That approach works well.
Carol W.