wmic.exe does consume a console window input
#25
andry81
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
If run a script with a long time execution and a pause at the end, then the pause can miss any key press if
wmic.exehad run in between.Example with the issue:
Run
wmic.exeas is:https://github.com/andry81/contools--debug/tree/HEAD/test_pause_after_wmic.bat
Workaround 1:
Run
wmic.exein a standalone console:https://github.com/andry81/contools--debug/tree/HEAD/test_pause_after_wmic_workaround1.bat
Warning
The workaround has an issue with the WMIC installation. The utility may not be completely installed on the moment of a first time execution.
Or does installation with an error:
A localized version of another error (russian version):
But continues execution without further errors.
Warning
Because the standard error stream is not redirected, then an error output would be hidden by the minimized console window.
But you still can maximize the console window in case of a pause from
wmic.exe.Warning
The workaround additionally may await an input. For example, the Windows Server 2003 has the issue: https://stackoverflow.com/questions/20270241/calling-a-wmic-command-inside-for-from-a-batch-file-hangs-the-system-for-indefin
Workaround 2:
Run a vbs (bat) script instead of
wmic.exe:https://github.com/andry81/contools--debug/tree/HEAD/test_pause_after_wmic_workaround2.bat
Note
The script does not have the issues from the workaround 1 with the WMIC installation and an accident pause.
Note
The builtin
pausecommand does not use a console window input buffer because reads the immediate keyboard input. Any keyboard press before the command execution does ignore. See _kbhit function for details.Note
The scripts does use an external repository. To import it see details here: https://github.com/andry81/externals
Known Issues
wbemcore.loglog reportsGetUserDefaultLCID failed, restorting to system verionSeems this happens then WMI detects a change (for example, OS Display language change) and tries to rebuild the
wbemrepository.Beta Was this translation helpful? Give feedback.
All reactions