Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There could be a few reasons why wmic may work in Command Prompt (cmd) but not in a batch file:

  1. Permission Issues: wmic may require administrative privileges to perform certain actions, and the batch file may not be running with sufficient permissions. Ensure that the batch file is being run as an administrator.

  2. Syntax Error: There may be syntax errors in the batch file that are causing the wmic command to fail. Make sure that the syntax used in the batch file is correct.

  3. Path Issues: The batch file may not be able to locate the wmic executable. Try adding the full path to the wmic executable in the batch file.

  4. Environment Variables: The environment variables used by wmic may not be set correctly in the batch file. Check that the necessary environment variables are being set in the batch file.

  5. Interference with Other Batch Commands: The wmic command may be interfering with other batch commands in the file. Try running the wmic command in a separate batch file to see if it works independently.