Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Find Drive letter for program files (86)  (Read 14532 times)

0 Members and 1 Guest are viewing this topic.

Salmon Trout

  • Guest
Re: Find Drive letter for program files (86)
« Reply #15 on: February 08, 2013, 04:49:45 PM »
Salmon Trout, I don't want to go back and forth about this and your help and everyone else s in the community very much appreciated BUT I just want to know if it can be done and how and if not then so be it I will move on. I'm just trying to learn this for fun and its on my cd for personal use. Thanks!!!

You don't seem to understand how forums work. The idea is you state your problem clearly and people try to answer it. If you have not stated the problem clearly or if your remarks seem to indicate some kind of comprehension or knowledge issue people are going to ask questions to get to the nitty-gritty. Until they lose patience or interest. Or you tell them to stop (like you seem to be doing).

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: Find Drive letter for program files (86)
« Reply #16 on: February 08, 2013, 08:48:18 PM »
Writing to "%temp%" is always an option.

Here's a method from stackoverflow.

Code: [Select]
@echo off
if defined ProgramFiles(x86) (
@echo yes
@echo Some 64-bit work
) else (
@echo no
@echo Some 32-bit work
)

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: Find Drive letter for program files (86)
« Reply #17 on: February 08, 2013, 09:02:14 PM »
The thread title says you want the drive letter, so this should work.

Code: [Select]
@echo off
if defined ProgramFiles(x86) (
for %%a in ("%ProgramFiles(x86)%") do echo the drive letter is %%~da
) else (
echo not 64 bit
)

oxicottin

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Windows 7
    Re: Find Drive letter for program files (86)
    « Reply #18 on: February 09, 2013, 10:16:54 PM »
    I got it to work from a DVD on 32bit and 64bit systems. The systems I tested it on were:

    • 64bit system was running Win8
    • 32bit was running Win7

    The reason I wanted the drive letter was I thought it would have been easier that way in the initial code I started with. I hope this will help somone else since I couldn't find any information on the matter. I still am messing with trying to to figure out how to write it to a text file foxidrive, I will read about how to do the %temp% option and post results. Thank You!

    Code: [Select]
    @echo off

    Color 2A

    ::(Registry Code Start)
    ::============================================================
    echo.
    echo.
    Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0

    REG.exe Query %RegQry% 2>NUL | find /I /N "x86">NUL

    If [%ERRORLEVEL%] == [0] (
    GOTO X86
    ) ELSE (
    GOTO X64
    )

    :X86

    echo. 32 bit OS

    GOTO END

    :X64
    echo. 64 bit OS

    GOTO END

    :END
    ::============================================================
    ::(Registry Code End)


    echo.
    echo. Press any key to exit...
    pause >nul

    Salmon Trout

    • Guest
    Re: Find Drive letter for program files (86)
    « Reply #19 on: February 10, 2013, 12:35:26 AM »
    Quote
    \Hardware\Description\System\CentralProcessor

    The bitness of the CPU does always not tell you the bitness of the OS. A 64 bit CPU could be running either a 32 bit or a 64 bit OS version.


    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    Re: Find Drive letter for program files (86)
    « Reply #20 on: February 10, 2013, 01:54:50 AM »
    I still am messing with trying to to figure out how to write it to a text file foxidrive, I will read about how to do the %temp% option and post results.

    Instead of just echoing the drive letter, use this:

    Code: [Select]
    @echo off
    del "%temp%\64bit.txt" 2>nul
    if defined ProgramFiles(x86) for %%a in ("%ProgramFiles(x86)%") do >"%temp%\64bit.txt" echo %%~da

    Then if the file doesn't exist the system is 32 bit, and if it does exist the file contains the drive letter of the %ProgramFiles(x86)% variable.

    Salmon Trout

    • Guest
    Re: Find Drive letter for program files (86)
    « Reply #21 on: February 10, 2013, 02:08:39 AM »
    The bitness of the CPU does always not tell you the bitness of the OS. A 64 bit CPU could be running either a 32 bit or a 64 bit OS version.

    Also command line methods for testing the bitness ("bit count") of the OS may give different results on a 64 bit system depending on whether you are running the 32 or 64 bit cmd.exe (a 64 bit system has one of each). If you shell out from a 32 bit process you get the 32 bit cmd.exe.

    64 bit: %windir%\System32\cmd.exe
    32 bit: %windir%\SysWoW64\cmd.exe

    64 bit

    C:\>set processor_a
    PROCESSOR_ARCHITECTURE=AMD64


    32 bit

    C:\>set processor_a
    PROCESSOR_ARCHITECTURE=x86
    PROCESSOR_ARCHITEW6432=AMD64


    Handy tips here

    http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx


    « Last Edit: February 10, 2013, 02:19:36 AM by Salmon Trout »

    Salmon Trout

    • Guest
    Re: Find Drive letter for program files (86)
    « Reply #22 on: February 10, 2013, 02:48:33 AM »
    ..

    Salmon Trout

    • Guest
    Re: Find Drive letter for program files (86)
    « Reply #23 on: February 10, 2013, 03:26:00 AM »
    Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0

    This reg key shows x86 on 32 bit Windows XP which is running on a 64 bit machine (Intel Core 2 Duo T7500)

    oxicottin

      Topic Starter


      Rookie

      • Experience: Beginner
      • OS: Windows 7
      Re: Find Drive letter for program files (86)
      « Reply #24 on: February 10, 2013, 06:53:30 AM »
       foxidrive, Im going to try that...... and see what happens!


      Salmon Trout, so what you saying is I might get a false reading if the system is 64bit capable but I installed a 32bit OS? Is there a way I could determine the capability of the CPU and displaying something like:

      "Your CPU is Capable of runing 64bit software but OS installed is 32bit" instead of your either a 32bit or 64 bit like I been doing. Salmon, I found Davids article while searching the other day and tried it the results on a 64bit PC running Win8 and it said:

      Code: [Select]
      @echo off

      IF PROCESSOR_ARCHITECTURE == amd64 OR
         PROCESSOR_ARCHITEW6432 == amd64 THEN
         echo. 64bit
      ELSE
         echo. 32bit

      echo.

      IF PROCESSOR_ARCHITECTURE == x86 AND
         PROCESSOR_ARCHITEW6432 NOT DEFINED THEN
         echo. 32bit
      ELSE
         echo. 64bit

      pause

      Results:




      Thanks... foxidrive & Salmon Trout

      Salmon Trout

      • Guest
      Re: Find Drive letter for program files (86)
      « Reply #25 on: February 10, 2013, 07:00:31 AM »
      What you copied was not batch code, it's pseudocode to describe the logic.


      oxicottin

        Topic Starter


        Rookie

        • Experience: Beginner
        • OS: Windows 7
        Re: Find Drive letter for program files (86)
        « Reply #26 on: February 10, 2013, 08:39:10 AM »
        Lol that would explain it then....

        Salmon Trout

        • Guest
        Re: Find Drive letter for program files (86)
        « Reply #27 on: February 10, 2013, 09:02:10 AM »
        Salmon Trout, so what you saying is I might get a false reading if the system is 64bit capable but I installed a 32bit OS?

        Yes. A 32 bit OS seems to report the CPU as x86 even if it is not, at least from batch. Of course in XP a user can go into Control Panel and click the System applet and see what kind of CPU they have.



        oxicottin

          Topic Starter


          Rookie

          • Experience: Beginner
          • OS: Windows 7
          Re: Find Drive letter for program files (86)
          « Reply #28 on: February 10, 2013, 09:20:35 AM »
          Ok so after reading around im finding if I use PROCESSOR_ARCHITECTURE it will tell me what my Processor is capable of not what OS im runing, Correct? Or the ::(Registry Code Start) code I posted finds the processor not the OS?

          Something like:

          Code: [Select]
          @echo off
          IF %processor_architecture% == AMD64 echo 64-bit
          IF %processor_architecture% == x86 echo 32-bit
          pause

          Then I need to find the OS ist running....


          Here is a chart I found...


          Salmon Trout

          • Guest
          Re: Find Drive letter for program files (86)
          « Reply #29 on: February 10, 2013, 12:39:31 PM »
          Ok so after reading around im finding if I use PROCESSOR_ARCHITECTURE it will tell me what my Processor is capable of not what OS im runing, Correct?

          Not quite. You can tell the OS type and in the case of a 64 bit OS you know you have a 64 bit cpu (because you already know a 64 bit OS can only run on 64 bit hardware)

          Whether or not a cpu is 64 bit, processor type will always be reported as x86 by a 32 bit operating system.
          Whether or not a cpu is 64 bit, processor type will always be reported as x86 by a 32 bit process in a 64 bit OS
          If a cpu is 64 bit, it will be correctly reported as AMD64 or IA64 by a 64 bit process in a 64 bit OS.

          of course you can find the CPU identifier from the registry, and if you happen to know what the ProcessorNameString means, then you can say if it's 32 or 64 bit.

          64 bit Windows 7 running on 64 bit CPU (AMD Phenom II 945)

          C:\>reg query HKLM\Hardware\Description\System\CentralProcessor\0

          HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0
              Component Information    REG_BINARY    00000000000000000000000000000000
              Identifier    REG_SZ    AMD64 Family 16 Model 4 Stepping 3
              Configuration Data    REG_FULL_RESOURCE_DESCRIPTOR    FFFFFFFFFFFFFFFF0000000000000000
              ProcessorNameString    REG_SZ    AMD Phenom(tm) II X4 945 Processor
              VendorIdentifier    REG_SZ    AuthenticAMD
              FeatureSet    REG_DWORD    0x203b7dfe
              ~MHz    REG_DWORD    0xbb8
              MicrocodeUpdateStatus    REG_SZ    Newer Patch Not Available
              PreviousPatchLevel    REG_DWORD    0x0
              CurrentPatchLevel    REG_DWORD    0x0
              PreferredPatchLevel    REG_DWORD    0x0


          32 bit Windows XP running on 64 bit CPU (Intel Core 2 Duo T7500)

          C:\>reg query HKLM\Hardware\Description\System\CentralProcessor\0

          ! REG.EXE VERSION 3.0

          HKEY_LOCAL_MACHINE\Hardware\Description\System\CentralProcessor\0
              Component Information       REG_BINARY      00000000000000000000000001000000
              Identifier  REG_SZ  x86 Family 6 Model 15 Stepping 11
              Configuration Data  REG_NONE        FFFFFFFFFFFFFFFF0000000000000000
              ProcessorNameString REG_SZ  Intel(R) Core(TM)2 Duo CPU     T7500  @ 2.20GHz
              VendorIdentifier    REG_SZ  GenuineIntel
              FeatureSet  REG_DWORD       0xa0033fff
              ~MHz        REG_DWORD       0x892
              Update Signature    REG_BINARY      00000000B3000000
              Update Status       REG_DWORD       0x6
              Previous Update Signature   REG_BINARY      00000000B3000000
              Platform ID REG_DWORD       0x80