Jump to content

TURN ON AND/OR TURN OFF COMPUTER


Recommended Posts

I have been searching. I have a string of au3 files that run one after the other via a bat file.

I would like to add an au3 file that turns on my computer as the first step in the bat file. And, I would like to add an au3 file to the end of this bat file that turns off my computer.

Does anyone have an au3 file that does either of these?

Can either of these (turn on PC or turn off PC) be done with AutoIt?

Thanks for the help!!

...

Link to comment
Share on other sites

I don't think I was clear either. If your computer is off, you can't run any batch scripts on it - because it's off.

Now, are you saying that you want to turn it on from another computer? That's only possible IF the other computer is on the same network subnet, AND your computer's network card supports Wake On Lan.

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

To turn off the computer try:

Run(@ComSpec & " /c shutdown -t now", "", @SW_HIDE)

Like lod3n said, kinda hard to write a script to turn your computer on when the computer isn't already on to run the script. I beleive theres a program called Magic Packet or something like that I used back in my second semester of college to do Wake-on-LAN. You should look that up.

Link to comment
Share on other sites

Just push the power button - no programming or script needed :P

2¢

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Joking aside, some computers do allow you to schedule a power on. Check your computer's BIOS to see if you can. When it's turning on, look for instructions - probably a key press - to get into the config/setup. (Be REALLY careful in there.)

If so, you can then run your scripts from your Startup folder.

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

Hello :P

To turn on your computer, you have two ways :

- fisrt one : the BIOS of your motherboard (press F2 or DEL during boot sequence to access) to program a wake up according to date & time (example : wake up my computer each day at 3 PM) or according to an event on your network card :

-second one : the WOL (Wake On LAN). You must have a network card supporting WOL and your BIOS configured to wake up if the card receive an event (a WOL message is named a "magic packet")

Then you need a program to send this magic packet from an other computer. I recommend WOL command line software from DEPICUS : http://www.depicus.com/wake-on-lan/

it works :nuke:

Link to comment
Share on other sites

  • 3 weeks later...

This func is missing from autoit

WakeUpAfteranHibernate()

It is ready in Visual Basic:

You can make an exe in Visual Basic that makes your pc wake up after hibernate

Wake up after hibernate code

ms

Autoit.es - Foro Autoit en Español Word visitors Image Clustrmap image: - Football Spanish team - Spanish team: Casillas, Iniesta, Villa, Xavi, Puyol, Campdevilla, etc..Programando en Autoit+Html - Coding Autoit-Html - Arranca programas desde Internet - Preprocesador de Autoit a http
Link to comment
Share on other sites

It cant....thats why basically everyones making ratorical questions and making fun of him :P

-----------Current Programming Language Status:Beginner: J#, Ruby Intermediate: Autoit, Java, C#, C++Advanced: Basic, Visual Basic, Fortran

Link to comment
Share on other sites

Hello :P

To turn on your computer, you have two ways :

- fisrt one : the BIOS of your motherboard (press F2 or DEL during boot sequence to access) to program a wake up according to date & time (example : wake up my computer each day at 3 PM) or according to an event on your network card :

-second one : the WOL (Wake On LAN). You must have a network card supporting WOL and your BIOS configured to wake up if the card receive an event (a WOL message is named a "magic packet")

Then you need a program to send this magic packet from an other computer. I recommend WOL command line software from DEPICUS : http://www.depicus.com/wake-on-lan/

it works :nuke:

A third way would be for some basic electronics to drive a relay connected to the motherboard where the power on switch connects to, (its only a momentry contact) from another computer, you can use the printer port for this.

See this thread http://www.autoitscript.com/forum/index.php?showtopic=31708

Way easier to use WOL though... :)

Edited by Lakes

2015 - Still no flying cars, instead blankets with sleeves.

Link to comment
Share on other sites

:P Hello I found this in this forum:

[autoit]

;===============================================================================

;

; Description: Sets a wakeup time to wake it up if the system / computer is hibernating or standby

