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

Not real important but kind of annoying EXIT issue...

Discussion in 'Support' started by mathewsdw, Aug 4, 2011.

  1. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    As I have mentioned before on this forum, I have poor eyesight and depend on the Windows "Magnify" application to see what I am doing. Because of this, I have a .btm file to start the "magnify" program and then "up" its priority (it is often essentially useless when run at its "normal" priority). Contents of said .btm file (modified slightly to turn echo ON and run from my Z: drive) are below:
    Code:
    @Echo On
    Iff "%1" == "" Then
       Start /Elevated /B /LA /LD /LF /LH /PGM Z:\DoMagnify.btm Elevated
       Quit 0
    EndIff
    Iff %@PID[Magnify.exe] == 0 Then
       C:\Windows\System32\Magnify.exe
       Delay 1
    EndIff
    Do While %@PID[Magnify.exe] == 0
       Delay 1
    EndDo
    PRIORITY %@PID[Magnify.exe] ABOVE
    Exit 0
    
    The output that is then displayed is:
    Code:
    ISO8601 plugin v1.1.1 loaded.
    SafeChars plugin v1.4.0 loaded.
    
    TCC  12.10.66   Windows 7 [Version 6.1.7601]
    Copyright 2011  Rex Conn & JP Software Inc.  All Rights Reserved
    Registered to Daniel Mathews
    
    Iff "%1" == "" Then
    Iff %@PID[Magnify.exe] == 0 Then
    Do While %@PID[Magnify.exe] == 0
    PRIORITY 5232 ABOVE
    Exit 0
    
    As might be able to see from the above, the batch file "hangs" at the "Exit" command when run.

    So replacing the "Exit" command by a "Quit" command, the batch file runs normally and then quits, leaving the "Started" command window still open (which I obviously don't want). Typing the "Exit" command in that command window then causes that command window to "hang" without actually exiting, just to be clear about it. What is going on here?

    And, as it says above, TCC 12.10.66 Windows 7 [Version 6.1.7601]
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,304
    Likes Received:
    39
    Do you have a TCEXIT file?

    Do you see the same issue if you start TCC without any plugins?
     
  3. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Charles, good guesses but no. I do not have a TCEXIT file (neither that I can remember (and I don't have any idea what I would have put into it), or find), and disabling plugins by temporarily renaming the "plugins" directory (and they then did not load) had no effect.

    New Data!!!!! It turns out that the command "Start /Elevated" starts a new TCC session that then "hangs" if "Exit" is typed as the first and only command in that session.
     
  4. Kachupp

    Joined:
    Aug 9, 2009
    Messages:
    133
    Likes Received:
    0
    From what I see below you have HARD CODED the PID. 5232, I'm sure the
    PID will change every time you
    start the magnify.exe
    The hang maybe because you are trying to up the ante on another process
    with that PID

    single line no loops no iffs simple one liner batchfile.

    priority %@pid[magnify.exe] above

    -----Original Message-----
    From: mathewsdw

    Iff "%1" == "" Then
    Iff %@PID[Magnify.exe] == 0 Then
    Do While %@PID[Magnify.exe] == 0
    PRIORITY 5232 ABOVE
    Exit 0
    ---------
    As might be able to see from the above, the batch file "hangs" at the
    "Exit" command when run.

    So replacing the "Exit" command by a "Quit" command, the batch file runs
    normally and then quits, leaving the "Started" command window still open
    (which I obviously don't want). Typing the "Exit" command in that
    command window then causes that command window to "hang" without
    actually exiting, just to be clear about it. What is going on here?

    And, as it says above, TCC 12.10.66 Windows 7 [Version 6.1.7601]
     
  5. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,855
    Likes Received:
    83
    How are you running the batch file -- from the Windows desktop or Explorer? If so, then the "hang" will be because of your shortcut settings. (Or your .btm file association settings.)
     
  6. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    From: Kachupp
    | From what I see below you have HARD CODED the PID. 5232, I'm sure the
    | PID will change every time you
    | start the magnify.exe
    | The hang maybe because you are trying to up the ante on another
    | process
    | with that PID
    |
    | single line no loops no iffs simple one liner batchfile.
    |
    | priority %@pid[magnify.exe] above

    You ignored the original post, which clearly showed the OP's batch file containing the exact command you recommended, and line with the string 5232 as the ECHO of that command!
    And yes, the OP's batch file is well thought out and contains no unnecessary loops or IFF-s - they are needed to allow the OS to start the requested program, since its priority can only be changed AFTER it has started to run.
    --
    Steve
     
  7. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    From: mathewsdw
    | As I have mentioned before on this forum, I have poor eyesight and
    | depend on the Windows "Magnify" application to see what I am doing.
    | Because of this, I have a .btm file to start the "magnify" program
    | and then "up" its priority (it is often essentially useless when run
    | at its "normal" priority). Contents of said .btm file (modified
    | slightly to turn echo ON and run from my Z: drive) are below:
    | Code:
    | @Echo On
    | Iff "%1" == "" Then
    | Start /Elevated /B /LA /LD /LF /LH /PGM Z:\DoMagnify.btm Elevated
    | Quit 0
    | EndIff
    | Iff %@PID[Magnify.exe] == 0 Then
    | C:\Windows\System32\Magnify.exe
    | Delay 1
    | EndIff
    | Do While %@PID[Magnify.exe] == 0
    | Delay 1
    | EndDo
    | PRIORITY %@PID[Magnify.exe] ABOVE
    | Exit 0

    What would happen if from any instance of TCC you issue the command:
     
  8. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    From: mathewsdw
    | As I have mentioned before on this forum, I have poor eyesight and
    | depend on the Windows "Magnify" application to see what I am doing.
    | Because of this, I have a .btm file to start the "magnify" program
    | and then "up" its priority (it is often essentially useless when run
    | at its "normal" priority). Contents of said .btm file (modified
    | slightly to turn echo ON and run from my Z: drive) are below:
    | Code:
    | @Echo On
    | Iff "%1" == "" Then
    | Start /Elevated /B /LA /LD /LF /LH /PGM Z:\DoMagnify.btm Elevated
    | Quit 0
    | EndIff
    | Iff %@PID[Magnify.exe] == 0 Then
    | C:\Windows\System32\Magnify.exe
    | Delay 1
    | EndIff
    | Do While %@PID[Magnify.exe] == 0
    | Delay 1
    | EndDo
    | PRIORITY %@PID[Magnify.exe] ABOVE
    | Exit 0

    What would happen if from any instance of TCC you issue the command:

    start /elevated /abovenormal C:\Windows\System32\Magnify.exe

    --
    Steve
     
  9. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    I really don't understand your comment about "HARD CODED". I do not, did not and absolutely never would do such a thing. If you look at the above .btm file a little more closely, you will see that the PID is coming from the @PID function.
     
  10. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Rex, for a long list of reasons related to my disabilities I literally almost never run a batch file or anything else for that matter from the Windows desktop or Explorer; I run everything virtually without exception from a command prompt. (I have aliases or batch files for everything I run on any sort of regular basis; I may use the start menu if it is something I almost never run and therefore didn't make an alias or batch file for, but even then I typically CDD into the directory containing the application and run it from there.) I don't think there's much more to say on this matter...
     
  11. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Steve, I am laughing as I type this! The batch file in question was written years ago and has been modified/updated as TCC/TCMD have been updated, and I was not aware of the "/AboveNormal" option. That of course allows me to eliminate the batch file altogether and just use an alias, which I just tried and works fine!!! (As I indicated earlier, the problem was not with the batch file itself in any way.) But Rex, there is still an issue with "Start /Elevated" starting a TCC session that "EXIT" does not terminate...
     
  12. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,304
    Likes Received:
    39
    He's confusing the output of the batch file (ECHO ON) with the batch file itself. An easy mistake to make, I'd say.
     
  13. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,304
    Likes Received:
    39
    The .BTM association might still be the issue, if you're using START to launch it.
     
  14. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,304
    Likes Received:
    39
    And after looking again, I see your batch file uses START to relaunch itself if it finds it's running without administrative powers....
     
  15. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,304
    Likes Received:
    39
    For grins, you might try changing that third line to

    Code:
    Start /Elevated /B /LA /LD /LF /LH /PGM %_Cmdspec /C Z:\DoMagnify.btm Elevated
    
    and see if that resolves the problem.
     
  16. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,855
    Likes Received:
    83
    You need to use the /C option in START if you want it to close the window
    when the batch file terminates.

    Rex Conn
    JP Software
     
  17. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Rex, of course you are correct (could you be anything but?) and in the long-term evolution of the command in question, I never noticed that. But be that as it may, shouldn't an "Exit" command actually exit the session, rather than hang?
     
  18. DMcCunney

    Joined:
    Jun 7, 2008
    Messages:
    96
    Likes Received:
    3
    On Thu, Aug 4, 2011 at 11:18 PM, mathewsdw <> wrote:

    Depends on what the exit is exiting *from*. In this case, the exit
    will exit from the batch file it's embedded in, but unless you tell
    Windows to close the window when the batch file terminates, Windows
    will keep it open. That's what the /c command line parm is all about
    - it tells Windows to close the window when whatever is running in it
    finishes.
    ______
    Dennis
     
  19. Kachupp

    Joined:
    Aug 9, 2009
    Messages:
    133
    Likes Received:
    0
    5232 < hard coded the pid, which if you got the PID from @pid after many
    (testing) instance of running the same app wouldn't of repeated
    the same PID, it would be a new instance of the same program running and
    a new PID. I've never use magnify it self, if its _able_ to run more
    than ONE-1 instance
    of it, it would not return the same PID 5232 HARD CODE in your batch
    HARD CODED < priority has no option other than to except your PID input,
    PID being 5232

    [Steve]
    -Steve, IF he had started magnify on its own and used priority
    %@pid[magnify.exe] above
    -it would make the contents of the original batch file superfluous.
    -he could start it as a service _and_ .or. a scheduled tasks
    -services.msc GroupPolicyEditor what ever its called (pro vers/elite
    home users) allows scripts USER todo what EVER they want, onBOOT
    -Are you allowed to ignore that in vista/w7 ? - XP buggy as Rexx has
    pointed out to Vince allows you to do just that. "MY SYSTEM DO WHAT EVER
    I WANT IT TO DO"

    do what i mean not what i say "DWIM" ?
    I forget the term Rexx uses for that

    -----Original Message-----
    From: mathewsdw
    Subject: RE: [Support-t-3033] Re: Not real important but kind of
    annoying EXIT issue...


    ---Quote (Originally by Kachupp)---
    From what I see below you have HARD CODED the PID. 5232, I'm sure the
    PID will change every time you
    start the magnify.exe
    The hang maybe because you are trying to up the ante on another process
    with that PID

    single line no loops no iffs simple one liner batchfile.

    priority %@pid[magnify.exe] above

    -----Original Message-----
    From: mathewsdw

    Iff "%1" == "" Then
    Iff %@PID[Magnify.exe] == 0 Then
    Do While %@PID[Magnify.exe] == 0
    PRIORITY 5232 ABOVE
    Exit 0
    ---------
    As might be able to see from the above, the batch file "hangs" at the
    "Exit" command when run.

    So replacing the "Exit" command by a "Quit" command, the batch file runs
    normally and then quits, leaving the "Started" command window still open
    (which I obviously don't want). Typing the "Exit" command in that
    command window then causes that command window to "hang" without
    actually exiting, just to be clear about it. What is going on here?

    And, as it says above, TCC 12.10.66 Windows 7 [Version 6.1.7601]
    ---End Quote---
    I really don't understand your comment about "HARD CODED". I *do not*,
    *did not* and *absolutely never would* do such a thing. If you look at
    the above .btm file a little more closely, you will see that the PID is
    coming from the @PID function.
     
  20. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Not to be a contrarian, Dennis, but that is simply not the case. To quote the help file: "EXIT terminates the current copy of the command processor". And more from the help file: "/B Exit the current batch file, rather than the shell." You are welcome, of course, to look it up in the help file yourself.
     
  21. Steve Pitts

    Joined:
    Jul 7, 2008
    Messages:
    159
    Likes Received:
    0
    I am confused. Based on past experience I would expect a START /C that invoked a .BTM file to close the window irrespective of any EXIT command in the batch file, and a START /K (or with neither switch) to leave that window open unless the batch file contained an EXIT. A bout of testing suggests that is exactly how the latest TCC behaves here.


    TCC 12.11.73 x64 Windows 7 [Version 6.1.7601]
    TCC Build 73 Windows 7 Build 7601 Service Pack 1
     

Share This Page