Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


Aaroona

3204 posts

Uber Geek
+1 received by user: 169


#309349 10-Oct-2023 23:33
Send private message

I am trying to set up a iOS Shortcut to hibernate a windows machine via SSH for windows, however I am having a bit of trouble getting the sequencing right. 

 

 

 

The Hibernate command for windows I am using is "%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState Hibernate" - this works fine, but the issue is it doesnt provide a response back to say it has successfully run, nor does it give enough time for the SSH session to disconnect gracefully, therefore it causes the iOS Shortcut to hang while running.

 

I used to solve this by using Pulseway, but they have since turned to rubbish the last year+ and the iOS automation options haven't worked since. They keep promising to fix them, but haven't done it.

 

 

 

Is there a better way to run this? Or a different command I can run that returns a response that I'm not aware of? 

 

I was thinking maybe delay/powershell job might be the best option, which gives the SSH session enough time to execute the task then exit the shell.


Create new topic
fe31nz
1294 posts

Uber Geek
+1 received by user: 423


  #3145141 11-Oct-2023 01:03
Send private message

The usual command used to shut down or hibernate is "shutdown".  The /h option is for hibernate, and it also has options to do a timeout before acting (/t).  If that is not sufficient, then you would need to write a script and run that remotely.  It is possible to run a script as a separate task so it is not affected by the ssh connection being disconnected.




nzkc
1634 posts

Uber Geek
+1 received by user: 1041


  #3145142 11-Oct-2023 01:03
Send private message

I'd be inclined to create a windows scheduled job (to run on demand with no schedule) that does the hibernate and have your ssh command call Start-Job to run it: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/start-job?view=powershell-7.3

I'd have the job delay for a bit so you have time for your SSH script to exit gracefully.


Aaroona

3204 posts

Uber Geek
+1 received by user: 169


  #3145506 11-Oct-2023 21:27
Send private message

Thanks for the suggestions. I did a bit of a mash up of the scheduled task option in the end.

 

I set up a scheduled task to run the hibernate command directly, no delays. I then run schtasks.exe /run /tn HibernateComputer and I get a successful message back for executing the task. This is enough to allow the SSH session from windows to close off, and is sufficient enough to give me confidence the computer will hibernate.

 

 

 

 

 

 

 

 

 

I had tried the shutdown.exe /t option, but /t is not valid with /h, only with reboots or shutdowns.


Create new topic








Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.