Announcement

Collapse
No announcement yet.

Restart operations

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Restart operations

    You can use below script to restart machine,


    Code:
    import subprocess;
    sysdown=subprocess.Popen(('shutdown /r '),shell=True,stdout=subprocess.PIPE);
    for line in iter(sysdown.stdout.readline,''):
        print line.rstrip();



    Note: please refer attach text file for script text without indentation error.


    No STDOUT text for this script. You need to check success or failed status .


    Options:

    use 'shutdown /s' to shutdown
    use 'shutdown /l' to logoff



    Attached Files
    Last edited by mkannan; 09-12-2016, 01:33 PM.

  • #2
    mkannan,

    Thanks for the scripts.
    For this one particularly, I was testing it out and I can't seem to get the 'shudown /l' option to work.
    As you instructed, simply replace the /r in the original script to change to /s for shutdown and /l for logoff.
    I managed to get /s for shutdown to work but not /l.
    The error that it gives you is:
    Incorrect function.(1)
    I'm not too sure what is wrong but I thought I should let you know.

    Thanks.

    Comment


    • #3
      Hi Ming

      Please try below script to log off

      Code:
      import os
      os.popen('shutdown -l')

      Comment

      Working...
      X