Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find Operating System

Status
Not open for further replies.

alpder

Technical User
Sep 22, 2002
103
AU
I run functions in an Access DB from one of 2 PCs (on Novell network). One PC runs WinNT and the other XP. As I have a Shell function in the code I need to use code to determine the OS so I can run a DOS command (the reason for this is that the windows directory for NT is WINNT, but for XP it is WINDOWS).
I tried a search limited to this forum, but the results included all forums.
 
This is ALPDER again - I forgot to mention in the original posting that I tried using the Environ variable(13). Both NT and XP pcs return a value of "OS=Windows_NT
 
The best way to do it use some APIs. However if you are using APIs why not use them to return the windows directory instead. Heres an example
Code:
Declare Function apiGetWindowsDirectory& Lib "kernel32" Alias _
   "GetWindowsDirectoryA" (ByVal lpbuffer As String, ByVal nSize As Long)

Function GetWinDir() As String
   Dim lpbuffer As String * 255
   Dim Length As Long
   Length = apiGetWindowsDirectory(lpbuffer, Len(lpbuffer))
   GetWinDir = Left(lpbuffer, Length)
End Function

For more info see
 
And what about Environ("SystemRoot") ?
Or Environ("windir") ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top