Solution
Instead of specifying the path C:\Windows\System32 use the special alias %WINDIR%\Sysnative
function fn_fecha()
{
WshShell = new ActiveXObject("WScript.Shell");
WshShell.Run("%WINDIR%/Sysnative/logoff.exe");
}
Explanation
Your 32-bit application is trying to access code in the %Windir%\System32 folder which is reserved for 64-bit code. Windows is silently redirecting your request as explained by this Microsoft KB article:
On a computer that is running a 64-bit version of Windows...a 32-bit application cannot access the following folder:
%WinDir%\System32
Therefore, the 32-bit application cannot start any 64-bit applications in the System32 folder. Additionally, the 32-bit application cannot retrieve file information about any files in the System32 folder or in the subfolders of the System32 folder....
This behavior occurs because Windows on Windows 64-bit (WOW64)
provides file system redirection. In a 64-bit version of Windows...the %WinDir%\System32 folder is reserved
for 64-bit applications. When a 32-bit application tries to access the
System32 folder, access is redirected to the following folder:
%WinDir%\SysWOW64
By default, file system redirection is enabled.
In your case logoff.exe
doesn't exist in the SysWOW64 folder, producing the file not found error. The article explains that the special alias %WinDir%\Sysnative bypasses the unwanted file redirection:
WOW64 recognizes the Sysnative folder as a special alias. Therefore, the file system does not redirect access away from the Sysnative folder. This mechanism is flexible and easy to use. You can use the Sysnative folder to bypass file system redirection.
Note that the hotfix mentioned in the article only applies to Windows Server 2003/XP. This functionality is built in to later versions of Windows.