Linked Questions

Popular Questions

Trying to access the correct directory

Asked by At

So I'm trying to write a script that'll use the command line in Windows, and it's defaulting to a structure that is under my Python directory - I don't want that.

import subprocess
import time
subprocess.call(r"""Cscript %windir%/System32/Printing_Admin_Scripts/en-US/Prnport.vbs -a -r "saturn.print.mediag.com" -h "saturn.print.mediag.com" -o raw""")
time.sleep(5)
subprocess.call(r"""rundll32 printui.dll, PrintUIEntry /if /b "Saturn" /f w:\printers\toshibae3511\eng\est_c2.inf /r "saturn.print.mediag.com" /m "TOSHIBA e-STUDIO Color PS3""")
raw_input("press any key to exit")

The first subprocess call should execute the script prnport.vbs in c:\windows\system32, etc, etc, however instead it goes to like c:\python27\projects\printer setup\%windir%\system32, etc etc

How do I make it go to the correct directory, which might (though probably won't) vary per computer?

Related Questions