AUTO RESTART

  1. 3 months ago

    Pathma M

    May 19 Pre-Release Testers, Xojo Pro

    Hi,
    Can u please advice how to restart my computer using Xojo at particular time (Linux and Windows).
    Kindly help me from this.

  2. Jean-Yves P

    May 19 Pre-Release Testers, Xojo Pro Europe (France, Besancon)

    use the shell class
    with it launch the command line specific to your system to restart the computer.
    use the timer class to launch the shell at the time you want.

  3. Pathma M

    May 19 Pre-Release Testers, Xojo Pro

    Thanks Jean-Yves Pochez..

    Dim s As Shell
    s = New Shell
    s.Execute("sudo reboot")

    Am using above code.. But it doesn't work.

  4. Richard D

    May 19 Pre-Release Testers Europe (UK, London)

    what about this command ??

    sudo shutdown -r now

    but seem like you will be ask for password. Can we include password in the command line

    sudo shutdown -r now pwd:abc

  5. Michel B

    May 19 Pre-Release Testers, Xojo Pro
    Edited 3 months ago by Michel B

    Sudo will not work because you cannot have the authorization level from a shell.

    IMHO this is a bad idea. But it is your karma ...

    Why on earth would you want to restart the user computer ? Any application doing that I would throw to the trash immediately. The user may have valuable tasks running you don't know about, maybe backing up the hard drive or something that should not be interrupted.

    Why not instead tell the user that modifications will not be complete before a restart, and let him decide when to do it ?

  6. Richard D

    May 19 Pre-Release Testers Europe (UK, London)

    yea.. michel... that is a much better way. inform the user and let him decide.

  7. Pathma M

    May 19 Pre-Release Testers, Xojo Pro

    @Richard D what about this command ??

    sudo shutdown -r now

    but seem like you will be ask for password. Can we include password in the command line

    sudo shutdown -r now pwd:abc

    This one also doesn't work..

  8. Pathma M

    May 19 Pre-Release Testers, Xojo Pro

    @Michel B Sudo will not work because you cannot have the authorization level from a shell.

    IMHO this is a bad idea. But it is your karma ...

    Why on earth would you want to restart the user computer ? Any application doing that I would throw to the trash immediately. The user may have valuable tasks running you don't know about, maybe backing up the hard drive or something that should not be interrupted.

    Why not instead tell the user that modifications will not be complete before a restart, and let him decide when to do it ?

    Actually my application monitor the some other process.. So if the process doesn't run properly i want to restart my computer.
    Thats y am looking for the solution for this.

  9. Michel B

    May 19 Pre-Release Testers, Xojo Pro

    None of the Sudo stuff will ever work this way, since shell cannot prompt for the password.

  10. Christoph D

    May 19 Pre-Release Testers, Xojo Pro

    You can omit the sudo part. It will work fine.

  11. Deleted 3 months ago by Beatrix W
  12. Jean-Yves P

    May 19 Pre-Release Testers, Xojo Pro Europe (France, Besancon)

    @Christoph Dnbsp;Vocht You can omit the sudo part. It will work fine.

    on macos the sudo is not necessary
    but on linux ? and windows ?

  13. Jean-Yves P

    May 19 Pre-Release Testers, Xojo Pro Europe (France, Besancon)

    don't know where I found this, but certainly on this forum or old realbasic.
    you can pass argument to a shell

     
    //make a constant (string) named passShell  
    
    PW="$(osascript -e 'tell application "System Events" to display dialog "Password:" default answer "" with hidden answer' -e 'text returned of result' 2>/dev/null)" 
    
    call it:  
    
      dim mshell as new shell
      mshell.Execute passShell
      mshell.Execute "echo ""$PW"" | sudo -S /usr/bin/true"
      mshell.Execute "echo ""$PW"" | sudo -S  //your next shell command
      mshell.Execute "exit"
         
  14. Michel B

    May 19 Pre-Release Testers, Xojo Pro
    Edited 3 months ago by Michel B

    @Jean-YvesPochez on macos the sudo is not necessary
    but on linux ? and windows ?

    Linux most certainly demands it.

    Windows uses quite different commands, so what works for Mac and Linux won't work there.

  15. John J

    May 19 Pre-Release Testers, Xojo Pro Cleveland, Ohio

    On linux and mac you can edit the "sudoers" file to change the permissions on sudo to include not requiring a password for certain users/groups and even for certain commands.

    type "sudo visudo" - edit the options (with care).

or Sign Up to reply!