; Parameter(s): $Hour - Hour Values : 0-23

; $Minute - Minutes Values: 0-59

; $Day - Days Values : 1-31 (optional)

; $Month - Month Values : 1-12 (optional)

; $Year - Year Values : > 0 (optional)

;

; Requirement(s): DllCall

; Return Value(s): On Success - 1

; On Failure - 0 sets @ERROR = 1 and @EXTENDED (Windows API error code)

;

; Error code(s): http://msdn.microsoft.com/library/default....error_codes.asp

;

; Author(s): Bastel123 aka Sebastian

; Note(s): -

;

;===============================================================================

func SetWakeUpTime($Hour,$Minute,$Day=@mday,$Month=@mon,$Year=@YEAR)

$SYSTEMTIME = DllStructCreate("ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort")

$lpSYSTEMTIME = DllStructGetPtr($SYSTEMTIME)

$LOCALFILETIME=DllStructCreate("dword;dword")

$lpLOCALFILETIME = DllStructGetPtr($LOCALFILETIME)

$DueTime=DllStructCreate("dword;dword")

$lpDueTime=DllStructGetPtr($DueTime)

DllStructSetData($SYSTEMTIME, 1, $Year)

DllStructSetData($SYSTEMTIME, 2, $Month)

DllStructSetData($SYSTEMTIME, 3, _DateToDayOfWeek($Year,$Month,$Day)-1)

DllStructSetData($SYSTEMTIME, 4, $Day)

DllStructSetData($SYSTEMTIME, 5, $Hour)

DllStructSetData($SYSTEMTIME, 6, $Minute)

DllStructSetData($SYSTEMTIME, 7, 0)

DllStructSetData($SYSTEMTIME, 8, 0)

$result = DllCall("kernel32.dll", "long", "SystemTimeToFileTime", "ptr", $lpSystemTime, "ptr", $lpLocalFileTime)

If $result[0] = 0 Then

Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")

SetExtended($lastError[0])

SetError(1)

Return 0

EndIf

$result = DllCall("kernel32.dll", "long", "LocalFileTimeToFileTime", "ptr", $lpLocalFileTime, "ptr", $lpLocalFileTime)

If $result[0] = 0 Then

Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")

SetExtended($lastError[0])

SetError(1)

Return 0

EndIf

$result = DllCall("kernel32.dll", "long", "CreateWaitableTimer", "long", 0, "long", True, "str", "")

If $result[0] = 0 Then

Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")

SetExtended($lastError[0])

SetError(1)

Return 0

EndIf

DllCall("kernel32.dll", "none", "CancelWaitableTimer", "long",$result[0])

DllStructSetData($DueTime, 1, DllStructGetData($LocalFILETIME, 1))

DllStructSetData($DueTime, 2, DllStructGetData($LocalFILETIME, 2))

$result = DllCall("kernel32.dll", "long", "SetWaitableTimer", "long",$result[0], "ptr", $lpDueTime, "long", 1000, "long", 0, "long", 0, "long", true)

If $result[0] = 0 Then

Local $lastError = DllCall("kernel32.dll", "int", "GetLastError")

SetExtended($lastError[0])

SetError(1)

Return 0

EndIf

return 1

EndFunc

;===============================================================================

;

; Description: Set the computer in Hibernate or Standby Status

; Parameter(s): $Mode - Suspend mode : True=Hibernate, False=Suspend

; $Force - Force-Mode : True=the system suspends operation immediately

; False=FALSE, the system broadcasts a PBT_APMQUERYSUSPEND event to each application to request permission to suspend operation

;

; Requirement(s): DllCall

;

; Author(s): Bastel123 aka Sebastian

; Note(s): If the system does not support hibernate use the standby mode -

;

;===============================================================================

Func SetSuspend($mode=False,$force=true)

$result = DllCall("PowrProf.dll", "long", "SetSuspendState", "long",$mode, "long",$force, "long", false)

EndFunc

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...