Reputation: 311
I will provide a video to show you as well what is going on, here is the link to the video displaying this strange issue:
https://www.youtube.com/watch?v=o9RUR7t18NA&list=UU0OG8tltECja7Sgxa9A5Drg
The source code is uploaded to pastebin which you can find on the youtube channel but is not really relevant since it is really only the "shutdown" function that is going crazy.
I'd like to address this strange issue or bug.
To narrow things down here is some information: I am using Windows 7 32bit version and am running Python 3.4 also 32bit version.
import os
os.system("shutdown -s -t 60")
The code here is simple and should work, now get this:
If I run this code in the standard Python GUI, it works as intended. However if I run this very same code in IDLE all it does is open up the Command Prompt (cmd) and creates a infinite loop, my only option being to press enter.
Another interesting thing to note is when I try to close this command prompt, the command prompt prints something like this out:
^C ^C ^C ^C ^C ^C
and at times this:
^^^^^^^^^^^^^^^^^^^^C
Is this known? Is there a work around? I need to be able to access this function and it needs to work for my project (A simple shutdown program where the user can input time and in that given time the computer will log off, shutdown etc).
Upvotes: 0
Views: 361
Reputation: 56180
os.system("C:\Windows\System32\shutdown.exe -s -t 60")
should do. (explicitely run the shutdown.exe
from Windows System folder)
Upvotes: 0
Reputation: 38667
Solution by OP.
My program was called "shutdown", and it seems that the os.system("shutdown -s - t 60")
Actually REOPENED the program, rather then executing the shutdown command.
The solution was to rename the program to something else.
Upvotes: 1