There are a couple of things wrong with your code.
When assigning your %directory% variable you use \\%1%\c$\Program Files (x86). Here %1% should be %1
You are using the c$ share, which is mostly not available anymore (or at least not without administative privilidges)
It could work like this:
@echo off
setlocal enabledelayedexpansion
echo Welcome
call :ping 192.168.1.1
echo.
echo done with everything
goto eof
:ping
echo Probing %1 ...
set pingtest=false
ping -n 1 %1 | find "Approximate round trip" > nul
IF %ERRORLEVEL% == 0 (
set tdir="\\%1\c$\Program Files (x86)"
echo Looking up !tdir!
dir !tdir!
if !ERRORLEVEL! == 0 (
set arch=64bit
) else (
set arch=32bit
)
echo Architecutre of %1 is: !arch! >> output.txt
) else (
echo Remote host unreachable: %1 >> output.exe
)
goto eof
BUT:
This will return 64bit for every machine that runs the microsoft sharing service or samba and that does not share C$ to just anyone, as dir will only return a non zero ERRORLEVEL when the target does not provide that service or generally is unavailable.
On the other hand every machine that does not provide the shareing service at all, will be marked as 32bit
For any machine that does provide access to it's root drive (which none should) the script does work.
Here is a more reliably method of checking for 32/64 bit Windows OS
@echo off
set RemoteHost=192.168.1.100
set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
reg \\%RemoteHost%\%RegQry% > checkOS.txt
find /i "x86" < CheckOS.txt > StringCheck.txt
IF %ERRORLEVEL% == 0 (
echo "This is 32 Bit Operating system"
) ELSE (
echo "This is 64 Bit Operating System"
)
[source]
This one utilizes the reg.exe that can query the registry of remote Windows NT machines.
There is also the possiblity of utilizing wmic: Example
%too much inset directory="\\%1%\c$\Program Files (x86)\" (probably a typo, because you are using%1` correctly in other lines).