Problem without solution?

Apr 10, 2013
14
0
hello all,

still evaluating the program (x64) on Windows 7 Ultimate.

This simple fragment causes a problem:

if %PROCESSOR_ARCHITECTURE% equ "x86" (
set programdir=%programfiles%
) else (
set programdir=%programfiles(x86)%
)

If TCMD.ini doesn't contain the CMDVariables=Yes option the programdir variable is evaluated incorrectly. If the option is present, programdir evaluates correctly but I'm not able to see variable values in the watch window.

How to resolve?
Salvatore

P.S.: I had to edit this post eight times to be able to insert all text... :-)
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
Salvatore, I assume you are trying to locate a specific executable (or executables). I need to locate devenv.exe on either 32 or 64 bit systems when running our unit test build script. I do the following:
Code:
set devenv=%@regquery[HKCU\Software\Microsoft\VisualStudio\10.0_Config\InstallDir]devenv.exe
If you *have* to have CMD compatibility, then you could do it this way:
Code:
for /f "skip=2 tokens=2*" %f in ('reg query HKCU\Software\Microsoft\VisualStudio\10.0_Config /v InstallDir') do set devenv=%gdevenv.exe
-Scott
 
Apr 10, 2013
14
0
good morning,
Salvatore, I assume you are trying to locate a specific executable (or executables).
no, no, no. I'm simply assigning the correct program files folder to the variable depending on the architecture for later use. As you know, the 32 bit program files folder on 64 bit systems has a " (x86)" appended to the classic (localized) Program Files name. I cannot add it manually because parenthesis are seen as errors in multi-command if's statements (see batch example in my original message). If I use the CMDVariables=Yes option the system variable is evaluated correctly, but it seems that I'm no longer able to watch variables when debugging, example: Watching the programdir variable the content shown is %programdir instead of the real value. If I don't use the CMDVariables option, TC cannot evaluate the environment variable correctly due to presence of the parenthesis in its name.

S.
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
Charles, I was going to say that @shfolder[42] doesn't exist on 32 bit systems. But Salvatore also said something about needing the scripts to run in CMD.
 
How To Check If Computer Is Running A 32 Bit or 64 Bit Operating System

http://support.microsoft.com/kb/556009

You can use the following registry location to check if computer is running 32 or 64 bit of Windows Operating System:

HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0

You will see the following registry entries in the right pane:

Identifier REG_SZ x86 Family 6 Model 14 Stepping 12
Platform ID REG_DWORD 0x00000020(32)

The above “x86” and “0x00000020(32)” indicate that the Operating System version is 32 bit.

You can also a simple batch file to check the setting on remote computer:

*** Start ***

@echo off

Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0

REG.exe Query %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"
)

*** End ***

You can use PSEXEC (a tool from Sysinternals) to run this script remotely redirect the output in a Text file.

To query registry entry on a remote computer you can use the following statement with Reg.exe:

Reg.exe Query \\computer_name\%Reg_Qry% > checkOS.txt

Please note that you can use the below registry entry to identify the processor architecture:

HKLM\SYSTEM\CurrentCongtrolSet\Control\Session Manager\Envirornment.

You can see the below registry entry in the right pane of the registry editor:

PROCESSOR_ARCHITECTURE REG_SZ x86

Joe
 
Apr 10, 2013
14
0
hello,

while I thank you all for your interest in this problem, I also want to better clarify it. The purpose of the batch script is to compile some Delphi components, and one of the requisites is to identify where Delphi is sitting to get the compiler executable. The Delphi IDE is a 32 bit application, so on 32 bit machines the root of the installation is in C:\Program Files\Embarcadero\RAD studio\x.0 while on 64 bit machines it is in C:\Program Files (x86)\Embarcadero\RAD studio\x.0 so a simple interrogation of the PROCESSOR_ARCHITECTURE environment variable is enough to know how to build the path, to which the bin folder is appended (the compiler lives in the bin folder), without inventing fanciful solutions involving the registry or external programs. Running well in CMD also is not an option, and the only problem are CMD limitations that I try to resolve. TC seems to be a good help when building batch files, but maintaining CMD compatibility is also not an option.

