Are you running this in a regular terminal? In Windows, you need to open the terminal specially for administrative privileges:
- In the Start menu search window, type cmd and press
Ctrl
+Shift
+Enter
. Or, navigate to All Programs > Accessories > right click on Command Prompt and click Run as administrator
.
- Run the python script in this new terminal.
Edit: a search yields it also may be an issue with executing the command after navigating to the directory the installer is located in; see WindowsError [error 5] Access is denied.
install_dir=r"C:\Users\xUser\"
assert os.path.isdir(install_dir)
os.chdir(install_dir)
subprocess.Popen('jdk-8u45-windows-x64.exe /s ADDLOCAL="ToolsFeature,SourceFeature"')
Finally, I always use an array of commands for Unix (not sure if it's required in Windows), not one long string, e.g.
subprocess.Popen(['jdk-8u45-windows-x64.exe', '/s', 'ADDLOCAL="ToolsFeature,SourceFeature"'])
.