Batch file exiting problem

Discussion in 'Scripting' started by didobg, Feb 22, 2013.

  1. didobg

    didobg MDL Novice

    Apr 4, 2011
    2
    0
    0
    Please can anyone tell me why the command prompt window does'nt close at the end.
    This is my script
    Cls
    @ECHO OFF
    :Start
    ECHO Do you wish to logout?
    set /p answer=Enter Y or N:
    if /i {%answer%}=={n} goto :Stay
    if /i {%answer%}=={y} goto :Continue
    cls
    goto :Start
    :Continue
    TASKKILL /IM "EXPLORER.EXE" /F
    cls
    NET USE \\DISKSTATION /DELETE
    cls
    EXPLORER.EXE
    :END
    EXIT
     
  2. Robin Hood

    Robin Hood MDL Novice

    Mar 20, 2011
    46
    3
    0
    #2 Robin Hood, Feb 25, 2013
    Last edited: Feb 25, 2013
    ...Hope this might help. Seems you forgot the ":Stay" - bit...i would suggest leave the "Explorer" entry... :)


    @ECHO OFF
    cls

    :Start
    ECHO Do you wish to logout?
    set /p answer=Enter y or n:
    if /i {%answer%}=={n} goto :Stay
    if /i {%answer%}=={y} goto :Continue

    :Stay
    goto :Start

    :Continue
    cls
    NET USE \\DISKSTATION /DELETE
    cls

    :END
    EXIT
     
  3. didobg

    didobg MDL Novice

    Apr 4, 2011
    2
    0
    0
    Thanks for the suggestion. Unfortunately I need to forcefully close the opened explorer window so the network connection can be successfully deleted. Do you have any suggestions how to do that???
     
  4. Robin Hood

    Robin Hood MDL Novice

    Mar 20, 2011
    46
    3
    0
    #4 Robin Hood, Feb 27, 2013
    Last edited: Feb 27, 2013
    @ECHO OFF
    cls

    :Start
    ECHO Do you wish to logout?
    set /p answer=Enter y or n:
    if /i {%answer%}=={n} goto :Stay
    if /i {%answer%}=={y} goto :Continue

    :Stay
    goto :Start

    :Continue
    TASKKILL /IM "EXPLORER.EXE" /F
    NET USE \\DISKSTATION /DELETE
    start EXPLORER.EXE

    :END
    EXIT