Salvatore
 
Apr 10, 2013
14
0
hello,

after fighting for a couple of hours on internet, this seems to be the only solution that works both in CMD and TC:

Code:
set _tmp1=%programfiles%
rem extracts the last 2 characters from variable
set _cpu=%PROCESSOR_ARCHITECTURE:~-2%
if %_cpu% equ 64 (
  set _tmp2= ^(x86^)
)
set programdir=%_tmp1%%_tmp2%
echo %_tmp1%
echo %_tmp2%
echo %programdir%

Tested and it works in both environments. BTW, is there any comprehensive guide to all the possible tricks in batch files?

Salvatore
 
Apr 10, 2013
14
0
mmmh, simplified version that works:

Code:
rem extracts the last 2 characters from variable
set _cpu=%PROCESSOR_ARCHITECTURE:~-2%
if %_cpu% equ 64 (
  set programdir=%programfiles% ^(x86^)
) else (
  set programdir=%programfiles%
)
set _cpu=
echo %programdir%

As you can see in both examples, I don't use the ProgramFiles(x86) environment variable any longer, but the substance doesn't change.

Salvatore
 
Similar threads
Thread starter Title Forum Replies Date
Dick Johnson Weird Color Problem Support 8
fishman@panix.com Problem with 27.15 Support 2
M Problem with VSDevCmd.bat in VS 16.7.3 Support 0
R Problem with @INT[ value] in V26 Support 9
M Selecting test "off by one" problem in Take command Support 4
Alpengreis UTF-8 problem in TCC related to Python Support 7
K_Meinhard Small problem in german IDE 26 Support 3
B Problem with color in nested shells Support 1
Joe Caverly Problem creating and switching to a DESKTOP Support 9
vefatica Another popup problem Support 10
Alpengreis ffind dialog (/W) problem Support 4
Alpengreis [TCMD v25.00.24] Small space problem with the DE translation in Prefs-GUI Support 1
Alpengreis [TCMD v25.00.24] Problem with copy and paste and the # char via mouse in TCC Support 6
A Problem with functions @int @decimal and identifying Powershell as a shell. Support 12
B IF command problem in tcexit.btm Support 9
fishman@panix.com Problem at Startup of TCC Support 3
P Problem with SFTP copies Support 7
P Problem with FTP copies Support 10
Jay Sage Problem with Context Menu Copy+Paste+Run Key Assignment Support 7
R Problem with %_do_loop in nested do loops Support 2
fishman@panix.com New Problem with later Windows 10 Support 10
Peter Murschall A little problem with LEAVE and COMMENT Support 5
M Handling of %~I problem Support 4
WinLanEm FOR problem Support 18
K Problem With SCRPUT /u Support 3
vefatica What's TCMD's problem with ^e[0m? Support 13
Peter Murschall IDE: RTL with non-English resources-problem is back in Build 28 Support 4
rps Regex problem: \xnn not recognized as a hex character Support 0
rps PRIORITY LOW problem Support 1
old coot Regex problem: \xnn not recognized as a hex character Support 12
vefatica Another problem with build 22. Support 3
Alpengreis [23.x] Download-Problem Support 2
S Problem with " Support 3
C Problem navigating forums Support 11
x13 Problem listing repository files using DIR http(s)://... Support 8
Joe Caverly Problem with TEE in v22 Support 2
Alpengreis Problem with thousands delimiter and colors Support 17
M Take Command 18, migrating to another machine, license problem. Support 1
B TCC 21.01.50 Problem with ALIAS /r and SET /r Support 2
rps How to? @search problem Support 2
WinLanEm @SELECT problem Support 6
T Fixed Problem with use of Batch parameters in the IDE Support 1
Oz Solomon Problem with "list" Support 14
S V21.24 theme problem Support 2
Alpengreis Problem if command prompt is not legacy Support 4
Alpengreis TCMD.INI: The "super hidden" problem ... Support 6
G Odd problem - screen brightness Support 4
rps V20 In-process pipes problem Support 8
Alpengreis Again theme problem [v20.0.21]? Support 11
WinLanEm INPUT problem Support 1

Similar threads