Tag: cmd

ImageMagick error on Windows: “magick: unable to open image ”test’: No such file or directory @ error/blob.c/OpenBlob/3565. magick: no decode delegate for this image format `’ @ error/constitute.c/ReadImage/741.” (SOLVED)

If in Windows 11 open CMD:

cmd

And then run the command:

magick '.\Для теста.jpg' test.png

An error will be received that there is no such file or directory:

magick: unable to open image ''.\╨Ф╨╗╤П': No such file or directory @ error/blob.c/OpenBlob/3565.
magick: no decode delegate for this image format `' @ error/constitute.c/ReadImage/741.

You can see that non-Latin characters are used in the file name, so you might think that this is the problem – that is, the “magick” program does not support alphabets other than English.

But if you try to rename the file and run the following command:

magick 'test file.jpg' new.png

Then the same error will be received again:

magick: unable to open image ''test': No such file or directory @ error/blob.c/OpenBlob/3565.
magick: no decode delegate for this image format `' @ error/constitute.c/ReadImage/741.

How to fix “magick: unable to open image ''test': No such file or directory @ error/blob.c/OpenBlob/3565. magick: no decode delegate for this image format `' @ error/constitute.c/ReadImage/741.”

1. Use double quotes instead of single quotes

If the filename is enclosed in double quotes instead of single quotes, then the command works correctly:

magick ".\Для теста.jpg" test.png

That is, try putting the filename in double quotes. If the problem persists, then it is related to the encoding of the file name.

2. Use PowerShell instead of CMD

In Windows 11 and Windows 10, the default command prompt is PowerShell, not CMD.

If your Windows uses CMD by default, then either set it to use PowerShell in the settings, or run one of the following commands at the command prompt:

powershell
pwsh

In Windows 11 + Windows Terminal Preview + PowerShell 7 command

magick '.\Для теста.jpg' test.png

works without errors.

See also: ImageMagick guide: installing, using, and troubleshooting

Basics of launching and using command line utilities in Windows

Are the command line and command line utilities relevant today?

Windows users are accustomed to using programs (applications) with a graphical user interface, in which actions are performed using mouse clicks or keyboard input.

At the same time, even in Windows there are and can be installed many utilities, programs without a graphical interface, with very useful functionality. As a rule, programs without a graphical interface are designed to perform a highly specialized action or function and are designed for professionals.

Programs without a graphical interface are called “command line utilities”, “programs with a command line interface” (CLI).

There is no need to think that command line utilities are some kind of atavism and something outdated. This is very far from the truth! Entire layers of specialized programs in various fields are developed precisely as utilities with a command line interface.

The purpose of this note is to give a general idea to Windows users about how to deal with the command line. If you have downloaded the utility and cannot run it, then this note is for you!

When I click on the exe file, a black window flickers and then disappears

When you try to launch the command line utility by double-clicking, you will most likely encounter the console window flashing for a second, which immediately closes.

Programs with a command line interface are not designed to be launched by double-clicking. Instead, they need to be run, as you might have guessed, on the command line.

Windows has several environments for executing commands:

  • CMD
  • PowerShell (includes all the features of CMD and provides many cmdlets for administering Windows desktops and servers)

You can also remember Windows Terminal, but this is not a separate environment that has its own commands, but just an application for conveniently entering CMD and PowerShell commands.

To run the program, you need to open a Windows Terminal window (or PowerShell). To do this, press the key combination Win+x, and select “Windows Terminal” or “Windows Terminal (Admin)”:

What to choose: “Windows Terminal” or “Windows Terminal (Admin)”

Utilities can be run with normal user rights, or require running with Administrator rights.

With Administrator rights, for example, the following programs should be launched:

  • Programs that register and install themselves as system services
  • Programs that require low-level access to devices (for example, programs for partitioning or fixing disk errors)
  • Programs that change system settings that only an administrator can change.

An example of programs with a command line interface that require Administrator rights:

  • Apache (web server, it registers and starts itself as a system service)
  • MySQL (DBMS, it registers and starts itself as a system service)

An example of utilities that do not require elevated privileges:

How to run an executable on the command line

Consider running a program with a command line interface using the Apache web server (httpd) as an example.

The first option: you can simply drag and drop the executable file into the command line window. The Apache executable is httpd.exe.

The second option: on the command line, you can change the current working directory to the one where the Apache executable files are located. For example, my program is located in the C:\Apache24\bin\ folder, to change the current working folder, the “cd” command is used, after which the folder you want to go to is indicated, in my case the command looks like this:

cd C:\Apache24\bin\

As you can see from the screenshot, the C:\Users\MiAl folder has been changed to C:\Apache24\bin\.

Now, to run the program, it is enough to type the name of the executable file indicating the current folder. The current folder is indicated by a dot (.), then you need to put a backslash, it turns out like this:

.\httpd.exe

Apache is a network service, that is, a program that uses a computer network for its work. Specifically, Apache listens for incoming connections on port 80 (the service opens a port). For this reason, the Windows Firewall asks whether to allow the Apache HTTP Server program to communicate on the network, select “Allow access”.

Already at this stage, the web server is running, and you can open the address http://localhost/ in a web browser

To stop the service, press Ctrl+c.

How to get help using the utility

Typically, command-line utilities support various options that can be specified with a space after the executable file name.

Also, utilities usually have built-in help on available options, which can be displayed using the -h option or the --help option, which must be specified after the executable file name.

For example:

.\httpd.exe -h

In addition to command line options, many services are configured using configuration files, which are text files with a specific syntax. This is especially common for utilities that came to Windows from Linux, since in this operating system many programs are configured using text files.

In this case, quite often explanations of custom directives are contained in the configuration file itself in the form of notes, or in accompanying documentation.

README, ReadMe.txt, README.md files and software documentation

Utilities are usually accompanied by documentation. For example, this is an Apache archive:

As you can see, the ReadMe.txt file with documentation is attached to the archive – this is documentation from those who compiled Apache for Windows.

Inside the Apache24 folder there are even more files and folders with installation information and more.

This is a PHP archive – it also contains a README.md file that provides help information.

A MySQL archive containing a README file and a documentation folder or a link to the documentation.

Program in PATH environment variable

The above shows that in order to run the program, you need to go to the folder with this program.

Alternatively, you can specify the full path to the executable, for example:

C:\Server\bin\Apache24\bin\httpd.exe

It is this method that works when you drag and drop the utility into the console to run the utility – in this case, the full path to the file is inserted into the command line.

But some commands run from any folder, wherever you are on the command line. For example, try the following command:

find /?

The fact is that for operating systems there is such a thing as the PATH environment variable.

The essence of the PATH environment variable is as follows:

1. The PATH variable is assigned a value that consists of a list of folders, that is, paths in the system.

2. When you run a file on the command line, the operating system tries to find it both in the current folder (where you went with the “cd” command, or open by default), and in each folder specified in the PATH environment variable

3. If the file is found in the current folder, or in any PATH folder, then it is launched.

This is the reason the following command always works:

find /?

The reason is that it is placed in one of the folders listed in PATH (namely C:\Windows\System32\).

To view the current value of the PATH environment variable, run any of the following commands:

Get-ChildItem -Path Env:PATH

$env:PATH

Example PATH content in Windows 11:

C:\Program Files\PowerShell\7-preview;C:\Program Files\ImageMagick-7.1.0-Q16-HDRI;C:\Server\bin\PHP\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\libnvvp;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\Nsight Compute 2022.1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\PowerShell\7-preview\preview;C:\Users\MiAl\AppData\Local\Microsoft\WindowsApps

You can place frequently used utilities in a folder included in PATH. Either you can add a new folder to PATH with the utilities you want to run without specifying the full paths to the executable files, or without having to change to the directory with these utilities.

You can set the value of PATH (and other environment variables) both in the GUI and on the command line.

See also:

Do I need to specify the extension of the executable file

When running executable files, it is not necessary to specify the extension, because the console will understand what you mean. For example, the following two commands are identical:

hashcat.exe

hashcat

Conclusion

This note is intended to give you a general idea of how to start and use the command line utilities. For basic information on using a particular utility, see the help displayed with the -h option or the program's documentation.

If you encounter an error when starting the utility, try running the program in an elevated command prompt (with admin rights).

If you get a message that “file not found”, go to the folder with the installed program using the “cd” command, or drag and drop the executable file to the command line.

If you received an error message inside the program when starting the program, then study the utility options and examples of its launch in more detail.

How to display all environment variables at the Windows command prompt

This article will show you how to display all environment variables from the Windows command line.

PowerShell and CMD

First of all, you need to distinguish what kind of program you are working in. The first appeared CMD - Windows command line, shell. For many years, CMD was the only option for running on the Windows command line.

Then PowerShell came along. In the beginning, it was an environment that could be specially launched. In recent years, PowerShell has become more common, in the “Power User Menu”, which is invoked by the Win+x keyboard shortcut, PowerShell has replaced CMD. Also, the new Terminal uses PowerShell by default.

The commands for displaying all environment variables depend on whether you are in PowerShell or CMD, so you need to differentiate between them.

PowerShell looks like this:

Or like this:

That is, the command line prompt begins with “PS”.

And the CMD looks like this:

Or like this:

How to list all environment variables in PowerShell

In PowerShell, use one of the following commands:

gci env:
ls env:
dir env:

They are not only equivalent, in fact, they are just aliases for the same command. That is, there is no difference in their use.

How to display all environment variables in CMD

To display environment variables in CMD use the command:

SET

To cut the output in one screen with the ability to scroll through the list, use the following construction:

SET | more

To save the output to a file:

SET > output.txt

This text file, output.txt, can be opened in any editor such as Notepad.

To display the value of a specific variable, use the familiar set command with the variable name:

set VARIABLE

For instance:

set PATH

The set command prints the value of all variables that start with the line VARIABLE. For example, the previous command will print the values of the PATH and PATHEXT variables.

And the following command will print the values of all variables whose name begins with P:

set P

Note that command names on Windows are not case sensitive.

Loading...
X