Wmic command placed in a batch file is not responding and refuse to work without administrator privilegies

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
BoQsc
Posts: 92
Joined: 30 Jun 2014 04:10

Wmic command placed in a batch file is not responding and refuse to work without administrator privilegies

#1 Post by BoQsc » 16 Mar 2020 03:19

I came across this weird behaviour with Wmic:
  • Running WMIC from manually opened command prompt without administrator privilegies - works properly and output is delivered as expected.
  • Running WMIC from batch file without administrator privilegies - Wmic is stuck in the permanent loop without any output.
  • Running WMIC from batch file with administrator privilegies - Wmic is showing output and everything is as expected.
Example file:

Code: Select all

@ECHO OFF
WMIC
pause
Another Example file:

Code: Select all

@ECHO OFF
WMIC Path Win32_LocalTime Get Day
pause

Eureka!
Posts: 136
Joined: 25 Jul 2019 18:25

Re: Wmic command placed in a batch file is not responding and refuse to work without administrator privilegies

#2 Post by Eureka! » 16 Mar 2020 04:50

Did you call your script WMIC.cmd/.bat?
That would explain this behaviour exactly.

I make a habit out of adding the file extension to programs used in scripts to avoid this (replace WMIC with WMIC.exe)

But it is always better to avoid naming your scripts the same as an already existing program.

BoQsc
Posts: 92
Joined: 30 Jun 2014 04:10

Re: Wmic command placed in a batch file is not responding and refuse to work without administrator privilegies

#3 Post by BoQsc » 16 Mar 2020 05:04

Eureka! wrote:
16 Mar 2020 04:50
Did you call your script WMIC.cmd/.bat?
That would explain this behaviour exactly.

I make a habit out of adding the file extension to programs used in scripts to avoid this (replace WMIC with WMIC.exe)

But it is always better to avoid naming your scripts the same as an already existing program.

I simply double clicked the script using GUI.
But it seems that adding .exe extension to the wmic command resolved the problem.

Thank you.

Post Reply