1

I am trying to write a batch script which, once complete, would allow the user to continue using the Windows command prompt as they normally would had no script been run. Is this possible? Thank you in advance for any help.

7
  • 2
    If you run the script from the command line instead of double-clicking it, you can already do this. Commented Sep 17, 2019 at 18:40
  • Is there anything that would allow this regardless of how the script is run? Commented Sep 17, 2019 at 18:40
  • 1
    Depends on whether you want to keep any environment variables you set during the script or not. If not, you can just stick a start "" cmd.exe at the end of your script to open a new CMD window. Commented Sep 17, 2019 at 18:46
  • 1
    I swear every time I see an ADB question on here, it just deepens my belief that ADB isn't meant to be scripted. Commented Sep 17, 2019 at 19:11
  • 1
    What about just appending cmd as the last command to the batch file? this opens a new cmd instance but it inherits the environment of the parent instance that ran the batch file... Commented Sep 17, 2019 at 21:49

1 Answer 1

3

If you manually open CMD (the Command Prompt) and invoke the batch file by name, CMD will remain open for additional commands after the batch file completes. You cannot do this by double-clicking on the batch file, but if you create a shortcut to the batch file that runs CMD.EXE with the /K switch, you will run the batch file and then leave CMD running for additional commands. See CMD at SS64.

Sign up to request clarification or add additional context in comments.

1 Comment

I was about to have them create a wrapper for the first script that invokes cmd /k, but I like this solution better.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.