Continue With CMD Commands After Batch Script - windows

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.

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.

Related

Batch file of powershell commands runs in cmd not in powershell terminal

I made a batch file to run with admin right in windows powershell, it opens a powershell but runs in another cmd windows. I saved the batch file with *.ps1 but it did not work.

Open another shell from cmd and execute commands from batch file

I'm creating a batch file which will open windows command prompt and from there it will open another shell(windchill shell). There I have to execute a command which will do some operations.
#echo off
start cmd.exe /k "cd D:\PTC\Windchill\bin & windchill shell"
Above script is opening windchill shell but I couldn't find a way to execute commands on it. I do not have much experience in this. Looking for some help.
Thanks in advance

How do I make a cmd script that once it is run, remains open and accepts new commands?

I want to make a cmd script that performs an action but then remains open and I can type new commands.
I have failed to find the proper terms to google as my knowledge of shell is almost zero.
thank you!
You can specify a command shell to run a specific command during start-up using the /k switch. E.g.
cmd /k C:\InitialScript.bat
The command shell would execute the C:\InitialScript.bat batch file and remain open for the user to type further commands.
If you want to create an icon for users to use then create a shortcut and use the following as the target:
%WINDIR%\System32\cmd.exe /K C:\InitialScript.bat
If you already have a command shell window open, then just use the following which will run the batch file in the context of the existing shell:
C:\InitialScript.bat

What is a batch file command to open a cmd window?

Yes, I tried googling this, by the way.
Basically, what is the dos command that will open a dos command window?
In other words, if you have a .bat file full of script commands, what command can you do that will open a command window?
You can try this maybe. In the command line it starts it so I assume in a bat file it'll do the same.
start cmd
If you want it to run another bat or something you can do:
start script.bat
If you want it to close then:
start cmd /c script.bat

How to close the command prompt when running a batch file in ruby in windows

am opening command prompt using system command like system("start cmd.exe") and then running some batch file. I want to stop the batch file running in command prompt or close the command prompt window. Could you please help me with this.
If you want the command prompt to terminate you just write the following in your script..:
system("exit")
To stop the batch file I will use win32ole lib and send a CTRL+C combo like this..:
require "win32ole"
key = WIN32OLE.new('Wscript.Shell')
key.SendKeys('{^}C{ENTER}')

Resources