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?
Maroun
96.4k30 gold badges195 silver badges249 bronze badges
1 Answer 1
This should work
import subprocess
subprocess.call(['C:\\Windows\\System32\\PNPUTIL.exe'])
answered Jun 21, 2013 at 6:55
Kris
8,8984 gold badges45 silver badges71 bronze badges
Sign up to request clarification or add additional context in comments.
7 Comments
glglgl
@AshwiniChaudhary This one should work as well. Just tried it with
subprocess.call(['C:\\Windows\\System32\\systeminfo.exe']).Kris
@AshwiniChaudhary I'm not a python expert, just do bits of it. I will check and update.
Ashwini Chaudhary
@Krishnanunni This looks fine, I guess I misread it.(cmd's commands confuse me). +1 anyway
user2507907
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"
Kris
check system32 folder, find the file 'PnPutils.exe'. Try using the case properly as in file name.
|
lang-py
path = os.path.abspath(path)?osbut not using it to construct your path.a='\\' == os.sep, andpath=r"C:"+a+"Windows"+a+"System32" == path=os.path.join("C:","Windows", "System32")