Search code examples
pythonwmic

Python script using WMIC. required argument 'flags' (pos 2) not found


I have a simple python script that uses wmic, to gather information from remove machines. Everything worked well until I added a line to gather some version information about iexplorer (the os4 line).

os3 = os.popen('wmic /user:"' + username + '" /password:"' + pword + '" /node:"'+ name + '" os get Caption, CSDVersion /format:list').read()
os3 = os3.replace('\n','')
    
os4 = os.open('wmic /user:"' + username + '" /password:"' + pword + '" /node:"' + name + 'DATAFILE WHERE Name="%SYSTEMDRIVE%\\program files\\internet explorer\\iexplore.exe" os get Version /format:list').read()

The line requesting version information on iexplore.exe is returning this error:

TypeError: Required argument 'flags' (pos 2) not found

I don't see what the error is.


Solution

  • The answer lies in my world class typing skills.

    os4 = os.open( ...
    

    should be

    os4 = os.popen( ...