PUSHD/POPD and Temporary Drive Letters

  • I have a DOS Batch Process setup which polls an FTP Site and downloads text files to our File Server using the PUSHD and UNC Path Name. If the text files are not on the FTP Site, the Batch Process sleeps for 10 minutes and checks the FTP Site again. The problem I am having is when this process has to poll the Site many times, all of the Temporary Drive letters are used up by the PUSHD Command within this polling process. Normally, I would reboot the server to free up the temporary drive letters. If I do not reboot the server, the next time this Batch File runs I receive the error "... is an invalid current directory path. UNC paths are not supported."

    I am now wondering if I need to insert the POPD Command in this Batch File to remove the temporary drive letter created by each execution (within the loop) of the PUSHD Command. Is there any DOS Command I can execute to see which temporay drive letters have been assigned? And then execute a POPD Command to see if it actually removes that temporary drive letter.

    Thanks in advance, Kevin

     

  • you simply need to put the popd command in there.

     

    if you wanted to do something like... get the current drive mapping (the one that was mapped by pushd) , popd, ensure it's not mapped you could do something like....

    for /f "delims=:" %i in ('cd') do set currentdriveletter=%i

    popd

    for /f "tokens=2" %i in ('net use') do if %i.==%currentdriveletter%:. net use %i /d

     

    note that in batch files you need to use double % signs in the for command that aren't environment variables. ie

    for /f %%i in ('dir * /b') do @echo %%i

     

    none of that should be required though, popd will remove the most recent pushd mapping.

     

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply