Hardware and software setup

Cmd hide the console window. How to hide bat window if cmd file is executing

Sometimes there is a need to run bat file in stealth mode, hide, hide bat window. For example, if the file is executed through the scheduler. Or maybe a lot of commands are written there and are executed for a long time, while flashing before your eyes. Examples of what you need hide bat window many files can be given. So if you're wondering how hide cmd window or how to run a program in secret, read carefully.

I invite you to familiarize yourself with the offers of my partners

1. Using the vbs script. Here is a script that can secretly run programs, bat files, other files.

Dim oShell Set oShell = WScript.CreateObject("WSCript.shell") oShell.run "application path\application name", 0 Set oShell = Nothing

For those who are not in the know, just copy the text into a notepad, put your paths to the application and the name of the application, save it under any name - but with the vbs extension, (for example - hide the start.vbs window)

Example: secretly run the batch file qwerty.bat from drive C

Dim oShell Set oShell = WScript.CreateObject("WSCript.shell") oShell.run "C:\qwerty.bat", 0 Set oShell = Nothing

Similar code

Set WshShell = CreateObject("WScript.Shell") RetCode = WshShell.Run("C:\qwerty.bat", 0, False)

You can run in hidden mode not only *.bat but also other files. For example, you want to launch an mp3 without a player window, provided Windows usage media player

Set WshShell = CreateObject("WScript.Shell") RetCode = WshShell.Run("C:\qwerty.mp3", 0, False)

If your mp3 is linked to another player, then add wmplayer.exe to the code

Set WshShell = CreateObject("WScript.Shell") RetCode = WshShell.Run("wmplayer.exe C:\qwerty.mp3", 0, False)

2. cmdow utility (place the utility itself in C:\windows\system32)

So the console command line present in all versions of Windows operating systems. Early versions The OS supported MS-DOS mode directly, which allowed simple commands to be executed directly from the console. Representatives of the NT family, such as Windows 2000 or Windows Server 2003, they already work according to completely different principles, however, MS-DOS is also supported in them, but through virtual machine(NT Virtual DOS Machine, NTVDM), which allows you to control and administer system resources straight from the console command mode. The command mode interpreter is the cmd.exe program, which is launched through the Start -> Run menu. In addition, to launch the console, you can use the menu item "Start -> All Programs -> Accessories -> Command Prompt".

By launching the command mode console, the user can manage resources as local system, and the resources of the remote machine. There are commands that monitor the system and identify critical places in the server settings. The difference between working from the command line is complete absence large and unwieldy graphics utilities. Command line programs allow more fine tuning in the form of key parameters specified to the right of the command itself.

With the help of special script files (sets of commands that are executed sequentially or in a programmed order), the administrator can minimize the execution of routine daily operations. Existing modern utilities can run such scripts at specified intervals without the presence of a system administrator.

The administrator himself can execute both single commands and a list of commands using special control characters (&, |). For example:

Command 1 & Command 2 - Command 1 will be executed first and only then Command 2;
Command 1 && Command 2 - only after the successful execution of Command 1 will Command 2 be launched. It is possible to redirect the stream output by the program directly to text file for further processing. To do this, you must use the control character ">" and the name of the text file. An example of outputting the contents of the current directory to the Report.txt text file using the dir command is shown below:
dir>Report.txt

An administrator can run multiple instances of the console by calling cmd.exe from the command line. Using the nested console allows you to work with the environment variables of the operating system without any consequences for the entire system as a whole, since changes to the environment variables are not saved after the nested console is closed. The setlocal, endlocal, and set commands are used to control this process.

There are many commands and utilities in modern operating systems. Remember so many different programs, and even more so their parameters
very difficult, therefore one of the most important parameters for each program is a combination of characters /?. After executing a command with this parameter, the user will receive a comprehensive message about the application of the utility and the syntax of its parameters.

Note that the illustration at the top left of the next page uses complex syntax. So, right after the shutdown /? after the special separator "|" there is a more command, which allows you to display information on the screen not entirely, but in certain portions, convenient for further reading.

To close the command line console, you must execute the exit command.

Who is in charge here?

According to their capabilities, console programs are divided into:

  • operating system management commands are commands such as shutdown or taskkill;
  • network commands - net and ipconfig;
  • commands for monitoring the system - tasklist and systeminfo;
  • support teams file system- dir, mkdir, copy;
  • service commands hard drives- defrag and diskpart;
  • commands to support the directory service (Active Directories) - addrep and dsadd;
  • auxiliary commands, this section includes various utilities for creating scripts, configuring printers, working with environment variables, etc.

Let's take a look at typical representatives of each group and allow ourselves to give some recommendations on the use of the commands included in them.

Monitoring and diagnostic commands

For troubleshooting hardware problems and problems with software monitoring commands such as systeminfo and tasklist are intended. These utilities first appeared only in the operating room. Windows environment Server 2003, so administrators have not yet fully appreciated functionality these commands. So, for example, now you don’t need to go to the “Properties” tab of the “My Computer” icon - the systeminfo command will print on the console screen basic information about all system components with full decryption. The /s option will display information about any remote computer. For example, to find out the configuration of the TESTSERVER computer, run the following command:

Systeminfo /s TESTSERVER

And the tasklist utility will show the processes running on your computer.

The tasklist utility allows you to query systems connected to a network. The /v option allows you to get verbose listings from useful information, including usernames, and the /t option shows the processes that loaded the particular dll file. Other useful utility- openfiles - allows you to get information about all open files local and remote operating system. IN previous versions Windows operating systems had to use the oh.exe command, in modern versions it is enough to execute a command in the console command line that sets the monitoring mode for all open system files:

Openfiles /local on

The user will get information about all open files on the system using a command with a simple syntax:

openfiles

The openfiles command with the /query /v options shows which users have started the processes that opened the files. With the help of other key parameters, you can set a different mode of information output.

Control commands operating system

Windows Server 2003 provides administrators with new commands that help them not only diagnose the system, but also manage it. These commands include the shutdown utility. The following can be used as key parameters of this utility:

  • / s - complete regular shutdown of the system;
  • /p - power off;
  • /f - shutdown of active applications;
  • /d - transition to low power consumption mode;
  • /I - end the session without turning off the computer.

The Shutdown Event Tracker, which collects and diagnoses all shutdowns performed by the administrator, acts as a tool that registers all regular shutdowns of the computer. It is also possible to shut down the system with an indication of the reason, for this you must use the / d switch.

The taskkill command, analogous to the kill command in operating systems of the *nix family, allows you to "kill" a hung application. Together with the tasklist command, these utilities provide a powerful tool for quickly interfering with the execution of applications that pose a potential threat to server performance. From the parameters of this command, it is necessary to note the /pid key, which allows you to terminate the process by its unique identifier, and the /im key - to terminate the application with the specified name. The following example terminates processes with IDs 1000 and 1240:

Taskkill /pid 1000 /pid 1240

Commands for servicing hard drives

You can use the defrag command to optimize your hard drive. The utility can defragment disks with file FAT system, FAT32 and NTFS. Defrag works equally well with dynamic type disk, and with the base. The syntax for calling this command is as follows:

Defrag disk [ -a j [ -f ] [ -v ] [ -? ]

The -a option only analyzes the information on the disk, the -f option optimizes the information, including when there is not enough disk space to create temporary files, and the -v option prints a report on the optimization progress. Do not forget that for a successful defragmentation, the disk must contain at least 15% free space.

The fdisk command is no longer supported by the operating system kernel. Windows systems Server 2003. It was replaced by the diskpart command, also designed for servicing hard drives. Partition a disk, create logical disks, delete them - these are just some of the tasks solved by this utility. Basically, the diskpart command is focused on working with special script files that describe the procedures for servicing hard drives. This is how the call to this command looks like for the script file Scriptl.txt:

Diskpart /s Scriptl.txt

Each line of such a file is an instruction for some operation. So, for example, gives the command to create a new partition with a specific string size

Create partition logical size=2048

Network commands

Among the network commands, I would like to highlight two utilities. The first is the ipconfig command, the second is netstat. System administrators use these commands not only to monitor the network, but also to protect against dangerous programs that try to take control of the system.

Using the ipconfig utility, the user can find out the network address of his computer, and by calling this command with the /all parameter, get full information about the network configuration on local computer. The /renew option allows you to change network settings without rebooting the entire system.

If you notice that something is wrong with your computer, then the netstat command will help in this case, which will not only indicate open network ports through which attackers could connect to your system, but also identify processes running on the server without your known. So, the /o switch displays information about the process ID (PID) using one or another network connection. It is possible to see which computers on the network are interacting with your local operating system.

Directory Services Commands

The entire network consists of components and is a complex hierarchical structure built in the form of a tree. The objects of such a system are sites, subnets, servers, computers, groups, users, contacts, shared network devices.

To monitor such a complex structure, the operating system provides the dsquery command, which is designed for advanced search of directory service components. Also, this command can be used to display information about the properties of selected components (key -attr). The -scope, -subtree, -onelevel, -base parameters determine the nesting level of the search, and the -filter key allows you to use the search filter.

The dsmod command can help you if you need to modify one or more accounts for a selected directory service component. For example, you can remove a user from a group or assign him New password. An example of changing the account for the user TestUser is shown below:

dsmod user
"CN=TestUser,CN=Users,DC=bigtex,DC=net" -pwd [email protected]-mustchpwd yes

The dsmove command moves an object within the current domain. Using the -newname and -newparent switches, you can set a new name for the object and change its location.

Commands for file system support

A description of some frequently used commands for working with files and directories is presented in the table. The deltree command, which performed a cascading deletion of folders and files in them, is now replaced by rmdir with the /s switch.

Little secrets of a big system

Changing the command line prompt

Find the key in the registry: Create a string parameter "PROMPT" with the type (REG_EXPAND_SZ) in this key and assign one of the following values:

  • $B - vertical bar "I";
  • $D - current date;
  • $G - greater than sign ">";
  • $1_ - less than sign "<»;
  • $N - current disk;
    $P - current drive and path;
  • $Q - = "=";
  • $T - current time;
  • $V is the version of Windows;
  • $$ is the dollar sign "$".

After the reboot, you will see the prompt in the form you defined.

Autocommand set

To enable auto-typing of commands by pressing the "Tab" key, find the key in the registry:

Then set the value of the CompletionChar parameter to 9, which corresponds to the key identifier "Tab", close the registry and restart the computer. In the console window, while typing part of the command name, you can now press the "Tab" key, and Windows will automatically substitute the required command.

Console color change

Find the key in the registry:

Change the DefaultCoior parameter. The -F0 value will display black text on a white background, while the IE value will surprise you with a yellow and blue coloring of the console.

Quick launch of the command line console from the context menu

Find the key in the registry:

Add "CommandPrompt -> Command" subsections to it. Set the Default parameter of the Command key to "cmd.exe /k cd "%1"".

Set the Default parameter of the Command Prompt key to "Open Command Prompt".

Clicking right click mouse on any folder in Explorer, you can select the Open Command Prompt command, which will launch a command line console in the desired directory.

Conclusion

Well that's all. We talked about the basics of working with the console. Then we give you the opportunity to explore the functionality and diversity console commands. Just do not forget the cherished key /?, and the rest will come with time and experience.

The article describes various ways how to hide the cmd window while running a batch file.

Batch files, they are also batch files, are very useful for running a whole batch of commands. But I think many people are wondering how to make the console window not appear on the monitor. I will focus on the built-in capabilities of the system, I will mention in passing third-party programs. Along the way, we will solve some other tasks, for example, by adding a separate label for the batch file.

How to bypass UAC protection? Refer to article

How to hide cmd window. Can this be done using the batch file itself?

No. The code works in the console environment, which means the window will be displayed. You have to live with this: the window will be open as long as the code is being executed. All you can do is take some steps to make the window appear for a minimum amount of time. In principle, this is useful: we can observe the work of the code with our own eyes. But if you want to hide the console window, you have to use third party tools: other developers or the capabilities of Windows itself. Let's start with her.

Run a batch file invisibly. Windows only.

In the “Code Madness” file itself, you sing the song yourself. I will suggest optimizing its content for the most quiet operation. There is important point: the shorter the code itself, the more likely it is that the console window will appear for a short time. If the volume is large or several commands are written at once, the window may attract attention.

For example, I will take a script code that allows a little (specifically, the characteristics processor in System Properties ). This is done for the duration of the Windows session: after a reboot, everything will fall into place.

In general, we have the following batch file code:

REGEDIT4 ; @ECHO OFF ; CLS ; REGEDIT.EXE /S "%~f0" ; EXIT "ProcessorNameString"="Intel(R) Core(TM) i112-3470 CPU @ 800.5GHz"

Pay attention to the characteristics of the processor. He will be responsible for changing system information. Name the file spec .bat . Also note that I will use only Latin characters in file names and avoid Cyrillic in the paths to their location, so that the path to the script is read by the system correctly. Therefore, I will put the created bat file in the system directory - directly to the C: drive.

However, its launch is accompanied by:

  • the appearance of the console window cmd
  • the appearance of a UAC confirmation window with the changes being made (the task, as you can see, has become more complicated in itself, because the system information is changing)

UAC window appears before batch file execution

I suggest you get rid of the first window with the help of the following script, which is already formatted in the next vbs file. And here is the script for it (see my path to the C:\spec.bat file):

"HideBat.vbs CreateObject("Wscript.Shell").Run "C:\spec.bat", 0, True

I'll call it any name with the .vbs extension. Now the work of the batch file by clicking on the vbs-nickname is accompanied only by the appearance of the window control accounts : the fact is that the changes made by the batch file concern the registry, and the system logically does not skip this uncontrollably. How is the topic of a separate article:

However, we will digress a little from the topic of the article and finish what we started by creating a console hiding file for the file ( vbs file) special label. In the Object location field, specify the path in the following format:

wscript path-to-vbs-nick-path-to-bat-nick

The label is ready (you can change its design via Label properties). You can drop it to your choice in the Startup folder, place it in Windows Scheduler or run with a double click. There will be no console window.

How to hide cmd window? Special programs.

There are a lot of them, they are lightweight and easy to use. Minus - they need to be downloaded, and some to install. Here are the most popular ones:

  • Hidden Start (HStart)

Utility of a domestic manufacturer. I need to buy, I do not know the cost. However, it can be used to hide the window once and for all, and it doesn't matter if UAC confirmation is required or not, it can also be hidden:

For 32 and 64 bit versions. It does not require installation, it is supplied as an executable file, which, when launched (on behalf of the administrator), immediately asks for the Windows root directory. We agree, and she is now with us:

The utility can do a lot of things, including changing the sound level, opening drive trays, etc. For our case, to hide the cmd window, one could simply enter the command in the form:

Nircmd elevatecmd exec hide filepath

They did not get rid of the UAC window (elevatecmd exec is part of the command with a request for UAC), but we were not promised. And it is inconvenient to constantly write the full path to the file in the console, so we will immediately create a shortcut:

Nircmd cmdshortcut "~$folder.desktop$" "Batch file" elevatecmd exec hide filepath

How to hide cmd window: batch turned into exe.

Also an option. This is the music of the higher spheres. To whom this utility is unknown, get acquainted - it will come in handy: Bat To Exe Converter. As you understand by the name, it turns the batch file into an executable file with the .exe extension. Download, install, use:

Good luck.

Read: 546

The command line (aka shell) may seem like a rather complicated tool, because. is the complete opposite GUI. However, when used correctly, the command line can greatly increase your productivity. So it never hurts to learn a few command line tricks to improve your productivity.

While there are a huge number of commands you can use in the console (more than 280 in fact), we are going to show you some of the really useful ones.

List of all installed drivers

If you want to see all the drivers installed on your computer, then you can easily do it right from the command line. Just open a command prompt window and type driverquery. When you hit Enter, you will see a large list of all installed drivers, along with information such as driver name, executable name, driver type, and so on.

Run multiple commands in sequence

If you don't want to wait for the next command to complete its work before you could run the next one, there is a way to enter multiple commands so that they are executed one after the other. All you have to do is add "&&" between the commands to separate them like this command1 && command2 && command3. Now, when the command1 command is executed, command2 will start, and when it completes, command3 will start.

Get help on any command

If you can't figure out what a particular command does or what its use cases are, you won't have to look it up on the web. The command line provides complete information about what each command does, and may even give examples of how the command is used (if possible). Just dial / ? after the command you are interested in, for example assoc/?.

Find out the IP address of a website

If you want to know the IP address of any website, you can easily do it right from the command line. For this purpose, dial nslookup< названиесайта> , for example, nslookup coderjob.ru and you will see its IP address.

View previously entered commands

If you need to type another command during your console session, you won't have to type it again. All you have to do is use the up and down arrow keys to cycle through all the commands already executed. You can also press the F8 function key to do the same. Below is a list of actions for other function keys when working in the command line:

  • F1- It inserts the command that was last executed using the command line, one command character at a time.
  • F2- Inserts the part of the command that was executed last on the command line, however, it will ask you to enter the character before which you want to insert the command. For example, if the last command was ipconfig /displaydns and you pressed d after pressing F2, ipconfig /i.e. will be inserted into the command line. all characters before d will be inserted.
  • F3- Inserts the last executed command (whole).
  • F4- Displays a dialog box that prompts the user to enter the character up to which to delete the text of the current command.
  • F5- Inserts the last executed command. When pressed again, it shows all commands in reverse order of command execution. After the oldest command has been shown, i.e. command that was executed first in the current session, pressing the F5 key does nothing.
  • F6– Inserts the ^Z escape sequence into the command line.
  • F7- Displays a list of previously used commands in the form of a dialog.
  • F8- Inserts recently executed commands into the command line. Note that unlike F5 in that it cycles endlessly between previously executed commands.
  • F9- As mentioned above, the command line stores a list of all executed commands. This list is numbered from 0 to 9. When you press the F9 key, a dialog appears prompting you to enter the number of the command you wish to reuse.

Also, if you want to stop running a command before it completes itself, you can use the keyboard shortcut ctrl+c.

Run command prompt as administrator without using mouse

There are several commands that require administrator privileges to work. To run these commands, you need to run Command Prompt as an administrator. Doing this with the mouse is not very convenient. We will tell you how to run Command Prompt as an administrator without using a mouse. There are two ways to do this:

  • Type cmd in the start menu search box and press Ctrl + Shift + Enter at the same time.
  • Create a shortcut for cmd.exe. Right-click the shortcut file and click Properties. On the Shortcut tab, click on the ‘Advanced’ button. A new dialog box will appear. Select the Run as administrator check box and click OK. Then click OK to close the Shortcut Properties window. Now, when you want to open a command prompt window with administrator rights, all you have to do is double-click the shortcut you created.
Command completion with the Tab key

Tab completion is another Command Prompt window feature that can save you a lot of time, especially if your command contains a file or folder name and you're not quite sure about it.

To use autocomplete on the command line, simply type the command followed by the part of the file path you know. Then, press the Tab key until the value you want is pasted into the command line.

For example, you want to change directories to some folder in Windows folder, but you're not sure what it's called. Enter command cd C:\Windows\, and then press the Tab key until you see the folder you're looking for.

Find out the IP address and name of your computer on the local network

With a single command line command, you can easily get basic information about your network connection, such as IP address, subnet mask, and default gateway address. To do this, enter on the command line ipconfig /all and press the Enter key. To find out the network name of your computer, enter the command hostname

Also, if your computer's IP address is dynamically assigned (i.e. your network is using DHCP), you can force your IP address to be updated by running the following command:
ipconfig/release & ipconfig/renew

Get information about network drives and folders

Enter net use on the command line and you will see all the network drives you are connected to. To find out which folders on your computer are accessible from the network, enter the command net share.

Check the model and serial number your computer

Enter wmic computersystem get model to find out the models of the computer you are working on. Alternatively, you can find out the serial number of your computer by typing the following command: wmic bios get serialnumber.

Open windows explorer from the command line

To open Windows Explorer from the command prompt, type the command start. and press Enter.

Shutting down and restarting the computer from the command line

To shutdown the computer from the command line, you need to run the following command:
shutdown / s / t 60 and the system will be turned off in one minute (the /t key is responsible for this with a delay of 60 seconds).
To turn off remote computer running on Windows, you need to run the following command: shutdown /s/t 60 /f/L/m\\192.168.1.55 To reboot the system you need to run the command shutdown-r-t0.

Launch any of the Control Panel applets
Control Panel applet name Command
Ease of Access Center access.cpl
Adding a new device hdwwiz.cpl
Programs and Features appwiz.cpl
Administration control admintools
Windows Update wuaucpl.cpl
Certificate Manager certmgr.msc
Computer management compmgmt.msc
Control Panel control
date and time timedate.cpl
Device Manager devmgmt.msc
Disk defragmentation dfrg.msc
Disk Management diskmgmt.msc
Desktop personalization control desktop
Screen resolution desk.cpl
Event Viewer eventvwr.msc
Folder properties control folders
Fonts control fonts
Local Group Policy Editor gpedit.msc
Keyboard control keyboard
Local Security Policy secpol.msc
Local Users and Groups lusrmgr.msc
Mouse control mouse
Network connections ncpa.cpl
Resource Monitor perfmon.msc
Power supply powercfg.cpl
Devices and printers control printers
language and regional standards intl.cpl
Task Scheduler control schedules
Support Center wscui.cpl
Services services.msc
Shared folders fsmgmt.msc
Sound mmsys.cpl
Properties of the system sysdm.cpl
Liked the article? Share with friends!
Was this article helpful?
Yes
Not
Thanks for your feedback!
Something went wrong and your vote was not counted.
Thanks. Your message has been sent
Did you find an error in the text?
Select it, click Ctrl+Enter and we'll fix it!