1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Some questions

Discussion in 'Support' started by aedthuio, Dec 4, 2012.

  1. aedthuio

    Joined:
    Nov 3, 2012
    Messages:
    25
    Likes Received:
    0
    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?

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

    Thank you
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,307
    Likes Received:
    39
    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.

    REG.EXE is an external command. You can call it from either shell.
     
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,307
    Likes Received:
    39
    Later: It seems that CMD.EXE and TCC both supply a leading zero for times before 10:00. The different you're seeing may be because you're running the code at different times, rather than a difference between the two shells.
     
  4. aedthuio

    Joined:
    Nov 3, 2012
    Messages:
    25
    Likes Received:
    0
    Thank you Charles! Anyway is it correct to write the variables in this format, right?
    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:

    What do you think about my code?
     
  5. aedthuio

    Joined:
    Nov 3, 2012
    Messages:
    25
    Likes Received:
    0
    For the date question i've written a wrong format, sorry. This is the correct using
    CMD -> 05/12/2012[two spaces]4.39.55,45
    TCMD -> 05/12/2012[one space]4.39.55,45
     
  6. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,307
    Likes Received:
    39
    Frankly, it makes my eyes cross.... Wouldn't it be a lot simpler to just check %_WINVER instead of querying the registry?

    I'm not clear on how that doesn't work, but I suspect that kind of construction needs DuplicateBugs=Yes.
     
  7. Stefano Piccardi

    Joined:
    May 31, 2008
    Messages:
    376
    Likes Received:
    2
    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.
     
    AlterGeek likes this.
  8. aedthuio

    Joined:
    Nov 3, 2012
    Messages:
    25
    Likes Received:
    0
    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:

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

    TCMD.ini has already the "DuplicateBugs=Yes". Thank you
     
  9. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,307
    Likes Received:
    39

    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
    
     
  10. aedthuio

    Joined:
    Nov 3, 2012
    Messages:
    25
    Likes Received:
    0
    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?
     
  11. AlterGeek

    Joined:
    Oct 12, 2008
    Messages:
    7
    Likes Received:
    0
    As of Windows 8.1, the list of versions can be found at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
    One example of where it may be useful to know is that "My Documents" morphed into a "Documents" library as of Windows 7. If the latter must be used in file paths, presumably one can check _winver gt 6.0, but one would need to look further as to whether the libraries feature is present in Windows Server 2008.
     

Share This Page