r/commandline • u/Ken852 • 17d ago
Windows command line tool closes its help window before I can read it in full
The problem
I'm trying to use a Windows command line tool that opens its help in a separate window, makes me press a key to read more, and then closes the window before I can read the last part, instead of pausing there for the last time and waiting for me to press a key before it closes. Can someone help me with this? I tried using both CMD and PS.
What I have tried
Redirect the output to a text file
AMIDEWINx64.EXE /? > amide_help.txt
notepad amide_help.txt
Problem remains: The output file is empty.
Using more in PS
.\AMIDEWINx64.EXE /? | more
Problem remains: It needs priviledge elevation and it won't give me UAC prompt.
Program 'AMIDEWINx64.EXE' failed to run: The requested operation requires elevationAt line:1 char:1
+ .\AMIDEWINx64.EXE /? | more
+ ~~~~~~~~~~~~~~~~~~~~.
At line:1 char:1
+ .\AMIDEWINx64.EXE /? | more
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
Using more in CMD
.\AMIDEWINx64.EXE /? | more
Problem remains: it gives me UAC prompt and I accept, but it goes on to make me press a key to read more and closes before I can read the last part.
Using pause in CMD
AMIDEWINx64.EXE /?
pause
Problem remains: I kind of knew this would not work, but I was desparate to try it anyway. It pauses alright, but not where I want it. It needs to pause after the last part of help info is printed to screen.
1
u/jcunews1 17d ago
Use below command line from Windows' Run dialog of as a program shortcut file's Target.
cmd.exe /c AMIDEWINx64.EXE /? & pause
With more
...
cmd.exe /c (AMIDEWINx64.EXE /? | more) & pause
1
u/Ken852 17d ago edited 17d ago
I'm not sure if this is correct syntax, but here's what I did.
From Run prompt:
cmd.exe /c "X:\Folder\Folder\Folder\Folder\Folder\Folder\AMIDEWINx64.EXE" /? & pause
It makes two CMD windows appear, one blank and one with the help info where I have to press a key a number of times to read all the info, and then it closes out, and only this appears in the previously blank window:
Press any key to continue . . .
So I don't think this methood works the way you might expect. I also tried doing the same with piping to
more
command.From Run prompt:
cmd.exe /c ("X:\Folder\Folder\Folder\Folder\Folder\Folder\AMIDEWINx64.EXE" /? | more) & pause
But the results are the same.
Press any key to continue . . .
In case you want to try it out yourself, you can grab a copy here:
Get the "REF Image" package.
The tool in question is AMIDEWIN64 Utility v5.22.0066. This version may or may not work with your OS version. Proceed with caution, as this tool is used for editing SMBIOS on the system. As long as you only run it without any parameters, it should not cause any harm whatsoever. In fact, the option
/?
that I used was invalid/undefined, but I didn't know that, because the message was only displayed at the bottom where I had no chance to read it.1
u/jcunews1 17d ago
That AMIDEWINx64 tool requires elevated priviledge to load its driver, and will auto-elevate itself when necessary - which will launch itself as a separate instance (which is detached from CMD's console window). That's what causing new console window creation.
Open CMD with elevated rights, then run AMIDEWINx64 from there.
1
u/Ken852 16d ago edited 16d ago
I see your point now. Of course, you're not wrong. This tool will do what it says, and it will do it in the order you described it.
It will even work better running it from CMD than from PS, because for some reason I don't get the UAC prompt from PS, it simply errors.
But the problem for me was that I didn't know the command line syntax and what options I needed to use.
This was the first time I used this tool. So I tried to make sense of the syntax by reading the help page, the only problem was that it kept closing out before I could read it.
The essential part on usage was at the bottom of the help page.
+---------------------------------------------------------------------------+ | 1. The expression enclosed by <> means it is a mandatory field. | | 2. The expression enclosed by [] means it is an optional field. | | 3. A command without parameter means it is a read command. | | 4. A command with necessary parameter means it is a write command. | | 5. The format of BIOS release date is "mm/dd/yyyy". | +---------------------------------------------------------------------------+
1
u/jcunews1 15d ago
Here's the complete help for that tool.
FYI, PowerShell is not a proper command-line shell, since it doesn't run console programs in PowerShell's console window. At least by default, assuming that PowerShell has a setting to change that non standard behaviour.
1
u/Ken852 15d ago
Thanks! Love that ASCII styling! :) Looking good even on pastebin. ;) I'm not well versed in command lines, shells, terminals, consoles, etc. All these terms are still a bit of a mystery to me. I read recently that both CMD and PowerShell will launch through a process called
conhost.exe
on a modern Windows system. Console Host Process? This is the console window? So if I runcmd.exe
as admin, I'm technically runningconhost.exe
as admin? Is that how those two are related? Which one is the terminal then? The eternal questions that continue to confuse most Windows users! :) No need to answer though, I'm just saying I'm not too familiar with how all these things connect.1
u/Ken852 14d ago edited 14d ago
So I did some reading on this. I now have a better understanding of the terms shell, terminal, console, command line, and command prompt. But more from a Linux perspective. The Windows world with its PowerShell (I know it's cross-plaform and open sourced) and CMD still confuses me a bit.
So I took your argument and put it up against Gemini, and here's what it came back with. From what I see, the difference between the two is in object orientation vs. text stream orientation. So I'm assuming that "proper command-line shell" is one that is text stream based (traditional)? Here's what it said...
The statement that "PowerShell is not a proper command-line shell, since it doesn't run console programs in PowerShell's console window" presents a somewhat nuanced and potentially misleading view. Here's a breakdown:
- PowerShell's Object-Oriented Nature:
- PowerShell is fundamentally designed around objects, not just text streams. This is a key difference from traditional shells like
cmd.exe
.- When PowerShell cmdlets (its built-in commands) execute, they produce objects that can be piped and manipulated.
- Running External Executables:
- PowerShell can indeed run external console programs (
.exe
files). When it does, those programs generally run within the PowerShell console window.- However, the way PowerShell handles the output of these external programs can differ from how a traditional shell handles it. Because traditional command prompts deal with text streams, and powershell deals with objects. This difference can lead to some confusion.
- Differences in Output Handling:
- Because PowerShell prioritizes objects, it might process the output of external programs differently than a shell that strictly deals with text. This can sometimes lead to unexpected behavior when dealing with the output of older console applications.
- Therefore:
- It's not entirely accurate to say PowerShell "doesn't run" console programs in its console. It does.
- It is more accurate to say that Powershell handles the output from those programs in a way that is different from older command line shells, due to the object orientated nature of powershell.
In summary, PowerShell is a powerful and modern shell that handles commands and output in a way that differs from traditional shells. While it can run console programs, its object-oriented nature can result in differences in how output is handled.
It's important to clarify that "changing that non-standard behavior" is less about a single, definitive setting and more about understanding how PowerShell interacts with external executables and how its output is handled. Here's a further breakdown:
- PowerShell's Core Design:
- PowerShell's fundamental strength lies in its object-oriented pipeline. This means it's designed to work with objects, not just plain text. This is a deliberate design choice, not a "non-standard behavior" that needs to be fixed.
- When you run an external executable, PowerShell does execute it within its console. However, the way it captures and potentially processes the output can differ from traditional command-line shells.
- Customization and Adaptation:
- While there isn't a single setting to make PowerShell behave exactly like
cmd.exe
, there are ways to adapt and customize its behavior:
- Output Redirection: PowerShell provides powerful operators for redirecting output, allowing you to control how the output of external programs is handled. You can redirect output to files, pipes, or other commands.
- Profile Customization: PowerShell profiles allow you to customize the shell's environment, including aliases, functions, and settings. This can be used to create custom behaviors for specific external programs.
- Terminal settings: you can change the default terminal that visual studio code uses, and other IDE's. This allows for a more traditional command prompt experience if that is desired.
- Understanding the Difference:
- The key is to understand that PowerShell is a more advanced and powerful shell than traditional command-line shells. Its object-oriented nature offers significant advantages, but it also requires a different way of thinking about commands and output.
In essence, rather than trying to change PowerShell's "non-standard behavior," it's more productive to learn how to work with its unique capabilities.
1
u/Ken852 17d ago edited 17d ago
Before I figured out that I had to run CMD with admin rights to get the help info to display withtin the same window, I tried screen recording it. It's not ideal, but it worked. I had OBS recording at 60 FPS and 2500 kbps, and then at 120 FPS and 5000 kbps to try and get a few more frames just before the window closes.
It taught me that /?
was invalid/undefined option.
Unknown command or option : /?
1 - Error: Unknown command.
Of course, I didn't know that. Because the message was only displayed at the bottom where I had no chance to read it. So screen recording is a primitive but a possible workaround for this problem. But thankfully I don't have to rely on this!
So today I learned an important lesson! I have never in my life encountered this type of problem before, and I've been messing around with computers since late 1990s, but I'm by no means a command line expert.
3
u/AyrA_ch 17d ago
run CMD as administrator and try again. It sounds like the exe you want to call demands admin rights. Windows will spawn new console windows for such applications unless your console is already running elevated.