Using environment variable to call an exe

by Nov 11, 2014


I'm trying to call a command in PowerShell using an environment variable.  Using cmd, I would call the exe using the following command %userprofile%somefolderrandom.exe.  When I use this command, $env:homepathsomefolderrandom.exe, I get an unexpected token error.  Browsing the web, I found this command ~somefolderrandom.exe and this works, but I don't understand why it works and $env:homepathsomefolderrandom.exe doesn't to call the script?