I have a windows cmd file that is making use of the %CD% environment variable to determine the execution directory of the cmd file.
When I run the cmd file from the command line it works correctly, meaning that the %CD% variable contains the working directory. If I double left click the cmd it also works as I expect. However if I right click the cmd file and select runas administrator then the %CD% variable contains the value "C:\Windows\system32" not the curent directory where the cmd is executing.
I was able to reproduce the problem with the following script:
echo %CD%
pause