Announcement

Collapse
No announcement yet.

Detect MS/DOS mode

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Detect MS/DOS mode

    I have a DOS program that shells to 32-bit programs.
    Is there a way to see if it is running in MS/DOS mode
    so it won't attempt to shell to any 32-bit apps.


    ------------------
    How long is an idea? Write it down.

  • #2
    Perhaps the code in the thread Determine OS platform and version from DOS could be of some use to you?
    If you try to make something idiot-proof, someone will invent a better idiot.

    Comment


    • #3
      Very close, but need to know if in MS/DOS mode so
      program doesn't attempt to shell. May have to resort
      to something funky like shelling to a 32-bit app and
      setting a flag in the 32-bit app if it completes.
      Don't really want to do this. Thought maybe an
      environment variable would be different.



      ------------------
      How long is an idea? Write it down.

      Comment


      • #4
        Is this program for your own use only? Or for use on PCs that you configure? If so, you could set an environment variable yourself, in the AUTOEXEC.BAT that is used when the system is booted in the MS-DOS mode.

        -- Eric


        ------------------
        Perfect Sync Development Tools
        Perfect Sync Web Site
        Contact Us: mailto:[email protected][email protected]</A>
        "Not my circus, not my monkeys."

        Comment


        • #5
          It is a demo of a DOS program that might be run
          from either DOS or Windows on many machines.
          I'm going to try shelling to a 1 line PB/DLL program
          that opens whatever is passed in COMMAND$. Then
          the DOS program can delete the file if it exists and
          know 32-bit Windows created it. Seems funky, but
          all I need to know is if DOS is running.



          ------------------
          How long is an idea? Write it down.

          Comment


          • #6
            Dear Mike

            In QB7, I use

            IF ENVIRON$("windir") <> "" THEN
            .
            .
            END IF
            etc., etc.,

            Note the low case for "windir"
            I assume this is possible in PB/DOS.

            David J Walker

            ------------------

            Comment


            • #7
              I use this simple approach, and I've never had a report of a problem:
              Code:
              IF (ISTRUE LEN(ENVIRON$("winbootdir")) AND ISTRUE BIT(pbvHost,8)) OR _
                UCASE$(ENVIRON$("OS")) = "WINDOWS_NT" THEN  ' Only if 32-bit Windows is running
                ...
              END IF
              ------------------
              Lance
              PowerBASIC Support
              mailto:[email protected][email protected]</A>
              Lance
              mailto:[email protected]

              Comment


              • #8
                Code:
                'Exactly what I needed.
                'Note: "winbootdir" appears in MS/DOS mode in Win98.
                'Made a slight modification and added the NT test.
                'This will hopefully work in either basic.
                IF LEN(ENVIRON$("windir")) > 0 OR UCASE$(ENVIRON$("OS")) = "WINDOWS_NT" THEN
                  Win32& = 1
                END IF
                Thanks much!

                ------------------




                [This message has been edited by Mike Doty (edited October 11, 2001).]
                How long is an idea? Write it down.

                Comment


                • #9
                  Lance

                  Even better!

                  Thanks!

                  ------------------

                  Comment


                  • #10
                    David,
                    Your "windir" might be correct using QB7 since
                    "winbootdir" appears in MS/DOS mode in Windows 98 SE.
                    Mike

                    ------------------


                    [This message has been edited by Mike Doty (edited October 11, 2001).]
                    How long is an idea? Write it down.

                    Comment


                    • #11
                      Seems to work ok, Mike. Compiler shouldn't make any difference
                      to it anyway. Works in ME as well (mind you, it would, would'nt
                      it?)
                      Just checked a W95 machine. Typed SET in various locations.
                      As far as I can see, W95/98 only has "windir" in the environment
                      when Windows is actually running. It certainly isn't
                      there if you boot into DOS (BootGUI=0 in MSDOS.SYS),nor is it
                      there after restarting in DOS mode out of Windows. Incidentally,
                      if you also set Logo=0 in MSDOS.SYS then you get faster boot, and
                      an obscure M$ document for W95 stated that this improved
                      stability with aftermarket memory managers. I consider it
                      improves it even more with M$'s!
                      However, "winbootdir" is there in all of these cases. So it seems
                      that checking the environment for windir is safe for 95/ME.
                      I'll check 98 tomorrow, also NT4 & W2K just out of interest!


                      ------------------


                      [This message has been edited by David J Walker (edited October 16, 2001).]

                      Comment


                      • #12
                        Ok, I remember where I originally derived winbootdir from:

                        In some of my older DOS app's I need to launch EDIT.COM, and in Win95+ machines, this is found in the \WINDOWS\COMMAND folder. Therefore, by using
                        Code:
                        IF LEN(ENVIRON$("winbootdir")) THEN _
                          SHELL ENVIRON$("winbootdir") + "\COMMAND\EDIT.COM"
                        So, if you just need to detect the Win9x GUI, then "windir" is the solution. If you need access to the Windows directory regardless of whether the GUI is active, use "winbootdir".

                        Ok?

                        ------------------
                        Lance
                        PowerBASIC Support
                        mailto:[email protected][email protected]</A>
                        Lance
                        mailto:[email protected]

                        Comment


                        • #13
                          PS: You'll also note that I combined the PBVHOST check with "winbootdir" so the result of that combined AND test will produce the correct result since "winbootdir" is not present on Win16 systems.


                          ------------------
                          Lance
                          PowerBASIC Support
                          mailto:[email protected][email protected]</A>
                          Lance
                          mailto:[email protected]

                          Comment


                          • #14
                            Checked W98, windir is OK.
                            NT & W2K, like Lance said (as it could be otherwise).
                            Just for completion, is XP the same, anyone? (Probably, but...)

                            ------------------

                            Comment


                            • #15
                              Great, so you won't use winbootdir.
                              Wanted to be sure you saw this.

                              ------------------
                              How long is an idea? Write it down.

                              Comment


                              • #16
                                Hi,
                                Under XP:
                                A$=ENVIRON$("OS"):PRINT A$
                                will print:
                                Windows_NT

                                Regards

                                ------------------

                                Comment


                                • #17
                                  Do you also get "windir"?

                                  ------------------
                                  How long is an idea? Write it down.

                                  Comment


                                  • #18
                                    Sorry, I did'nt try on everything yet.
                                    the <Windows_NT> will show regardless in the BOX or not

                                    Regards

                                    ------------------

                                    Comment


                                    • #19
                                      "windir" is Win9x, but not NT/2000 so doubt XP will provide it (since XP can be considered the "next version" of NT).

                                      BTW, the "OS" environment variable can be altered through the System Properties dialog, but it would unusual to do so.

                                      ------------------
                                      Lance
                                      PowerBASIC Support
                                      mailto:[email protected][email protected]</A>
                                      Lance
                                      mailto:[email protected]

                                      Comment


                                      • #20
                                        John,
                                        It would be great if you did 2 things.
                                        Get to an MS/DOS prompt and type SET.
                                        Also, restart the machine in MS/DOS mode and type SET.

                                        ------------------
                                        How long is an idea? Write it down.

                                        Comment

                                        Working...
                                        X