05/04/2017 8807 views
When i try to give "$($env:ProgramFiles)\Tableau" it should resolve to "C:\Program Files\Tableau" on any architecture machine (64 bit or 32 bit). But it is resolving to: "C:\Program Files (x86)\Tableau" 

I tried with different methods:


$test=$env:ProgramFiles + "\abc"

but same problem persists.. 

P.S. I am running script with Psexec.

Thanks in advance.
Answer Summary:
5 Comments   [ + ] Show comments


  • I'm pretty sure PSExec is a 32bit program, so that might affect the results. Are you also sure that you are always installing the 64bit version of Tableau on 64bit machines?
  • okay... Yes I am installing 64 bit tableau on 64 bit machine..
  • i tried with 64 bit Psexec, still it is resolving to Program Files (x86)
  • Why are you using PSExec with powershell? You should just use Enter-PSSession instead, or Invoke-Command. Also, are you using KACE with this or is this just a question regarding Powershell?
  • I am using PS AppDeployment Toolkit. So, to execute it, i am opening cmd through Psexec and then running the command "Deploy-Application.exe Install" which will in turn invoke Deploy-Application.ps1" and start its installation.

Answer Chosen by the Author

Please keep in mind that environment variables are resolved according to the parent's process architecture/bitness. For example env. variable "ProgramFiles" is resolved to "C:\Program Files(x86)" by 32bit processes and as "C:\Program Files" for 64bit processes.
To list all environment variables for 64bit processes (ofc on 64 bit OS) you could run C:\WIndows\System32\cmd.exe type a 'set' command and hit Enter. For 32bit type a 'set' in the C:\Windows\SysWOW64\cmd.exe.

I'm guessing that you are starting your script from 32bit parent process and then (usually, if you do not use SYSNATIVE call) child process inherits the architecture/bitness of the execution environment - in this case 32 bit environment and that's why "ProgramFiles" variable is resolved to "C:\Program Files (x86)\"

Please see a simple test with your script. Left window presents 64bit parent process (cmd.exe) while on the right side you can see 32 bit environment (\SysWOW64\CMD.EXE) - the second execution in the 32bit env (marked in blue) shows usage of SYSNATIVE which allows to jump out of the 32bit env to the native architecture:

As you have mentioned that you need to run your script on both (32 and 64 bit) OSes I would suggest to add some logic to OS Architecture detection and then use "ProgramFiles" on a 32bit OS and "ProgramW6432" on a 64 bit OS. Something like this:

$OSArch = (Get-WmiObject Win32_OperatingSystem).OSArchitecture
If ($OSArch -like '64*') {
} else
Answered 05/04/2017 by: rad33k
Second Degree Brown Belt

  • Thanks a lot..!!! You made me the happiest girl today!!! :) It worked perfectly..!!!!!

All Answers

Open Powershell and use Invoke-Command

If you don't know how to use Invoke-Command, I'd encourage you to use the Get-Help Cmdlt to get info on how to use Invoke-Command. To do that, enter the the following into powershell.

Get-Help Invoke-Command

Now this is the command you'll want to use to deploy tableau, though you'll need to make some modifications.

Invoke-Command -ComputerName <computername> -ScriptBlock {"<Directory of Tableau EXE>\TableauDesktop-64bit.exe /install /norestart /quiet AUTOUPDATE=0 ACCEPTEULA=1"}

Replace <computername> with the name of the machine you want to install tableau on.

Replace <Diractory of Tableau EXE> with the directory where the Tableau executable is

Finally replace TableauDestop-64bit.exe with the name of the tableau install file.

The /norestart switch disables restarting, the /quiet switch ensures the user doesn't see the install occuring, the AUTOUPDATE=0 option disables auto-updating, and the ACCEPTEULA=1 option prevents the User from having to click "accept" on the end user license agreement which helps prevent them from getting confused.

Answered 05/04/2017 by: Drave
Orange Senior Belt

  • Thanks for the help. But, this is not about the tableau install. Actually, I wanted to remove the empty folders tableau is leaving after the uninstall. So, I need it to resolve to C:\Program Files\.. but it is resolving to C:\Program Files (x86)\..