Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. %programfiles% in windows inconsistent
Forum Update on Monday, May 27th 2025

%programfiles% in windows inconsistent

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 267 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Seb TurS Offline
    Seb TurS Offline
    Seb Tur
    wrote on last edited by
    #1

    Hi
    I have created a .bat file for troubleshooting and found an interesting behavior, maybe somebody can explain why it works this way:

    first line runs
    echo "%programfiles%">path.txt

    when I run the bat from a QProcess and check path.txt showing
    "C:\Program Files (x86)"

    when I run the bat by windows cmd i get path.txt showing
    "C:\Program Files"

    why is that?

    Chris KawaC 1 Reply Last reply
    0
    • Seb TurS Seb Tur

      Hi
      I have created a .bat file for troubleshooting and found an interesting behavior, maybe somebody can explain why it works this way:

      first line runs
      echo "%programfiles%">path.txt

      when I run the bat from a QProcess and check path.txt showing
      "C:\Program Files (x86)"

      when I run the bat by windows cmd i get path.txt showing
      "C:\Program Files"

      why is that?

      Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      why is that?

      You haven't said what type of app you're running, but apparently it's a 32bit application, so Windows puts you in the 32bit environment and %programfiles% points to the 32bit program files directory, which is C:\Program Files (x86).

      cmd is a 64bit app so it runs in 64bit environment and %programfiles% points to 64bit program files directory, which is C:\Program Files.

      Note that if you'd run cmd from the C:\Windows\SysWOW64\ directory instead of the default one from C:\Windows\System32\ you'd get the 32bit version and %programfiles% would also point to C:\Program Files (x86).

      1 Reply Last reply
      4
      • Seb TurS Seb Tur has marked this topic as solved on

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved