Here are the steps I need, I am using a batch script
Open a cmd with path set to the desktop
Then set it's echo off
Then clear the screen
Then wait for me to type commands
So I can enter the commands directly without a long line blocking the view
Code I tried so far
#echo off
cd "C:\Documents and Settings\Administrator\Desktop"
cls
cmd
#echo off
cls
But when I run this I get a typical CMD window, where I have to type "echo off" & "cls" again to get a clean window.
The output I get is
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Administrator\Desktop>
The output I want is simple
Imagine a blinking underscore
_
Thank you.
Try this line:
start /D "C:\Documents and Settings\Administrator\Desktop" cmd /k "prompt $"
/D <path> will set your working directory
Prompt $ will set your prompt to "nothing", only the blinking cursor will display
The output I want is simple
_
You can achive this with the prompt command, e.g. prompt $S or prompt $g
Here's an example batch file that would open up a new cmd window with an empty prompt:
#echo Off
start cmd /k "prompt $g"
create a VBS file using notepad
add this lines
Set cmd = CreateObject("WScript.Shell")
cmd.run"cmd"
WScript.Sleep 200
cmd.Sendkeys"echo off{Enter}"
WScript.Sleep 200
cmd.Sendkeys"cls{Enter}"
WScript.Sleep 200
This command can be very problematic (cmd /c "echo off | clip")
USE WITHOUT QUOTES:
cmd /c echo off | clip
goto off
(Save as .bat)
No more problems !!!
I just used
cls
echo off
cls
cmd|echo off
cls
in a batch file. Works for me
Related
what I'm essentially trying to do is make a batch file (or shortcut if possible) to change to a directory, echo a message, and then let you use the cmd window as if you had opened it up normally after.
Example:
The batch file/shortcut opens a cmd prompt in C:\test-folder\
Echos "This is your message"
Awaits user input for commands
I've tried the following command:
start cmd /k cd /d C:\test-folder\
echo test
The folder change will work without the echo line, but if I include the echo line, it will not work at all.
Is there any way to do what I'm trying to accomplish here?
the order of the switches matters. See start /? and cmd /? for details.
start "My window" /d "d:\" cmd /k "echo Hello&echo use me"
"My window" belongs to start and gives the new window a title.
/d "c:\test-Folder\" also belongs to start and gives the startdirectory
cmd is the command to start
/k belongs to cmd and has to be cmd's (only or) last Switch
"echo Hello&echo use me" is the commandline to execute.
Your problem is the echo test is run in the parent window that issues the START command. You want the ECHO to occur in the window that START launches.
One option is to append the ECHO command to the end of the START command, remembering to escape the & so that it is included as part of the CMD /K option.
start cmd /k cd /d C:\test-folder\ ^& echo test
Or you could put quotes around the entire /K option (CMD will remove the quotes before executing the string):
start cmd /k "cd /d C:\test-folder\ & echo test"
Or you could use Stephan's suggestion to let START set your active directory, so that your CMD /K option only needs to ECHO the message.
start /d "C:\test-folder" cmd /k echo test
Or you can create a shortcut and edit the properties such that
"Target" = C:\Windows\System32\cmd.exe /k echo test
and
"Start in" = c:\test-folder
If you create a batch file that ends with cmd /k, it will run the commands before cmd /k and then leave you in a command prompt. This is useful if you're performing enough work that makes a one-liner shortcut hard to write.
To get the behaviour you described, you can create a file called "open_test_folder.cmd" with the following:
#echo off
cd C:\test-folder
echo This is your message
cmd /k
[How can i prevent it from showing C:/Users/[Username]/Desktop/ ? Link
My code:
#Echo off
title Menu
color A
echo You can do anything,but please don't delete system32!
echo color (1-11) title (name)
echo If you type CLS you can hide the hints!
echo For Game and Program codes type in: Codes!
cmd /k
Use prompt, for example:
cmd /k prompt $$ changes the prompt to $
cmd /k prompt $T$G$S changes the prompt to 17:29:12,44> (with space at the end)
See more formatting codes by running prompt /? in the Command Prompt console.
cmd.exe is blocked at school. However batch files runs normally and sometimes it's very annoying to type the command in the batch file, write pause>nul and run the batch file to execute a command. Is there anyway to input commands from the user and execute them as cmd.exe does?
#echo off
:Loop
echo %cd%^>
set /p cmd=SkYWAGz Enter Command to Run (Press Ctrl + C to exit)
%cmd%
Goto Loop
Your very own command processor
I found the solution, the code in the batch file would be start
This works for me:
#echo off
break off
title Command Prompt
cls
:cmd
set /p cmd="%cd%>"
%cmd%
echo.
goto cmd
So I want to open a new cmd prompt from my batch script and set that as the "active window" to run the following cmds in my script.
I know how to open the new cmd promt:
start cmd \k "cd c:/users"
Now whenever I enter in cmds to perform under that line it executes in the prompt that I used to call my batch script. How can I set it so they all execute in the new window, there will be a lot of cmds executed and i have tried the && and & but it doesn't work.
Any help on this would be appreciated!
Thanks in advance!
This works:
#echo off
start cmd /k "cd c:\users" ^&set/p check=Did it work? ^& call echo %%check%%
note: c:\ not c:/
Or:
#echo off
start cmd /k "cd /d c:\users" ^&^
set/p check=Did it work? ^&^
call echo %%check%%
Any idea on, how to insert text into a new cmd prompt window to continue the script?
e.g.
runas /user:adminuser cmd
opens up new cmd window. I want to insert the below using the batch file
c:
cd\temp\file\executefile.exe
del c:\temp
Create a batch file "C:\batch.bat" and insert these commands in each line
c:
c:\temp\file\executefile.exe
del c:\temp
and start this batch file using following command
C:\> runas /user:adminuser C:\batch.bat
also you probably want to use following command to delete temp folder along with subfolder and files in temp. For that instead of del c:\temp use echo y | rmdir /s c:\temp in batch file
To print this on new windows cmd use this:
text.cmd:
#echo off
echo c:
echo.
echo cd\temp\fichier\executefile.exe
echo.
echo del c:\temp
pause
and use the command:
start text.cmd
You can use a file.cmd or file.bat it is the same.
runas /user:adminuser "cmd /C c: & cd\temp\file\executefile.exe & del c:\temp"
Previous line execute the commands and terminate the new cmd prompt window. If you want that the window remain after execute the commands, change /C by /K.
To insert manually values into your command prompt when executing a batch script, use the following:
set /p var=
echo %var%
This will gather what you entered, then display it (or wathever you need).