Start cmd with pre-loaded string - batch-file

I would like to know if it is possible to start cmd.exe from a .bat file, having a string pre-loaded but witout executing it immediately.
So effectively what i want to do is to have a bat like the below:
cmd /K time
but when the user double-clicks on it to just show the:
C:\Windows\time
but without executing it. I would like the user to press "Enter" to run it.
Is there an option in cmd.exe that allows that?
Thanks.

cmd /k "set /p cmd=C:\Windows\time&time"
if this isn't what you were looking for could you please describe what you are trying to accomplish?

Related

Trying to open a new cmd window then run multiple commands in it

I am facing a rather annoying issue when trying to write a batchscript file for my assignment, the assignment asks me to open a new command prompt window, change its color and make it print the current windows version. I can make it open the new window and change the color but no matter what I do it will always execute any new commands including the ver command on the old command prompt window, I have tried using & to run multiple commands but it just does nothing.
start cmd /k color F1 & ver
pause
This is the code I have now, any help would be appreciated
To undertake the task you've specifically shown us, there is no need whatsoever to use the color command, and as a result, include an ampersand to join two commands.
If you open a Command Prompt window, type cmd.exe /? and press the ENTER key, you should see that there is a /T option you can use.
Start %SystemRoot%\System32\cmd.exe /T:F1 /D /K Ver
Have you tried
start "My assignment" cmd /k "color F1 & ver"
Note that the window title is the first quoted string in the start command.
Without double quotes only the "color f1" command is being passed to your new cmd window.
start cmd /k "color F1 & ver"
pause
I think will give you the results you want.

Get all info through one command prompt

I know when I start a bat file and have pause at the end it will stay open.
Then when pressing the spacebar the bat file ends, and the command prompt will be closed.
Also I know when we use cmd /k it will stay opened, and there is even a command prompt left to enter some bat file code.
Without pause or cmd /k there will be a new window opened and it closes itself.
What I really want to is to have a console window opened, and every time I run a bat file I want the output to be seen on the cmd that is already opened.
I like the way that I can see all the code that was running, without to having close the windows every time, and like it as if all the code will be seen in one opened cmd prompt.
edit: 2
first_file.bat
#echo first
call "C:\ProgramData\Cool\second_file.bat"
#echo thirth
second_file.bat
#echo second

What is the batch script to open another cmd window to run another line of script

I know that the question was not very clear, so I will try to make it clearer.
I am looking for the batch script command to open a cmd window that runs like a batch program.
I know the command exists as I have seen it used before and have used it before, however, as of late I have not been
able to find it or remember it. The command looks something like this
#echo off
start cmd.exe ("#echo off && echo second window opened && pause")
pause
It would open a second cmd window that read.
second window opened
press any key to continue...
And when you pressed a key the second window would close, just like a batch file cmd window would. As you probably can tell I am relatively new to batch scripts and am still a little iffy on how it works.
Not bad memory. Almost done
start "title" cmd /c "echo in other window & echo. & pause"
Type cmd /? and start /? to get all the needed information for this commands usage

how to set anothe path - cmd

I would like to start cmd.exe from batch file and execute command, but:
If I use start cmd.exe /k e.g. „net use“ – it executes command behind /k. - and it gives me default path - i would like to change it.
But how to run cmd.exe with another path as it is set and execute command behind /k?
I start cmd.exe - i have - c:\users\xxxx
What do i have to if i would like to chande it? E.g. c:\tools\Script\...
How to write batch like this?
Use the start /d parameter, e.g.
start "" /d"c:\documents and settings" cmd /k
see start /? for more help.
Try using
cd "pathname"
to get to the correct Path.
For Example:
cd c:\tools\Script
you can also show all folders by using the command
dir
Furthermore the cmd.exe is automatically used if you try to execute a .bat file I believe.
But for changing the normal path used you can edit the settings as shown in this picture:
For more funcitons you could look here: http://www.computerhope.com/overview.htm

Run a batch file in a new window from batch?

I know it seems this has been asked before, but I need a batch to open another batch in a new window. I've tried:
start abc.bat
cmd abc.bat
run abc.bat
and others. They've all opened in the same window or just opened Command Prompt in new window, ignoring my batch. Is there a batch command to open a batch file in a new window?
Is this what your after?
start "New Window" cmd /c test.cmd
It's a little bit strange that start abc.bat doesn't work but I assume this is because you are running this in the middle of another batch. You probably need call:
22:22:38.85 c:\help call
Calls one batch program from another.
CALL [drive:][path]filename [batch-parameters]
Giving you start call abc.bat or call start abc.bat depending on what the exact problem is.
To simply do it is just
start cmd /c "exampleexample.bat"
This could also work with spaces;
start cmd /c "example example.bat"
And directories.
start cmd /c "C:\NAME\Example\Hi there\example example.bat"
I created my universal batch with this and this works flawlessly.
start abc.bat works for me. What is the problem in your case? You could also try start cmd /c abc.bat.
I found something that works:
call "C:\FILEPATH HERE\abc"
Demo:
#echo off
call "C:\Users\USERNAME HERE\Desktop\abc"
This should work <3
Unfortunatly, I know of no such method (I encounter the same thing). However, try killing the old window when you start the batch
abc.bat:
abd.bat
stop
abd.bat:
#echo off
#echo It works!
If you are going to run it in a different command prompt, type start C:\abc.bat or whatever the directory of abc.bat is, or if you want to open it in the same command prompt, type call "C:\abc.bat" again, wherever the directory is. It should work
Either:
call "C:\abc.bat"
or
start C:\abc.bat

Resources