Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: close explorer to continue scriptt  (Read 6356 times)

0 Members and 1 Guest are viewing this topic.

hope/despair

    Topic Starter


    Rookie

    close explorer to continue scriptt
    « on: November 17, 2008, 11:06:25 PM »
    Hope this is not a repost but couldn't find anything with my search


    My script basically calls for a certain drive to be viewed in explorer (Start z:/) now i need to pause the script until the explorer is closed by the user.
    Is it possible?

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: close explorer to continue scriptt
    « Reply #1 on: November 18, 2008, 03:32:51 AM »
    This should work:

    Code: [Select]
    start /wait explorer z:\

     8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    hope/despair

      Topic Starter


      Rookie

      Re: close explorer to continue scriptt
      « Reply #2 on: November 18, 2008, 09:38:04 AM »
      I tried that but it doesn't seem to work. Do i need something for the 'wait' to work i.e another script or something?

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: close explorer to continue scriptt
      « Reply #3 on: November 18, 2008, 11:15:43 AM »
      My script basically calls for a certain drive to be viewed in explorer (Start z:/) now i need to pause the script until the explorer is closed by the user.
      Is it possible?

      Post your script so we can both see the light. Do you actually have a drive z:?

      8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      hope/despair

        Topic Starter


        Rookie

        Re: close explorer to continue scriptt
        « Reply #4 on: November 18, 2008, 11:32:02 AM »
        net use Z: \\madressahserver\test3
        Start Z:\
        pause
        net use Z: /delete
        @echo thanks
        sleep 5

        I want to substitute the pause for the wait function
        « Last Edit: November 18, 2008, 12:24:39 PM by hope/despair »

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: close explorer to continue scriptt
        « Reply #5 on: November 18, 2008, 01:07:11 PM »
        This code should map your z: drive, open explorer and wait; When explorer closes, the z: drive should be deleted from the drive pool and a thank you message displayed on the console.

        Code: [Select]
        @echo off
        net use Z: \\madressahserver\test3
        start /wait explorer z:\
        net use Z: /delete
        echo thanks
        sleep 5

        Works fine on my machine. Are you sure \\madressahserver\test3 is correct?

         8)
        The true sign of intelligence is not knowledge but imagination.

        -- Albert Einstein

        hope/despair

          Topic Starter


          Rookie

          Re: close explorer to continue scriptt
          « Reply #6 on: November 19, 2008, 05:23:33 PM »

          Quote
          Works fine on my machine. Are you sure \\madressahserver\test3 is correct?
           8)

          The path is correct

          Quote
          This code should map your z: drive, open explorer and wait; When explorer closes, the z: drive should be deleted from the drive pool

          The explorer opens up but the script continues without waiting for me to close explorer.
          I tried start /wait calc.exe and that holds the script until i close calculator... ???

          Sidewinder



            Guru

            Thanked: 139
          • Experience: Familiar
          • OS: Windows 10
          Re: close explorer to continue scriptt
          « Reply #7 on: November 20, 2008, 05:30:28 AM »
          Try running the explorer without the start /wait. I cannot reproduce your results, but when I was trying to, I noticed that this works equally well:

          Code: [Select]
          @echo off
          start /wait %comspec% /v:on /c "mode 40,10 & title Login Window & color 1e & echo. & set /p name=Enter Name: &  set /p pswd=Enter password: & cls & echo name=!name!>login.txt & echo pswd=!pswd!>>login.txt & exit"
          for /f "tokens=1* delims==" %%i in (login.txt) do (
          if %%i==name set name=%%j
          if %%i==pswd set pswd=%%j
          )
          echo Name is %name%
          echo Password is %pswd%

          net use z: \\madressahserver\test %pswd% /USER:%computername%\%name%
          explorer z:
          net use z: /delete

          I cannot explain why start /wait would work for calc but not explorer.

          If the code still fails, a workaround would be to insert a pause statement after explorer launches. This would force the user to hit any key for the batch file to continue. I didn't say it was a great workaround.  ;D

          Good luck.

          The true sign of intelligence is not knowledge but imagination.

          -- Albert Einstein

          hope/despair

            Topic Starter


            Rookie

            Re: close explorer to continue scriptt
            « Reply #8 on: November 20, 2008, 01:26:48 PM »
            get this
            start /wait z:\file.txt works and holds the script yet start /wait z:\ or start /wait explorer z:\ doesn't
             ???

            « Last Edit: November 20, 2008, 02:14:37 PM by hope/despair »

            Sidewinder



              Guru

              Thanked: 139
            • Experience: Familiar
            • OS: Windows 10
            Re: close explorer to continue scriptt
            « Reply #9 on: November 20, 2008, 02:57:20 PM »
            I can't find any documentation referring to this issue. There don't seem to be any settings in explorer that would change this behavior. Might be something deep in the registry, but if it works for you, why not go ahead and use it?

            When I try your method, if the file does not exist, explorer defaults to the c: drive and if it does exist, the file opens read-only.

            What does the user do when explorer opens? You'd be surprised how imaginative we can be when we have the whole picture.

             8)


            The true sign of intelligence is not knowledge but imagination.

            -- Albert Einstein

            johnsonbben



              Greenhorn

              Re: close explorer to continue scriptt
              « Reply #10 on: November 22, 2008, 05:38:01 PM »
              call explorer.exe Z:\

              this should work

              hope/despair

                Topic Starter


                Rookie

                Re: close explorer to continue scriptt
                « Reply #11 on: November 22, 2008, 06:35:15 PM »
                What does the user do when explorer opens? You'd be surprised how imaginative we can be when we have the whole picture.

                 8)

                the user is going to transfer files in/out or save/edit/open, Now the user's are not neccesarily going to know the file name they are going to be looking for. so i can't have the them type in the file name.

                As for the whole picture... I want my script when called upon, to map a drive on the network and open explorer with the mapped drive and when the user closes explorer the script should continue on to disconnect the drive.

                hope/despair

                  Topic Starter


                  Rookie

                  Re: close explorer to continue scriptt
                  « Reply #12 on: November 22, 2008, 06:40:30 PM »
                  I have been doing a little research and this may or may not be why it's not been working for me.
                  since explorer is always running in the background when i start explorer it just adds on to the current process (task manager) and thus the script continues. this explains why when i use calc.exe or notepad it's been starting a new process and can track when terminated.

                  I guess now i need to find out how to start explorer in a seperate process. any ideas?

                  Sidewinder



                    Guru

                    Thanked: 139
                  • Experience: Familiar
                  • OS: Windows 10
                  Re: close explorer to continue scriptt
                  « Reply #13 on: November 23, 2008, 05:33:26 AM »
                  Quote
                  I guess now i need to find out how to start explorer in a seperate process. any ideas?

                  Not a one. As the file manager application in Windows, I suspect Explorer was written not to allow multiple copies of itself and that all requests would attach to the single running instance.

                  Window tasks by definition open in their own window, so using start is probably over kill. The start command was designed to run console applications in another window. The /wait switch determines whether the batch file continues or waits.

                  In your system the batch file never waits and continues to run whether Explorer is launched with start or run inline. I still am not able to duplicate your results, on XP or Vista.

                  Perhaps someone wiser will come by with a solution. 8)

                  Note: a previous post suggested using call. Call is used to transfer control to external batch file or an internal subroutine. It also sets up a return address back to the next sequential instruction after the call. Call works internal to the current shell program context, start works external to the current shell program context.
                  « Last Edit: November 23, 2008, 08:58:39 AM by Sidewinder »
                  The true sign of intelligence is not knowledge but imagination.

                  -- Albert Einstein

                  hope/despair

                    Topic Starter


                    Rookie

                    Re: close explorer to continue scriptt
                    « Reply #14 on: November 23, 2008, 10:19:32 AM »
                    If possible, could you check if task manager shows two processes of explorer.exe when you open explorer through  command prompt?
                    Appreciate all your help