Results 1 to 8 of 8

Thread: Get the Windows directory?

  1. #1

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935

    Get the Windows directory?

    How can I get the Windows directory path in QBasic? Or for that matter, how can I get the contents of any environment variable in QBasic (like %PATH%, %CLASSPATH%, %TEMPDIR%, etc.)?

  2. #2
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    You can get from QB using Environ$(), just like in VB .
    Code:
    DIM i AS INTEGER
    DIM strEnv AS STRING
    i = 1
    strEnv = ENVIRON$(i)
    DO UNTIL strEnv = ""
       PRINT i; CHR$(34); strEnv; CHR$(34)
       i = i + 1
       strEnv = ENVIRON$(i)
    LOOP
    PRINT
    END
    The only thing that seems to be a little funky is that it's case sensitive if you request an environment variable by name, such as Environ$("windir") to get the windows directory. In my system, the environment var is %windir%, but if you ask for it with Environ$("WINDIR"), you get nothing back. Since you may or may not know the actual capitalization of the var itself, it's probably better to go off of index number and make up your own array or something.
    Last edited by Kaverin; Sep 15th, 2001 at 05:20 PM.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

  3. #3

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    Cool.

  4. #4

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    What I'm trying to do is make my own installer stub that copies the VB runtimes and then executes a VB setup EXE. So can I always ensure that the path is %WINDIR%? This is my SET stuff:

    Code:
    ALLUSERSPROFILE=C:\Documents and Settings\All Users
    APPDATA=C:\Documents and Settings\Arien Talabac\Application Data
    CommonProgramFiles=C:\Program Files\Common Files
    COMPUTERNAME=TOWER1
    ComSpec=C:\WINNT\system32\cmd.exe
    HOMEDRIVE=C:
    HOMEPATH=\Documents and Settings\Arien Talabac
    LOGONSERVER=\\TOWER1
    NUMBER_OF_PROCESSORS=1
    OS=Windows_NT
    Path=C:\WINNT\system32;C:\WINNT;C:\WINNT\system32\WBEM;D:\programs\borland\tcpp452\BIN
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
    PROCESSOR_ARCHITECTURE=x86
    PROCESSOR_IDENTIFIER=x86 Family 6 Model 8 Stepping 6, GenuineIntel
    PROCESSOR_LEVEL=6
    PROCESSOR_REVISION=0806
    ProgramFiles=C:\Program Files
    PROMPT=$P$G
    SESSIONNAME=Console
    SystemDrive=C:
    SystemRoot=C:\WINNT
    TEMP=C:\DOCUME~1\ARIENT~1\LOCALS~1\Temp
    TMP=C:\DOCUME~1\ARIENT~1\LOCALS~1\Temp
    USERDOMAIN=TOWER1
    USERNAME=Arien Talabac
    USERPROFILE=C:\Documents and Settings\Arien Talabac
    windir=C:\WINNT

  5. #5
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    As long as windows in some form is on, I believe you can always assume %windir% will be that dir.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

  6. #6

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    So will a VB program run if the MSVBVM50.DLL is in the Windows directory, or the system directory? I don't see any listing for a system directory.

  7. #7
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    As long as the dll is registered, I'd guess that it would work. And if you can get the windows dir, the system one would just be windir\system.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

  8. #8

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    c:\winnt\system32

Posting Permissions

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



Click Here to Expand Forum to Full Width