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

How to? Handle unexpectedly inaccessible CWD

Discussion in 'Support' started by Steve Fabian, Jul 11, 2013.

  1. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    As I am sure many others do, my CWD is often on a network drive, and my TCC prompt displays CWD. However, the network is subject to failure, and when that happens, I want to:
    1/ terminate any command in progress that requires use of the network
    2/ if the CWD is no longer accessible change to an accessible default.

    I suspect ON ERROR is the primary method for 1/ above, and can deal with 2/ if the network failure occurs while a command is executed. However, how can I handle a network failure which occurs when TCC is waiting for a new command at the command prompt?
     
  2. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    680
    Likes Received:
    8
    Could you use the NETMONITOR command to check for a network failure?

    Joe
     
  3. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,860
    Likes Received:
    83
    The simple answer is no -- when TCC is at a prompt you can't interrupt it with another command.

    The more complicated answer is yes, if you want to write a plugin that monitors network connections and then sends a ^C / ^Break signal to TCC if a connection is lost. (And couple that with a PROMPT command that checks for this and switches the drive.)
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,959
    Likes Received:
    30
    I looked into this a bit. Subscribing to NetworkLocationAwareness (NLS service) is quite far from trivial and (IMHO) seems simply not worth the trouble. And even that, I believe, involves polling. In a plugin, a very simply thread could very efficiently poll for the availability of _CWD but (again IMHO) even that seems like overkill.

    Somewhere, I have code for an "EVERY" plugin command (EVERY N s|m|h command). You could probably use a simple (meant for the background) BTM to do some kind of monitoring. I abandoned that because I couldn't think of anything to do with it.
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,959
    Likes Received:
    30
    A question for Rex: It _CWD is a network path and I disconnect from the network, this test fails to detect it.
    Code:
    if ( !GetCurrentDirectory(MAX_PATH,szCwd) || !SetCurrentDirectory(szCwd) )
    That is, both functions continue to succeed. What fails in the expansion of _CWD causing this message from TCC?
    Code:
    \\lucky\v$> echo %_cwd
    TCC: (Sys) The specified network name is no longer available.
     
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,860
    Likes Received:
    83

    %_CWD first checks to see if the drive exists.
     
  7. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,959
    Likes Received:
    30
    How? The _CWD in question is "\\lucky\v$". I also tried IsPathDirectory() but that continues to succeed after a VPN has been connected.
     
  8. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,860
    Likes Received:
    83

    GetDriveType().
     
  9. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,959
    Likes Received:
    30
    OK, thanks. I'll try that. I can also get the desired message (net name no longer available) with CreateFile(FILE_READ_ATTRIBUTES).
     

Share This Page