-1

How do I launch a cmd window and input the commands i specify into the cmd for windows using a python script?

For example , the script will launch the cmd and input the following : runas /username:Admin control

Then cmd will then prompt the user for their passwords and open the control panel. Any idea? Thanks

user2633882
  • 1,551
  • 3
  • 11
  • 6

1 Answers1

1
import subprocess 
subprocess.call(['runas', '/username:Admin', 'control'])

Don't have a python shell here to test, but this should get you pretty close to what you want.

It should run the runas command which will prompt you for the password, then launch the control panel. This could easily be done with a batch program too, or even just a shortcut. Just putting that out there.


controlpanel.bat

This one is most comparable to your python script, but it skips having to load the pyton interpreter.

runas /username:Admin control


shortcut

This one lets you have a little more control over the command, and who is running it. *right click desktop

*new

*shortcut

*Enter "runas /username:Admin control" for the Location.

*Type a name for the shortcut.


alternative shortcut

This one is useful if you just want UAC to handle it.

  • same as above, but for location type just "control"

  • then right click on the new shortcut, and click properties.

  • click the shortcut tab

  • click "advanced"

  • check the "run as administrator" box.


Bonus alternative

This gives you a master list of all settings you can change, rather than just the control panel.

  • Create a new folder, and rename it to:

    Settings.{ED7BA470-8E54-465E-825C-99712043E01C}

  • You can change the "Settings" part to anything you want

  • follow the instructions above for "alternative shortcut"

Gray
  • 7,050
  • 2
  • 29
  • 52