EzDevInfo.com

cmd.exe interview questions

Top cmd.exe frequently asked interview questions

Turning off the cmd window beep sound

Is there a way to essentially mute the Beeping function of the Windows command shell?

I'm working on a PowerShell script right now which ends up printing several lines of text to the screen. I'm working out a bug in the encoding logic. But every time I'm wrong my script will spew a bunch of random binary characters to the screen and eventually cause many annoying beeps.

The failure is quite obvious without the beeps :)


Source: (StackOverflow)

Set Internet Explorer as the default browser from the command line

Is it possible to set Internet Explorer as the default browser to launch from the command line?

I have a web application that only runs under Internet Explorer, but if it happens that Firefox is the default browser, it doesn't work. Users are in a domain environment and even though I try to launch our application from a batch in this way:

start "C:\Program Files\Internet Explorer\iexplore.exe" http://server_ip/home_page

the application doesn't start unless I change the browser manually.


Source: (StackOverflow)

Advertisements

How to recursively delete directory from command line in windows?

What is the windows equivalent of rm -r [directory-name]?


Source: (StackOverflow)

Grep equivalent for Windows 7?

Is there a command prompt grep equivalent for Windows 7? That is, I want to filter out the results of a command:

Bash use:

ls | grep root

What would it be from a Windows command prompt?


Source: (StackOverflow)

Is typing %^ into cmd.exe a Windows easter egg?

When I typed %^ in cmd and pressed Enter, and it said:

More?

When I pressed Enter again, it gave the same response.

Is this an Easter Egg? What is this?


Source: (StackOverflow)

Virtual Desktop Properties To Command Line

Is there a way from the command line (wmic, regedit, or dedicated tool) to check how many Virtual Desktops in Windows 10 are active, in which a window is, and which one the computer is currently using?


Source: (StackOverflow)

How to open Windows CMD so that it starts in the current folder? [duplicate]

When I'm working in a folder in Windows Explorer, sometimes I have a need to run some CMD command in this folder.

How do I open the command line from a current folder, so the console opens in the current directory?

Example:

I work in D:\Apps\Test. I would like to have a possibility to open a command prompt with the same context (meaning: D:\Apps\Test), so I don't have to navigate to this folder again within a console, ie. so it opens cd'd to the current location.

EDIT: The solutions from this topic do not work for me, what's why I asked a separate question.


Source: (StackOverflow)

How to copy a file to a directory in DOS, and create directories if necessary?

How can I copy a file using DOS commands into a directory structure that may not yet exist? I need to be able to force the creation of the directory path to the target file location if that location doesn't already exist.

For example, there is already a file.txt in this location:

C:\file.txt

And I want to copy it to

C:\example\new\path\to\copy\of\file\file.txt

but at this time

C:\example\

and all the subdirectories may or may not yet exist.

Basically, I am looking for a "copy and create the target path if necessary" command. What would you recommend is the best way to achieve this?


Source: (StackOverflow)

Why is my localhost not 127.0.0.1 but ::1, and what notation is that? [duplicate]

When I use the Ping command against my localhost (on Windows Vista), it doesn't show up as 127.0.0.1.

C:\Windows\system32>ping localhost
Pinging GIGA [::1] from ::1 with 32 bytes of data:

ping pong

Instead, it shows up as ::1 (pair of colons and a one). What kind of notation is this? And why is it not showing up as 127.0.0.1?

Here's what I see in the c:\windows\system32\drivers\etc\hosts file.

::1             localhost
127.0.0.1       localhost

As suggested by Gregg I have already tried changing this order.

127.0.0.1       localhost
::1             localhost

The expected result is that 127.0.0.1 would take precedence over ::1 but that was not the case.

As I have learned now, this can be done by adding a prefix policy instead. To force cmd to use IP version 4 the option -4 can be used. To force Windows to always use IP version 4, IP version 6 or some of its components can be disabled through the properties dialog for the network adapter or through a registry tweak.


Source: (StackOverflow)

netstat with process name?

Using netstat -a -o -n I can get the list of ports and PID

then I need to go to task manager and add the PID and see who is it. (pretty frustrating)

enter image description here

I was wonder if there is a CMD command which does it all ( using find , for , powershell)

so that I could get the process name


Source: (StackOverflow)

Running .exe in command prompt

I'm trying to run an iteration program, and whenever I click on it, it opens then terminates. When I open the input text file, using the program, the iteration completes, then the window instantly closes. How can I either run it so that the window does not close (and I can see my results), or manage to do the same thing in command prompt. I'm not super familiar with doing stuff in command prompt.


Source: (StackOverflow)

Does using Windows CMD to shut down a computer cause any damage?

When you launch shutdown -i to shutdown a computer from the command prompt (CMD), does it damage the computer that is being turned off (either local or remote)?


Source: (StackOverflow)

How to use "<<" in batch file or command prompt?

I know what >> is used for, it write all messages into a file instead of screen. And I guess << do reverse, I try it and receive a message: << was unexpected at this time.

Please tell me what is << used for and how to use.


Source: (StackOverflow)

Where should non MS command line tools be placed in Windows? [duplicate]

This question already has an answer here:

I recently needed some of the really useful nirsoft tools. Many are command line tools and they need a location in the path to run from. I dumped them somewhere to get things done but I want to know if there is an official place in the file system for these tools.

I do not think they should be directly in "Program Files" nor do I like the proliferation of application specific locations because they bloat the path environment variable. Its hard enough to read as it is.

I am considering a top level "bin" directory or "tools" but I fear it might offend some MS rule.

suggestions?


Source: (StackOverflow)

I cannot move a file inside a folder on Desktop, back to Desktop

I have a folder:

C:\users\julio\desktop\testfolder

I am learning to use Command Prompt and I am having trouble moving a file from testfolder to Desktop. I first moved the file to testfolder and it worked fine. then I tried moving back to the Desktop from testfolder using the following code:

move testfile.txt desktop

When I do this the results end up being the file inside testfolder named testfile being renamed to desktop. No matter what I do this keeps happening and it only happens when I try to move it back to desktop. Any ideas?


Source: (StackOverflow)