1

Code snippets are as follows:

import os
a= "\\"

path=r"C:"+a+"Windows"+a+"System32"

print "\n path :",path

os.chdir('C:')

os.path.abspath(path)

os.chdir(path)

print os.getcwd()

os.system('PNPUTIL.exe')

Result :

path : C:\Windows\System32

C:\Windows\System32

'PNPUTIL.exe' is not recognized as an internal or external command,
operable program or batch file.

Though the utility is available its not geting identified,wat could be the problem?

2
  • Did you mean: path = os.path.abspath(path)? Commented Jun 21, 2013 at 7:06
  • 1
    I find it interesting that you are importing os but not using it to construct your path. a='\\' == os.sep, and path=r"C:"+a+"Windows"+a+"System32" == path=os.path.join("C:","Windows", "System32") Commented Jun 21, 2013 at 7:33

1 Answer 1

3

This should work

import subprocess
subprocess.call(['C:\\Windows\\System32\\PNPUTIL.exe'])
Sign up to request clarification or add additional context in comments.

7 Comments

@AshwiniChaudhary This one should work as well. Just tried it with subprocess.call(['C:\\Windows\\System32\\systeminfo.exe']).
@AshwiniChaudhary I'm not a python expert, just do bits of it. I will check and update.
@Krishnanunni This looks fine, I guess I misread it.(cmd's commands confuse me). +1 anyway
subprocess.call(['C:\Windows\System32\PNPUTIL.exe']) also didn't work,It throws error "Traceback (most recent call last): File "D:\InstallUninstall\new.py", line 8, in <module> subprocess.call(['C:\Windows\System32\PNPUTIL.exe']) File "C:\Python31\lib\subprocess.py", line 428, in call return Popen(*popenargs, **kwargs).wait() File "C:\Python31\lib\subprocess.py", line 658, in init errread, errwrite) File "C:\Python31\lib\subprocess.py", line 868, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified"
check system32 folder, find the file 'PnPutils.exe'. Try using the case properly as in file name.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.