I've got a VERY big pre-existing batch file that I need to add some logic to run the correct EXE depending on whether it is a x86 or x64 bit machine. I can't use PowerShell because for some reason they have it pseudo disabled on most of these machines.
What I'm trying to do is use PSEXEC to fetch the system variable PROCESSOR_ARCHITECTURE from the remote, then create a local system variable from the output.
If I run this command from a Win10x64 CMD prompt:
C:\PsTools>c:\pstools\PSEXEC.exe \\TEST-Win7x86 cmd /c echo ^%PROCESSOR_ARCHITECTURE^%
I get the correct remote x86 value, but can't do anything with it:
x86
cmd exited on TEST-Win7x86 with error code 0
.
I tried testing this method to get the output into a variable:
FOR /F "delims=" %i IN ('c:\pstools\PSEXEC.exe \\TEST-Win7x86 cmd /c echo ^%PROCESSOR_ARCHITECTURE^%') DO set proc=%i
I'm getting back the local AMD64 value:
cmd exited on TEST-Win7x86 with error code 0.
C:\PsTools>set proc=AMD64
.
Anyone spot what I'm doing wrong?
Thanks!
-Matt