Some questions

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Nov 3, 2012
25
0
#1
Hi guys, i've two questions:

1) In cmd.exe if i write:
ECHO=%DATE%%TIME%
i get the actual date and the time separated by a space (2012/12/05 10.20.30,00)
Why with Take Command the date and the time are non separated by the space? I must write
ECHO=%DATE% %TIME%
. Do you know explain that?

2) In cmd.exe i can use "REG QUERY". Does it work with Take Command or i must use the "@REGQUERY" function?

Thank you
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,376
39
Albuquerque, NM
prospero.unm.edu
#2
Hi guys, i've two questions:

1) In cmd.exe if i write:
i get the actual date and the time separated by a space (2012/12/05 10.20.30,00)
Why with Take Command the date and the time are non separated by the space? I must write . Do you know explain that?
Not here; on my computer, that command mashes the date and time together in both shells. (%DATE does return the date in a different format in TCC though; CMD.EXE gives the day of the week, TCC doesn't.)

Is it possible that CMD.EXE provides a leading space for one-digit hours? I haven't checked.

2) In cmd.exe i can use "REG QUERY". Does it work with Take Command or i must use the "@REGQUERY" function?
REG.EXE is an external command. You can call it from either shell.
 
Nov 3, 2012
25
0
#4
Thank you Charles! Anyway is it correct to write the variables in this format, right?
ECHO=%DATE% %TIME%
For the second question, i prefer to use REG QUERY. In cmd.exe it works, while with Take Command it seems not work (sure my code is bugged). I write an example:

REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion|FIND "6.2">NUL 2>&1&&(
IF "%PROCESSOR_ARCHITECTURE%"=="x86" (
ECHO=You're running Windows 8 x86)
IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
ECHO=You're running Windows 8 x64))||(
IF "%PROCESSOR_ARCHITECTURE%"=="x86" (
ECHO=You're running Windows x86)
IF "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
ECHO=You're running Windows x64))
What do you think about my code?
 
May 31, 2008
376
2
#7
aedthuio, if you end up using %_winver - and your script needs to work with all regional settings - pay attention to using dot as the decimal separator instead of assuming that the system setting will magically work. Example:
Code:
setdos /G".,"
iff %_winver% GT 5.2 then
  echo after WinXP
elseiff %_winver GT 6.0 then
  echo after ...
endiff
setdos /G0
Without the SETDOS /G commands the code above will subtly fail on some regional settings.
Give the same treatment to %_4ver%.
And pay attention to %@ functions. One notable pitfall:
Code:
set c23=X%@if[%_4ver GE 14,Y]
on systems with English regional settings you get c23=XX when TCC's version is below 14 and c23=XY otherwise.
But on systems wihere comma is the decimal separator you get c23=X%@if[%_4ver GE 14,14,02,X] (for TCC version "14,02") which yields an unexpected c23=X14 in some cases.
 
Likes: AlterGeek
Nov 3, 2012
25
0
#8
Hi guys, i've a new problem, could you help me please? This is my batch:

Code:
SET "Opening=Opening %%~nA..."
 
FOR /R %%A IN (filename.exe*) DO (
        SET _=T
        ECHO=%Opening%>>"%~dp0log.txt"
        START "" /MIN /WAIT "%%A")
If "filename.exe" exists it should write a "log.txt" file with written:

Opening filename...
With cmd.exe all works, while with tcmd.exe the log file is:

Opening ...
TCMD.ini has already the "DuplicateBugs=Yes". Thank you
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,376
39
Albuquerque, NM
prospero.unm.edu
#9
Code:
SET "Opening=Opening %%~nA..."

You're putting one of those CMD.EXE FOR-variable things inside an environment variable. I don't know whether Rex intended to support such a construction. (In fact, I can't even find any documentation of any of that FOR-variable stuff anywhere in the help file; I'd consider it a bonus that it even works outside an environment variable.)

I'd respectfully suggest that you let go of FOR; it's inherently a single-line construct, and its peculiar syntax is unusable everywhere else. Instead, consider rewriting your loop to use DO:

Code:
do file in filename.exe*
   echo Opening %file >>! "%@path[%_batchname]log.txt"
   start "" /min /wait "%file"
   rem ...
enddo
 
Nov 3, 2012
25
0
#10
Thank you Charles, i've found that if the "SET" command is inside the "FOR" all works:

Code:
FOR /R %%A IN (filename.exe*) DO (
        SET "Opening=Opening %%~nA..."
        ECHO=%Opening%>>"%~dp0log.txt"
        START "" /MIN /WAIT "%%A")
Does exist a way to fix it keeping the SET outside the FOR?
 
Oct 12, 2008
7
0
#11