1

I am trying to run date command with cmd, but I required to be an Administrator in order to do so. The command is: os.system("date 09/09/1999")

Is it possible to run the command with admin privileges without the need to import new libraries?

ali_m
  • 71,714
  • 23
  • 223
  • 298
user180894
  • 79
  • 1
  • 4
  • 3
    Operating System? API? – trojanfoe Aug 21 '13 at 11:37
  • "without the need to import new libraries" - probably not. On Unix, you'd need to call `sudo` to gain administrative privileges, on Windows you'd need to hook into UAC which I believe only happens automatically for programs marked to run as administrator, elevating privileges for an existing process might require an API call assuming it's possible. – millimoose Aug 21 '13 at 11:38
  • How it can be done with win32 api ? – user180894 Aug 21 '13 at 11:45
  • Start here: http://social.msdn.microsoft.com/search/en-US?query=uac&refinement=117 and search for how to do the stuff you find programatically. – millimoose Aug 21 '13 at 11:46
  • ([`runas` might work](http://stackoverflow.com/a/133500/41655).) – millimoose Aug 21 '13 at 11:52
  • 1
    Also note that you could (outside of python), do runas to start a cmd shell as adminstrator [e.g. start->run->accessories-> right click cmd and select run as) and then start python from there, depending on how you're invoking your script) – Foon Aug 21 '13 at 11:53
  • Thank you, Foon option worked – user180894 Aug 21 '13 at 11:59

0 Answers0