MS-DOS and Windows command line start command

I’m trying to open a new command window in a BAT file:

After it opens, I’d like to execute a BAT command in the new window:

How can I do this?

This question is related to

While it might sound complex but there are many commands which can help you. For instance, you need to find the IP address of a website you might Google how to find the IP address of a website then try websites with lots of ads. But it can be done within your terminal in few seconds without any issues by using ping or nslookup.

Do Not Mess with Command Prompt

In this article

I need to run two commands which never terminate. What I normally do is to

I then have my two processes running in parallel.

I now would like to automate this by having one “startup” file which would lauch the two terminals above. It can be cmd or PowerShell based.

Note 1: I tried to use cmd with /k or /c but this does not spawn a new terminal. Trying something like cmd /c cmd ended up with Internal Error output in the shell.

Note 2: PowerShell has Background Jobs. The problem is that I want to have two separate shells I can monitor the output on (and eventually close the running process with Ctrl-C.

Is there a way to achieve this in one file?

asked Oct 12, 2017 at 12:03

Create a batch file:

Run the batch file and it will open the two cmd windows and the batch file will exit.

answered Oct 12, 2017 at 12:27

2 gold badges24 silver badges40 bronze badges

I believe ‘start cmd /c dir’ is what you’re looking for.
edit: Well, /k for short example like dir, but ‘start’ is the magic word you need.

answered Oct 12, 2017 at 12:20

2 silver badges13 bronze badges

In my Windows command prompt, sometimes when I run a command it gets executed in a new command prompt instead of the current one. Is there a way to control this (force commands to always run in current window or always in a new prompt)?

Example: running ipython.exe opens the interpreter in a new prompt (and i’ve seen this behavior with few other commands which I can’t recall right now).

9 gold badges45 silver badges70 bronze badges

asked Feb 11, 2011 at 5:22

There are basically two types of Windows applications, console based and window based. This is set by the developer before compiling the code. CMD. EXE is console based, NOTEPAD. EXE is window based. If a console based app is launched from cmd.exe, it will always open in the same window unless you do something to change that (like use the START command). If an app opens in a new window, then it is either window based or the program itself was coded to create a new window.

answered Feb 11, 2011 at 6:43

1 bronze badge

If the program itself opens a new console window, there is nothing you can do to stop it.

answered Feb 11, 2011 at 6:08

62 gold badges891 silver badges961 bronze badges

I hate to resurrect such an old post, but I had a similar issue and came accross this thread, which didn’t solve my problem since my .exe is definitely of the console variety. So I wanted to add my update for others.

Hope that helps someone

answered Dec 16, 2022 at 4:36

Now I know we can create a keyboard shortcut for any shortcut. So in a similar way, I created a desktop shortcut for cmd, gave it the Ctrl+Alt+T shortcut. So when I press that combination, it opens a new cmd window, now when minimized, if I press the same combination, it opens the same window.

How should I modify so that this shortcut opens up a new CMD (Just like terminal in Ubuntu)?

asked Oct 29, 2017 at 10:00

From what I know, you can not open up multiple cmd prompt using this method. One alternative way would be to use AutoHotkey.
For the CTRL+Alt+T keyboard shortcut:

^!t::
Run %comspec% /k
return

comspec is resolved to cmd.exe when using AutoHotkey.

A method that requires a couple of more keystrokes, but has the advantage of not requiring any program:

A slightly shorter one:

answered Oct 29, 2017 at 11:36

1 gold badge11 silver badges16 bronze badges

Dont. Just hold shift. job done.

Holding shift opens a second-copy of the app. You can use the below on almost any Windows PC, not just your customised PC. This also works when clicking apps in the GUI.

Generic method for all Win10 apps:

Tap the corresponding keyboard shortcut for CMD / PS.

More Background info:

(but I will put a reason to leave it as PowerShell instead of CMD in comments)

answered Nov 3, 2018 at 2:06

2 silver badges16 bronze badges

Updated: by

Availability

start /NODE 1 /AFFINITY 0x3 application1.exe start /NODE 1 /AFFINITY 0xc application2.exe

non-executable files may be invoked through their file association by typing the name of the file as a command. (e.g., WORD. DOC would launch the application associated with the . DOC file extension). See the ASSOC and FTYPE commands for how to create these associations from within a command script.

When executing an application that is a 32-bit GUI application, CMD. EXE does not wait for the application to terminate before returning to the command prompt. This new behavior does NOT occur if executing in a command script.

When executing a command line whose first token is the string “CMD” without an extension or path qualifier, then “CMD” is replaced with the value of the COMSPEC variable. This change prevents picking up CMD. EXE from the current directory.

When executing a command line whose first token does NOT contain an extension, CMD. EXE uses the value of the PATHEXT environment variable to determine the extension. The default value for the PATHEXT variable is:

Notice the syntax is the same as the PATH variable, with semicolons separating the different elements.

When searching for an executable, if there is no match on any extension, then looks to see if the name matches a directory name. If it does, the START command launches the Explorer on that path. If done from the command line, it is the equivalent to doing a CD /D to that path.

Windows XP and earlier syntax

When executing a command line whose first token is the string “CMD ” without an extension or path qualifier, then “CMD” is replaced with the value of the COMSPEC variable. This change prevents picking up CMD. EXE from the current directory.

Start examples

start notepad myfile.txt

Start a new instance of Notepad with the file myfile.txt.

start /MAX notepad

Start the notepad window with the screen maximized.

start /MIN mybatch.bat

The above example would start the batch file mybatch.bat in a minimized window.

start c:music”my song.mp3″

If the file or folder has a space in it, you must surround it with quotes. In the above example, we’re starting the MP3 song file “my song.mp3.” Without the quotes surrounding the file name with a space, you would get a Windows cannot find the file error.

Open the Computer Hope web page in your default browser from the command line.

I have a Virtual Machine in Virtual PC 2007.

“c:program filesMicrosoft Virtual PCVirtual PC.exe” -pc “MY-PC” -launch

But that leaves a dos prompt on the host machine until the virtual machine shuts down, and I exit out of the Virtual PC console. That’s annoying.

So I changed my command to use the START command, instead:

start “c:program filesMicrosoft Virtual PCVirtual PC.exe” -pc MY-PC -launch

But it chokes on the parameters passed into Virtual PC.

START /? indicates that parameters do indeed go in that location. Has anyone used START to launch a program with multiple command-line arguments?

asked Sep 30, 2008 at 17:21

63 gold badges160 silver badges234 bronze badges

START has a peculiarity involving double quotes around the first parameter. If the first parameter has double quotes it uses that as the optional TITLE for the new window.

I believe what you want is:

start “” “c:program filesMicrosoft Virtual PCVirtual PC.exe” -pc MY-PC -launch

In other words, give it an empty title before the name of the program to fake it out.

answered Sep 30, 2008 at 17:25

Instead of a batch file, you can create a shortcut on the desktop.

Set the target to:

and you’re all set. Since you’re not starting up a command prompt to launch it, there will be no DOS Box.

answered Sep 30, 2008 at 17:29

38 gold badges225 silver badges299 bronze badges

start /D “C:Program FilesInternet Explorer” IEXPLORE. EXE

start /D “TITLE” “C:Program FilesInternet Explorer” IEXPLORE. EXE

will start IE with default web page.

start /D “TITLE” “C:Program FilesInternet Explorer” IEXPLORE. EXE www.bing.com

starts with Bing, but does not reset your home page.

/D stands for “directory” and using quotes is OK!

start /D “TITLE” “C:Program FilesInternet ExplorerIEXPLORE. EXE”

ERROR “The current directory is invalid.”

Tested and works under XP but windows Vista/7/8 may need some adjustments to UAC.

12 gold badges66 silver badges122 bronze badges

answered Feb 12, 2013 at 21:37

1 silver badge3 bronze badges

The spaces are DOSs/CMDs Problems so you should go to the Path via:

:/>  Как изменить каталог установки программ по умолчанию в Windows

cd “c:program filesMicrosoft Virtual PC”

and then simply start VPC via:

start Virtual~1.exe -pc MY-PC -launch

~1 means the first exe with “Virtual” at the beginning. So if there is a “Virtual PC.exe” and a “Virtual PC1.exe” the first would be the Virtual~1.exe and the second Virtual~2.exe and so on.

Or use a VNC-Client like VirtualBox.

15 gold badges126 silver badges162 bronze badges

answered Jun 30, 2012 at 14:11

None of these answers worked for me.

Instead, I had to use the Call command:

78 gold badges114 silver badges152 bronze badges

answered Jun 4, 2019 at 15:48

If you want passing parameter and your .exe file in test folder of c: drive

start “parameter” “C: est est1.exe” -pc My Name-PC -launch

If you won’t want passing parameter and your .exe file in test folder of c: drive

start “” “C: est est1.exe” -pc My Name-PC -launch

If you won’t want passing parameter and your .exe file in test folder of H: (Any Other)drive

start “” “H: est est1.exe” -pc My Name-PC -launch

answered Feb 17, 2016 at 13:45

3 silver badges11 bronze badges

The answer in “peculiarity” is correct and directly answers the question. As TimF answered, since the first parameter is in quotes, it is treated as a window title.

Also note that the Virtual PC options are being treated as options to the ‘start’ command itself, and are not valid for ‘start’. This is true for all versions of Windows that have the ‘start’ command.

This problem with ‘start’ treating the quoted parameter as a title is even more annoying that just the posted problem. If you run this:

start “some valid command with spaces”

You get a new command prompt window, with the obvious result for a window title.
Even more annoying, this new window doesn’t inherit customized font, colors or window size, it’s just the default for cmd.exe.

answered May 20, 2015 at 15:59

If you must use double quotation mark at any parameter, you can get error “‘c:somepath’ is not recognized a an internal or external command, operable program or batch file”.
I suggest below solution when using double qoutation mark:
https://stackoverflow.com/a/43467194/3835640

answered Apr 18, 2017 at 8:30

How To Change Date and Time on Windows using command prompt

time HH:MM
time 12:13 pm
time 12:13 am

If you just want to know the current time using command then pass

date dd-mm-yy
date 04-07-2019

To get current date use

If you are using automatic time and date sync feature in windows 10 then time and date set by you using command going to be overridden by windows 10 on next time and date sync.


MS-DOS and Windows command line start command

Know Your IP

As the command is itself explaining it will give you all the IP configuration of your computer,
Details like your local ipv6 and ipv4 addresses, Subnet Mask, Default Gateway, Ethernet Adapter info.

But if you add some extra options with the command it can do a lot of things

For example, if you are hosting a website and you change the DNS server of your website you need to flush your local DNS cache so you can get the new DNS server details

What you need to do is run

It will purge all DNS resolver cache from your system

If you only want to know your mac address you can use the command: getmac

Active connection

Quickly view all your current TCP/IP active connection to find out which service is using what port.

By passing some additional flag you can customize the information. If you want to know which executable file is making that connection you can use -b and for interval just pass the value in numeric digits at the end of the command.

To view all the options in your terminal use netstat /? which will display the below options.

PING

Ping command is often used to check if your network printer is connected or not, so you know where to look for troubleshooting. Or use it to check if your computer can connect to another computer on a local area network or not.

By default ping command sends 4 requests you can increase the number of request by passing count with -n flag or you can use -t to run it until stopped.

Send ping request 10 times

ping -n 10 www.google.com

Send ping request until stopped

ping -t www.google.com

Send ping request with packet size of 1000 bytes instead of default 32 bytes

ping -l 1000 www.google.com

ping /? – Check all available options

Pathping is a related command that gives more information you can use pathping if ping command does not satisfy your need

pathping /? – Check all available options

Quick Tip:
Some commands after running keep running and if you want to stop it use keyboard shortcut Ctrl+C
It will break the running process and you can run any command afterwards or Just open up new command prompt if you don’t want to break the process.

SHUTDOWN

There are some examples of the shutdown command

shutdown /s – Shutdown without prompt
shutdown /i – prompts
shutdown /r – Full shutdown and restart the computer
shutdown /l – Log off
shutdown /h – Hibernate computer
shutdown /t – Set timeout period after which system should shutdown or restart,
you need to define time in seconds,
max time you can set is 315360000 (10 years)
shutdown /? – Check all available options

To shut down after 15 minutes

shutdown -s -t 900

To restart after 15 minutes

shutdown -r -t 900

SYSTEMINFO

A must know to command everyone should know. The kind of useful information you get is exactly what you need in multiple scenarios detailed info of all the parts of your computer.

If some software doesn’t work or you are getting help from someone else or you are searching for help online people will usually ask the most basic system-level info of your computer which can be seen here easily.

Here is my system info I got to know in one command and is quite helpful for various problems :

Windows version with build number
Microsoft Windows 10 Home Single Language
10.0.18362 Build 18362

Processor Info
Intel 64 Family 6 Model 42 Stepping 7 Genuine Intel ~3300 MHz

BIOS Version
Intel Corp. B EH6110H.86A.0020.2011.0218.1538, 18-Feb-11

Hyper-V Requirements :
VM Monitor Mode Extensions: Yes
Virtualization Enabled In Firmware: Yes

It’s super handy when you want to know the info of any computer instantly.

System File Checker

sfc /scannow – Scans
sfc /verifyonly- Check the integrity only
sfc /scanfile=c:windowssystem32kernel32.dll – Scan file and repair if required
sfc /verifyfile=c:windowssystem32kernel32.dll – Only scan file, no repair performed
sfc /? – Check all available options

Schedule Tasks

This command can do wonders combined with some useful batch files or tasks.
It provides you ability to run certain programs, files on a specified date, time or interval.

It’s upto you what that task does, for example, you can take our batch file which we gave an example on our how to make your Windows boot time faster and schedule it to run on windows start what will happen is your boot time will be super fast and all your favourite programs will still be running without slowing down your boot up.

Using this command can look a little complex as it requires multiple options for creating scheduled tasks.

To know various parts in detail use /? after any parameter to get more help. Try running any of these commands they will get you more information (always remember reading more is good)

SCHTASKS
SCHTASKS /?
SCHTASKS /Run /?
SCHTASKS /End /?
SCHTASKS /Create /?
SCHTASKS /Delete /?
SCHTASKS /Query /?
SCHTASKS /Change /?
SCHTASKS /ShowSid /?

An example of running a batch file hourly that is located in C drives temp folder with name File1.bat :

SCHTASKS /Create /SC HOURLY /MO 12 /TR Example /TN c: empFile1.bat

DRIVERQUERY

Often times you come across a situation where the software needs some specific drivers to work. In that case, you need to find is the driver installed and if it is then where it’s installed?

Simply Run driverquery it will list all the currently installed drivers of your local computer. To know the path where each driver is installed

If you want to store that information into CSV file use driverquery -v /fo csv it will output data with comma-delimited.

To know all the possible combination use driverquery /?

TASKLIST

You can get the list of running processes of your computer. You can even check running process of a remote computer too.

This command is useful because you can use this command to get the specific information you want like process using memory greater than or less than your specified memory. You can list the apps running on a remote computer, tasklist command offers various filters you can use with parameters some example here

List processes using memory greater than 100 MB. /fi is used to pass filter with command

tasklist /fi “memusage gt 100000”
you can use /fo to foramt your out like table, csv ot list
tasklist /fi “memusage gt 100000” /fo csv

:/>  Что можно сделать с компьютером друга и списком команд Windows (Windows CMD) с описанием и примерами

TASKKILL

Now you have a list of all the running process, you can use taskkill command to kill the process, the reason to kill the process using command are many like the programme is not responding or programme has a background service that is not stopped you want to kill all the services.

To kill any programme you can pass process id (PID) or image name with wildcard(*). You can kill task forcefully by passing /f with the command, also you have the option to use filters with /fi to make this command more powerfull like kill all apps using memory over 100 MB.

taskkill /FI “memusage gt 100000”
Kill Chrome
Taskkill /F /IM Chrome.exe
Kill process with pid 3125
taskkill -pid 3125

NSLOOKUP

You can get any websites Domain Name System (DNS) infrastructure records with nslookup, even you can get specific record from DNS records like MX record or text record.

Find MX record of a website

Server: dns.google
Address: 8.8.8.8

Non-authoritative answer:
google.com MX preference = 10, mail exchanger = aspmx.l.google.com
google.com MX preference = 20, mail exchanger = alt1.aspmx.l.google.com
google.com MX preference = 50, mail exchanger = alt4.aspmx.l.google.com
google.com MX preference = 40, mail exchanger = alt3.aspmx.l.google.com
google.com MX preference = 30, mail exchanger = alt2.aspmx.l.google.com

Find txt records of the website

More about nslookup on Microsoft’s website.

It will compare a set of files and displays the difference between them.
Comparing works differently depending on what extra parameter you use along with FC.

Fc /a File1.txt File2.txt will compare two ascii files.
Fc /b Picture1.jpg Picture2.jpg will do a binary compare on two images.

All the available options are:

ASSOC

Find out all the current file association for each file extension. File Association means when a type of file is associated with a program to open by default when double-clicked. For example all the .mp3 files open through windows media player then .mp3 file extension is associated with windows media player.

A lot of time you might select the wrong program when you open new files for the first time but later on find it’s not the right program, well there is a GUI mode too but it can be done through command as well.

Running assoc will list all the association of your computer

To remove any specific extensions file association from a program just write

By not providing any program name after equal to sign it will remove the current association. After if you click on any mp3 file it will ask to select which program.

TRACERT

This command helps in finding all the hops a request needs to go through until reaching destination specified by you either IP address or hostname of a website.

If we run tracert www.google.com we will get the output as

What it means is until reaching www.google.com network request goes through 7 hops in which 192.168.1.1 is our router then broadband service and 216.58.196.68 is Google’s one of many IP addresses.

You can find all the available options through tracert /?


MS-DOS and Windows command line start command

ROBOCOPY

Robocopy stands for Robust File Copy for Windows and robocopy is actually robust command it has a long list of parameters you can use with it, some examples

Robocopy D:sourcedata E:destinationdata

copy all directories excluding empty directories

Robocopy /S D:sourcedata E:destinationdata

copy directories with empty directories

Robocopy /E D:sourcedata E:destinationdata

for a complete list of options check

Copy command is useful command is used to copy files from one location to another location in the same drive or different directories. Copy command can be used to copy multiple files using a wildcard.

Copy all .pdf from current folder

copy *.pdf E:destination

copy all files from the current folder

copy * E:destination

Copy important.doc files to a different folder

copy D:sourceimportant.doc D:destination

XCOPY

xcopy is an advanced version of copy that has some advanced options besides basic features copy command has like copy directories, exclude files of a director or all files with a specific extension, copy subdirectories with a tree structure.

copy for file
copy all files & directories excluding empty directories if destination folder don’t have directories then create them

xcopy /S /E /I D:sourcedata E:destinationdata

if want to copy hidden files too then pass /H too. xcopy command gives you the option to copy files based on files modified date by using /D that helps in taking an incremental backup

Xcopy /D:01-06-19 /I E:source E:destination

Copies files that are newer in the source folder than destination folder

Xcopy /D /I E:source E:destination

Start a new command window, this can be useful if you want to execute something in a separate window or want to show something in a separate window. It can be used to execute a batch script and .exe too.
/k makes new window to stay after execution

/wait waits for new command window close before continuing

It’s up to you, you can pass /MIN so new command window open starts minimised and with /MAX new command window will open maximised

Start command can be used to open file explorer with a specific path, like start will open file explorer with current direcotry path of command prompt, you can pass path with to open that path like

TIMEOUT

timeout /t -1 /nobreak
timeout /t 5 /nobreak
timeout /t -1
timeout /t 5

MKDIR or MD / RMDIR or rd

Create New Folder with name newfolder in the current drive or path

Remove the folder named newfolder from the root of S Drive

Use /s if the folder is not empty and contains files or folders. You can also use /q if you don’t need confirmation of Yes or No to remove folder.

TREE

Lists all files and directory of current location if no specified path and drive is passed. This is very helpful when you want to know what files are in what folder without hopping around folder to folder, don’t try this on path where thousands of files and folder are available because then output of this command won’t be much useful for you.

list all directories of the given path,

list all directories with file name also

tree /F S:oldername
use tree /? for to know more

DISKPART

You can use it to get basic information about your drive

DISKPART
list disk
select disk 0
list partition
list volume


MS-DOS and Windows command line start command

This command can be dangerous if not properly used so if you want to know more about DISKPART command you can go to Docs Microsoft.

CHKDSK

Try chkdsk command if your hard drive is giving you a hard time to know if its time to replace it. chkdsk checks logical and physical errors, chkdsk gives many optional switches you can use with chkdsk command but usually you only going to need /r and /r most of the time.

This command is timesaver because sometimes we think some of our apps are crashing because the app had some error but it can be due to bad sectors on the hard drive.

If you run chkdsk without any options it will run in a read-only mode where command does not attempt to correct any errors, you can pass /f with it to instruct fix the errors found on the disk, additionally, you can pass /r to check for bad sectors on hard disk and try to recover data.

Always make sure to run these commands after having a proper backup of your drives because in some cases if may act differently.

chkdsk – Check for errors but don’t fix errors
chkdsk /f – Scan disk and fix errors
chkdsk /r – Locate bad sectors on hard disk (implies /f)
chkdsk /? – Check all available options

DEL

Delete files using DEL command make sure to use it with caution in right directory otherwise you will end up losing your data, DEL command gives you many options like use /P so before deleting every file it will prompt for permission, use /A: with correct attribute to delete files based on their attribute like delete hidden files.

Delete all files that have .jpg extension

Delete all files that have word test in starting

RENAME

Easily rename file or folder name

You can’t specify a path or drive name in the destination file.

If your terminal is in the path where the file or folder is which you need to rename you don’t need to pass the path you can simply write

/b parameter

start /b “” “c:program filesMicrosoft Virtual PCVirtual PC.exe” -pc “MY-PC” -launch

14 gold badges154 silver badges472 bronze badges

answered May 14, 2016 at 17:46

19 gold badges235 silver badges236 bronze badges

have you tried:

start “c:program filesMicrosoft Virtual PCVirtual PC.exe” “-pc MY-PC -launch”

answered Sep 30, 2008 at 17:23

5 gold badges54 silver badges57 bronze badges

Put the command inside a batch file, and call that with the parameters.

Also, did you try this yet? (Move end quote to encapsulate parameters)

start “c:program filesMicrosoft Virtual PCVirtual PC.exe -pc MY-PC -launch”

answered Sep 30, 2008 at 17:24

:/>  Route add постоянный маршрут windows 10

1 gold badge15 silver badges17 bronze badges

Change The “Virtual PC.exe” to a name without space like “VirtualPC.exe” in the folder.
When you write start “path” with “” the CMD starts a new cmd window with the path as the title.
Change the name to a name without space,write this on Notepad and after this save like Name.cmd or Name.bat:

CDCD Program Files
CD Microsoft Virtual PC
start VirtualPC.exe
timeout 2
exit

This command will redirect the CMD to the folder,start the VirualPC.exe,wait 2 seconds and exit.

answered Jun 17, 2013 at 5:33

How to Customize Your Command Prompt

By using this command you can change the title of your current command prompt window.

You must be thinking what’s the need for this?
Well, while working there are the situation when you run a command it will start something for which you need to keep it running.

For running additional commands you need to open a new command prompt window.
So you might end up with 4-5 windows.
If you set the title of the window in the starting you can easily identify which window is doing exactly what.

TITLE My new Title
title /? – Check all available options

COLOR

By default when you open any command prompt window the colour will be a black background with white text.


MS-DOS and Windows command line start command

Try running color 07

You will notice nothing changes because this is the default one.
In the command, the first digit is for background, second for text colour
Type ‘color help’ to all the possible colours and combinations available.


MS-DOS and Windows command line start command

Quick Tip: Opacity Control
If you are in a situation where you need to write commands from a webpage, keep an eye on another terminal what happening you can reduce the opacity of your current terminal by using the shortcut key
To Decrease the opacity: Ctrl + Shift + –
To Increase the opacity: Ctrl + Shift + +

Most Essential Commands

After lots of command testing or work command prompt gets messy with too many commands, to get the clean window you don’t need to close and start a new window just use the command cls to clear the screen.

ECHO

Print variable value

Add text to file

A new file will be created if the file does not exist and also file content will be replaced with new content

Play a sound

to type ^G press Ctrl+G on the keyboard don’t write or copy-paste it. This command will play BELL sound on windows can be useful in your batch file to play a sound when something important happens.

DIR is a great command to list all files and folders of any given location, you can list and sort output with various parameters to display exactly what you are looking for like display files and folder based on attributes with /A (hidden files, read-only files, archive files, folders or just files).

DIR/A:H (display hidden files)
DIR /A:A (display archive files)
DIR /A:HA (display hidden and archive files)
DIR /A (display all files)

You can sort the out of the DIR command with /O

DIR /A /O:N (sort by name)
DIR /A /O:S (sort by size)
DIR /A /O:GEN (sort by group folders, file extension and Name)

There are multiple more options that can be used to make output helpful like use /T to change display time from Last Written(default) to File creation or Last Access Time on output.

Hide Files and Folder using Command

Hiding files and folders is easy on windows you can use GUI version, right-click file or folder you want to hide go to properties and check hidden in general tab, If you want to use this that’s ok but if you want to hide files and folder selectively like hide all .mp4 in folder but not .mp3 or hide all folders that start with word new

Hide All Files with .mp4 extension

attrib +s +h *.mp4 (Hide)
attrib -s -h *.mp4 (Unhide)

Hide Folders and Files that start with word new

attrib +s +h new* /D (Hide)
attrib -s -h new* /D (Unhide)

attrib +s +h file_name (Hide)
attrib -s -h file_name (Unhide)

Hide Folders also with Files

attrib +s +h file_name /D (Hide)
attrib -s -h file_name /D (Unhide)

The answer is

You may already find your answer because it was some time ago you asked. But I tried to do something similar when coding ror. I wanted to run “rails server” in a new cmd window so I don’t have to open a new cmd and then find my path again.

What I found out was to use the K switch like this:

You can also use the /C switch for something similar.

start cmd /C pause

This will then execute “pause” but close the window when the command is done. In this case after you pressed a button. I found this useful for “rails server”, then when I shutdown my dev server I don’t have to close the window after.

start cmd.exe /k “more-batch-commands-here”

start cmd.exe /c “more-batch-commands-here”

/c Carries out the command
specified by string and then
terminates
/k Carries out the
command specified by string but
remains

The proper formating of the command string gets a little more complicated with spaces in the arguments. See the examples below. Note the use of nested double quotes in some examples.

Run a program and pass a filename parameter:
CMD /c write.exe c:docssample.txt

Run a program and pass a long filename:
CMD /c write.exe “c:sample documentssample.txt”

Spaces in program path:
CMD /c “”c:Program FilesMicrosoft OfficeOfficeWinword.exe””

Spaces in program path + parameters:
CMD /c “”c:Program Filesdemo.cmd”” Parameter1 Param2
CMD /k “”c:atch filesdemo.cmd” “Parameter 1 with space” “Parameter2 with space””

Launch demo1 and demo2:
CMD /c “”c:Program Filesdemo1.cmd” & “c:Program Filesdemo2.cmd””

This is not very easy.

The best approach is to have the part of your script that you want to be executed in a “new window” to be in a separate .bat file. This might be impractical if e.g. you need a lot of state from the rest of your script (variables, etc). One option is to pass any values you need (e.g. dir to operate in) to the batch file:

start cmd.exe stuff.bat %this_dir%

If you have a large amount of state to transmit you might consider generating a batch file at runtime:

Obviously this is a trivial example.

The above answers helped me. But still required some figuring out. Here is an example script I use to start 3 processes for web development. It results in 3 windows staying open, as they need to run continously.

Mongo is globally added to my path, so I don’t need to cd like I do for the other two programs. Of course the path to your files will vary, but hopefully this will help.

:: Start MongoDB
start cmd.exe /k “mongod”

:: cd app directory, and start it
cd my-app
start cmd.exe /k “npm run dev”

:: cd to api server, and start that
cd ./my-app-api
start cmd.exe /k “npm run dev”

Thanks to all here in Stack Overflow; this solution solves the above question but is extended to automatically run these tasks:

I guess my project is called “antiquorum.”

The code opens two more cmd windows and a browser. T IMEOUT avoids errors in the browser.

The :start section does the work.
You can run tasks 1,2 or 4 separately by typing params as: server, worker, or none to leave a cmd opened in root of “antiquorum” project.

to run a python file in a new cmd window with spaces in the file name:

start cmd.exe /k python “C:Program FilesHelloWorld.py”

If I understand you correctly doing this in side your bat file will open Command prompt and print your message to screen.

cmd.exe hello world

hope this helps.

Adding /k between two commands executes both command in order.

How to Open Command Prompt [Multiple Ways]

If you are reading this post that means you already know how to open command prompt but still, there are multiple ways to do that maybe you can try a new way.

How to Navigate in Command Prompt

How to change directory

Go to root of your current drive with cd

How to Switch to another drive

Go back one folder from the current location using cd.

Go inside one folder or multiple folders using cd

Pass the path name with from current location

Change Drive and go to a specific folder while switching drive otherwise, windows will take you to last visited location

cd /d S:/Your/pathName

Conclusion

We hope you have to find at least something new to try out and become more efficient if you are just starting out to learn commands. Now you know some of the best and useful cmd commands for windows you should read our post on best windows utilities.

The best part of using terminal or command prompt is you can do things little faster with just your keyboard.