Jump to content
Sign in to follow this  
HendrikWitbooi

Remote Power Management Program with GUI, need some help

Recommended Posts

HendrikWitbooi

Hi there,
 
I am very new to AutoIt and have only used it thus far to make a few simple file management scripts to make life a little easier.
 
I have also made a series of .bat files to Wake on Lan, Shutdown, restart and put to sleep the various computers on my home network. I would love to have a GUI to launch these scripts, or even better run the command themselves.
 
Here is what I have so far:
 
This is how I envision it working;
 
RPMProgram.jpg
 
This would be the initial Screen;
 

Initial_Screen.jpg
 
After selecting a Power down option, you would reach this screen;
 

Power_Down_Selection_Screen.jpg
 
Or after selecting Wake on Lan you would get this;
 
Wo_LSelection_Screen.jpg


 
 
Then if possible, I would like it to display a dialog confirming the selection with an, Ok Cancel and then run the command directly or the .bat file I have already made.
 
Here are the codes. I have 1 for each screen which I modified from something I found here on the forums. I can't remember where, so I am unable to thank the member, but thank you  :)
 
I need help tying all 3 codes together into a single script and have it run the correct command depending on selection.

Initial Screen

#include <GUIConstantsEx.au3>

Example()

Func Example()
Local $radio1, $radio2, $radio3, $radio4, $Cancel_Btn, $Next_Btn, $msg
GUICreate("Remote Power Management")
GUICtrlCreateLabel("What would you like to do?", 10, 10, 270, 40)
$radio1 = GUICtrlCreateRadio("Wake a System using Wake on Lan", 10, 40, 200, 20)
    GUICtrlCreateLabel("WARNING, THE FOLLOWING OPTIONS CAN AFFECT", 50, 90, 320, 40)
    GUICtrlCreateLabel("OR DISCONNECT LOCAL OR REMOTE USERS", 65, 110, 320, 40)
$radio2 = GUICtrlCreateRadio("Put a System into a Sleep State (S3) *", 10, 140)
    GUICtrlCreateLabel("* Recommended always to be used instead of a full Shutdown to", 25, 160)
    GUICtrlCreateLabel("preserve Local User data and provide a faster Power Down/Wake cycle", 30, 175)
    GUICtrlCreateLabel("THE NEXT TWO OPTIONS SHOULD ONLY BE", 50, 220)
    GUICtrlCreateLabel("USED FOLLOWING SYSTEM UPDATES", 65, 240)
    $radio3 = GUICtrlCreateRadio("Restart a System", 10, 260, 120, 20)
    $radio4 = GUICtrlCreateRadio("Shutdown a System", 10, 290, 120, 20)
GUICtrlSetState($radio1, $GUI_CHECKED)
    $Cancel_Btn = GUICtrlCreateButton("Cancel", 75, 350, 70, 25)
    $Next_Btn = GUICtrlCreateButton("Next >", 250, 350, 70, 25)

GUISetState() ; will display an dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
MsgBox(64, 'Info:', 'You clicked the Radio 1 and it is Checked.')
Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED
MsgBox(64, 'Info:', 'You clicked on Radio 2 and it is Checked.')
EndSelect
WEnd
EndFunc ;==>Example

Power Down Screen

#include <GUIConstantsEx.au3>

Example()

Func Example()
Local $radio5, $radio6, $radio7, $radio8, $msg
GUICreate("Remote Power Managment") ; will create a dialog box that when displayed is centered
GUICtrlCreateLabel("Please Select a System to Manage:", 10, 10)
$radio5 = GUICtrlCreateRadio("SERVER - Webserver (192.168.0.10) *", 10, 40, 200, 20)
    GUICtrlCreateLabel("* WARNING - This system is hosting VPN, SSH and an Apache Web Server.", 10, 70)
    GUICtrlCreateLabel("Ensure there are no active users before continuing.", 50, 90)
$radio6 = GUICtrlCreateRadio("MSERVER - Media Server (192.168.0.11)", 10, 140, 270, 20)
    $radio7 = GUICtrlCreateRadio("WORKSTATION - Desktop Computer (192.168.0.12)", 10, 170, 270, 20)
    $radio8 = GUICtrlCreateRadio("All Systems *", 10, 260, 120, 20)
    GUICtrlCreateLabel("* WARNING - THIS SELECTION WILL AFFECT ALL OF THE ABOVE SYSTEMS", 10, 290)
GUICtrlSetState($radio5, $GUI_CHECKED)
$Back_Btn = GUICtrlCreateButton("< Back", 75, 350, 70, 25)
$Next3_Btn = GUICtrlCreateButton("Next >", 250, 350, 70, 25)

GUISetState() ; will display an dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $radio5 And BitAND(GUICtrlRead($radio5), $GUI_CHECKED) = $GUI_CHECKED
MsgBox(64, 'Info:', 'You clicked the Radio 1 and it is Checked.')
Case $msg = $radio6 And BitAND(GUICtrlRead($radio6), $GUI_CHECKED) = $GUI_CHECKED
MsgBox(64, 'Info:', 'You clicked on Radio 2 and it is Checked.')
EndSelect
WEnd
EndFunc ;==>Example

Wol Selection Screen

#include <GUIConstantsEx.au3>

Example()

Func Example()
Local $radio5, $radio6, $radio7, $radio8, $msg
GUICreate("Remote Power Managment") ; will create a dialog box that when displayed is centered
GUICtrlCreateLabel("Please Select a System to Wake with a Magic Packet:", 10, 10)
$radio5 = GUICtrlCreateRadio("All Systems - Send Packet to all Systems listed", 10, 60, 300, 20)
$radio6 = GUICtrlCreateRadio("SERVER - Webserver (192.168.0.10)", 10, 110, 270, 20)
    $radio7 = GUICtrlCreateRadio("MSERVER - Media Server (192.168.0.11)", 10, 160, 270, 20)
    $radio8 = GUICtrlCreateRadio("WORKSTATION - Desktop Computer (192.168.0.12)", 10, 210, 270, 20)
GUICtrlSetState($radio5, $GUI_CHECKED)
$Back_Btn = GUICtrlCreateButton("< Back", 75, 350, 70, 25)
    $Next3_Btn = GUICtrlCreateButton("Next >", 250, 350, 70, 25)

GUISetState() ; will display an dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $radio5 And BitAND(GUICtrlRead($radio5), $GUI_CHECKED) = $GUI_CHECKED
MsgBox(64, 'Info:', 'You clicked the Radio 1 and it is Checked.')
Case $msg = $radio6 And BitAND(GUICtrlRead($radio6), $GUI_CHECKED) = $GUI_CHECKED
MsgBox(64, 'Info:', 'You clicked on Radio 2 and it is Checked.')
EndSelect
WEnd
EndFunc ;==>Example

And here are examples of the .bat files I use. I have included the ones to shutdown or wake all systems so you have an idea of what command I am trying to run

Standby - all systems

echo off
cd C:\SIS
cls
echo THIS WILL PLACE "SERVER" (192.168.0.10), "MSERVER" (192.168.0.11) AND "WORKSTATION" (192.168.0.12) IN SLEEP STATE (S3)
echo ARE YOU SURE YOU WISH TO CONTINUE?
pause
cls
psexec \\mserver -s -d Rundll32 Powrprof.dll,SetSuspendState
psexec \\server -s -d Rundll32 Powrprof.dll,SetSuspendState
psexec \\workstation -s -d Rundll32 Powrprof.dll,SetSuspendState
pause

WoL - All Systems

echo off
cls
echo This Command will wake "SERVER" (192.168.0.10), "MSERVER"
echo (192.168.0.11) AND "WORKSTATION" (192.168.0.12) From S3 State
pause
cls
echo Sending Packet to "SERVER"
wolcmd 00:1A:4D:7E:1B:94 192.168.0.10 255.255.255.0
echo Packet sent to "SERVER"
echo ....
echo Now sending Packet to "MSERVER"
wolcmd 00:13:72:98:2F:08 192.168.0.11 255.255.255.0
echo Packet sent to "MSERVER"
echo ....
echo Now sending to "WORKSTATION"
wolcmd 00:13:72:97:AE:6B 192.168.0.12 255.255.255.0
echo packets sent, press any key to comtinue,...
pause

I apologise for the very long post, and my great request.

If anybody can help me tie these 3 together and help me run the correct command at the end, or point me in the right direction I would be extremely grateful.

Thank you for taking the time to read..

Hendrik

Share this post


Link to post
Share on other sites
HendrikWitbooi

I have tried to merge two of the 3, the initial screen and WoL screen. At first I had my first bit of progress getting the "Cancel" Button on the initial screen to close the program.

Now I am getting error Func on line 12 has no corresponding EndFunc, but it does...

#include <GUIConstantsEx.au3>

Global $Wol, $Sleep, $Restart, $Shutdown, $AllSystemsWol, $ServerWol, $MserverWol, $WorkstationWol, $AllSystemsSD, $ServerSD, $MServerSD, $WorkstationSD, $AllSystemsSleep, $ServerSleep, $MserverSleep, $WorkstationSleep, $AllSystemsRestart, $ServerRestart, $MserverRestart, $WorkstationRestart, $Cancel_Btn1, $Cancel_Btn2, $Next_Btn1, $Next_Btn2, $Next_Btn3, $Back_Btn1, $Back_Btn2, $Ok_Btn1, $msg

RPM()
Init()
Wol()
Power()

Func RPM()
        
        Func Init()
            Local $Wol, $Sleep, $Restart, $Shutdown, $Cancel_Btn1, $Next_Btn1
            GUICreate("Remote Power Management")
            GUICtrlCreateLabel("What would you like to do?", 10, 10, 270, 40)
            $Wol = GUICtrlCreateRadio("Wake a System using Wake on Lan", 10, 40, 200, 20)
            GUICtrlCreateLabel("WARNING, THE FOLLOWING OPTIONS CAN AFFECT", 50, 90, 320, 40)
            GUICtrlCreateLabel("OR DISCONNECT LOCAL OR REMOTE USERS", 65, 110, 320, 40)
            $Sleep = GUICtrlCreateRadio("Put a System into a Sleep State (S3) *", 10, 140)
            GUICtrlCreateLabel("* Recommended always to be used instead of a full Shutdown to", 25, 160)
            GUICtrlCreateLabel("preserve Local User data and provide a faster Power Down/Wake cycle", 30, 175)
            GUICtrlCreateLabel("THE NEXT TWO OPTIONS SHOULD ONLY BE", 50, 220)
            GUICtrlCreateLabel("USED FOLLOWING SYSTEM UPDATES", 65, 240)
            $Restart = GUICtrlCreateRadio("Restart a System", 10, 260, 120, 20)
            $Shutdown = GUICtrlCreateRadio("Shutdown a System", 10, 290, 120, 20)
            GUICtrlSetState($Wol, $GUI_CHECKED)
            $Cancel_Btn1 = GUICtrlCreateButton("Cancel", 75, 350, 70, 25)
            $Next_Btn1 = GUICtrlCreateButton("Next >", 250, 350, 70, 25)
                
            GUISetState()
    
    
    
            While 1
            
                $msg = GUIGetMsg()
                Select
                    Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
                    Case $msg = $Cancel_Btn1
                        Exitloop
                    Case $msg = $Next_Btn1 And (GUICtrlRead($Wol)
                        Func Wol()
                            Local $AllSystems, $Server, $Mserver, $Workstation, $Back_Btn1, $Next_Btn1, $msg
                            GUICreate("Remote Power Managment") ; will create a dialog box that when displayed is centered
                            GUICtrlCreateLabel("Please Select a System to Wake with a Magic Packet:", 10, 10)
                            $AllSystems = GUICtrlCreateRadio("All Systems - Send Packet to all Systems listed", 10, 60, 300, 20)
                            $Server = GUICtrlCreateRadio("SERVER - Webserver (192.168.0.10)", 10, 110, 270, 20)
                            $Mserver = GUICtrlCreateRadio("MSERVER - Media Server (192.168.0.11)", 10, 160, 270, 20)
                            $Workstation = GUICtrlCreateRadio("WORKSTATION - Desktop Computer (192.168.0.12)", 10, 210, 270, 20)
                            GUICtrlSetState($AllSystems, $GUI_CHECKED)
                            $Back_Btn1 = GUICtrlCreateButton("< Back", 75, 350, 70, 25)
                            $Next_Btn1 = GUICtrlCreateButton("Next >", 250, 350, 70, 25)
                            
                                GUISetState()
                            
                                While 1
                                
                                    Select
                                        Case $msg = $GUI_EVENT_CLOSE
                                            ExitLoop
                                        Case $msg = $Back_Btn1
                                            ExitLoop                
                                        
                                    
                                    EndSelect
                            
                            
                                Wend
                        EndFunc
                EndSelect
        EndFunc
    Wend
EndFunc

Share this post


Link to post
Share on other sites
Jos

You cannot have a Func..EndFunc inside of another Func..EndFunc. Use Tidy that comes with the Full SciTE4AutoIt3 to help you finding these issues.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
HendrikWitbooi

Hi Jos,

Many thanks for reading and getting back to me.

Now you can see how new to this I really am.

Other than this big mistake, am I going about combining the different menu's the right way?

Really appreciate the help...

Share this post


Link to post
Share on other sites
HendrikWitbooi

I have tried adding a separate function for each outcome, but this has unexpected results also

#include <GUIConstantsEx.au3>
MInit()
MWol()
MSleep()
MRestart()
MShutdown()
MAllSystems()
SLServer()
SLMserver()
SLWorkstation()
SLAllSystems()
RServer()
RMserver()
RWorkstation()
RAllSystems()
SDServer()
SDMserver()
SDWorkstation()
SDAllSystems()
WServer()
WMserver()
WWorkstation()
WAllSystems()
Func MInit()
    Local $Wol, $Sleep, $Restart, $Shutdown, $Cancel_Btn, $Next_Btn, $Msg
    GUICreate("Remote Power Management")
    GUICtrlCreateLabel("What would you like to do?", 10, 10, 270, 40)
    $Wol = GUICtrlCreateRadio("Wake a System using Wake on Lan", 10, 40, 200, 20)
    GUICtrlCreateLabel("WARNING, THE FOLLOWING OPTIONS CAN AFFECT", 50, 90, 320, 40)
    GUICtrlCreateLabel("OR DISCONNECT LOCAL OR REMOTE USERS", 65, 110, 320, 40)
    $Sleep = GUICtrlCreateRadio("Put a System into a Sleep State (S3) *", 10, 140)
    GUICtrlCreateLabel("* Recommended always to be used instead of a full Shutdown to", 25, 160)
    GUICtrlCreateLabel("preserve Local User data and provide a faster Power Down/Wake cycle", 30, 175)
    GUICtrlCreateLabel("THE NEXT TWO OPTIONS SHOULD ONLY BE", 50, 220)
    GUICtrlCreateLabel("USED FOLLOWING SYSTEM UPDATES", 65, 240)
    $Restart = GUICtrlCreateRadio("Restart a System", 10, 260, 120, 20)
    $Shutdown = GUICtrlCreateRadio("Shutdown a System", 10, 290, 120, 20)
    GUICtrlSetState($Wol, $GUI_CHECKED)
    $Cancel_Btn = GUICtrlCreateButton("Cancel", 75, 350, 70, 25)
    $Next_Btn = GUICtrlCreateButton("Next >", 250, 350, 70, 25)
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                GUIDelete()
            Case $msg = $Cancel_Btn
                GUIDelete()
            Case $msg =  $Wol And $Next_Btn
                GUIDelete()
                MWol()
            Case $msg = $Sleep And $Next_Btn
                MSleep()
                GUIDelete()
            Case $msg = $Next_Btn And $Restart
                GUIDelete()
                MRestart()
            Case $msg = $Next_Btn And $Shutdown
                GUIDelete()
                MShutdown()
        EndSelect
    WEnd
EndFunc
GUIDelete()
Func MWol()
    Local $AllSystems, $Server, $Mserver, $Workstation, $Back_Btn, $Next_Btn, $msg
    GUICreate("Wake a System")
    GUICtrlCreateLabel("Please Select a System to Wake with a Magic Packet:", 10, 10)
    $AllSystems = GUICtrlCreateRadio("All Systems - Send Packet to all Systems listed", 10, 60, 300, 20)
    $Server = GUICtrlCreateRadio("SERVER - Webserver (192.168.0.10)", 10, 110, 270, 20)
    $Mserver = GUICtrlCreateRadio("MSERVER - Media Server (192.168.0.11)", 10, 160, 270, 20)
    $Workstation = GUICtrlCreateRadio("WORKSTATION - Desktop Computer (192.168.0.12)", 10, 210, 270, 20)
    GUICtrlSetState($AllSystems, $GUI_CHECKED)
    $Back_Btn = GUICtrlCreateButton("< Back", 75, 350, 70, 25)
    $Next_Btn = GUICtrlCreateButton("Next >", 250, 350, 70, 25)
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                GUIDelete()
            Case $msg = $Back_Btn
                GUIDelete()
                MInit()
            Case $msg = $Next_Btn And $AllSystems
                GUIDelete()
                WAllSystems()
            Case $msg = $Next_Btn And $Server
                GUIDelete()
                WServer()
            Case $msg = $Next_Btn And $Mserver
                GUIDelete()
                WMserver()
            Case $msg = $Next_Btn And $Workstation
                GUIDelete()
                WWorkstation()             
        EndSelect
    WEnd
EndFunc
GUIDelete()
Func MSleep()
    Local $Server, $Mserver, $Workstation, $Allsystems, $Back_Btn, $Next_Btn, $None, $msg
    GUICreate("Remote Power Managment") ; will create a dialog box that when displayed is centered
    GUICtrlCreateLabel("Please Select a System to Manage:", 10, 10)
    $Server = GUICtrlCreateRadio("SERVER - Webserver (192.168.0.10) *", 10, 40, 200, 20)
    GUICtrlCreateLabel("* WARNING - This system is hosting VPN, SSH and an Apache Web Server.", 10, 70)
    GUICtrlCreateLabel("Ensure there are no active users before continuing.", 50, 90)
    $Mserver = GUICtrlCreateRadio("MSERVER - Media Server (192.168.0.11)", 10, 140, 270, 20)
    $Workstation = GUICtrlCreateRadio("WORKSTATION - Desktop Computer (192.168.0.12)", 10, 170, 270, 20)
    $Allsystems = GUICtrlCreateRadio("All Systems *", 10, 220, 120, 20)
    GUICtrlCreateLabel("* WARNING - THIS SELECTION WILL AFFECT ALL OF THE ABOVE SYSTEMS", 10, 250)
    $None = GUICtrlCreateRadio("None", 10, 290, 120, 20)
    GUICtrlSetState($None, $GUI_CHECKED)
    $Back_Btn = GUICtrlCreateButton("< Back", 75, 350, 70, 25)
    $Next_Btn = GUICtrlCreateButton("Next >", 250, 350, 70, 25)
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Back_Btn
                GUIDelete()
                MInit()
            Case $msg = $Next_Btn And $None
                MsgBox(64, 'Info:', 'You Need to make a selection to continue...')
        EndSelect
    WEnd
EndFunc
Edited by HendrikWitbooi

Share this post


Link to post
Share on other sites
HendrikWitbooi

Can anybody please help me a little with this?

I have the codes for the 3 dummy windows.

After Advice from Jos (thanks a million :)) I learnt that I could not have a function within another, so decided to add them one after another, with a different function for each outcome,  this also doesn't work,

As English isn't my first language I find it very difficult to think of correct search terms that are appropriate and relate to my problem.

Please help me, with guidance or advice, even links that will help me. I just want to join these sceens together and have it function like the sketch in my first post.

I would be most grateful for any help at all

Regards,

Hendrik 

Edited by HendrikWitbooi

Share this post


Link to post
Share on other sites
NewPlaza

Here is a VERY crude way of doing it.. It may be a little sloppy but it should work for the most part. (NOT TESTED THOUGH)

#include <GUIConstantsEx.au3>


Local $radio1, $radio2, $radio3, $radio4, $radio5, $radio6, $radio7, $radio8, $radio9, $radio10, $radio11, $radio12
Local $Next_Btn, $Next2_Btn, $Next3_Btn, $Back_Btn, $Back2_Btn, $Cancel_Btn, $msg





Local $RemotePowerManagement = GUICreate("Remote Power Management")
GUICtrlCreateLabel("What would you like to do?", 10, 10, 270, 40)
$radio1 = GUICtrlCreateRadio("Wake a System using Wake on Lan", 10, 40, 200, 20)
GUICtrlCreateLabel("WARNING, THE FOLLOWING OPTIONS CAN AFFECT", 50, 90, 320, 40)
GUICtrlCreateLabel("OR DISCONNECT LOCAL OR REMOTE USERS", 65, 110, 320, 40)
$radio2 = GUICtrlCreateRadio("Put a System into a Sleep State (S3) *", 10, 140)
GUICtrlCreateLabel("* Recommended always to be used instead of a full Shutdown to", 25, 160)
GUICtrlCreateLabel("preserve Local User data and provide a faster Power Down/Wake cycle", 30, 175)
GUICtrlCreateLabel("THE NEXT TWO OPTIONS SHOULD ONLY BE", 50, 220)
GUICtrlCreateLabel("USED FOLLOWING SYSTEM UPDATES", 65, 240)
$radio3 = GUICtrlCreateRadio("Restart a System", 10, 260, 120, 20)
$radio4 = GUICtrlCreateRadio("Shutdown a System", 10, 290, 120, 20)
GUICtrlSetState($radio1, $GUI_CHECKED)
$Cancel_Btn = GUICtrlCreateButton("Cancel", 75, 350, 70, 25)
$Next_Btn = GUICtrlCreateButton("Next >", 250, 350, 70, 25)





Local $WOLSelectionScreen = GUICreate("Remote Power Managment - WOL Selection Screen") ; will create a dialog box that when displayed is centered
GUICtrlCreateLabel("Please Select a System to Wake with a Magic Packet:", 10, 10)
$radio5 = GUICtrlCreateRadio("All Systems - Send Packet to all Systems listed", 10, 60, 300, 20)
$radio6 = GUICtrlCreateRadio("SERVER - Webserver (192.168.0.10)", 10, 110, 270, 20)
$radio7 = GUICtrlCreateRadio("MSERVER - Media Server (192.168.0.11)", 10, 160, 270, 20)
$radio8 = GUICtrlCreateRadio("WORKSTATION - Desktop Computer (192.168.0.12)", 10, 210, 270, 20)
GUICtrlSetState($radio5, $GUI_CHECKED)
$Back_Btn = GUICtrlCreateButton("< Back", 75, 350, 70, 25)
$Next2_Btn = GUICtrlCreateButton("Next >", 250, 350, 70, 25)






Local $PowerDownScreen = GUICreate("Remote Power Managment - Power Down Screen") ; will create a dialog box that when displayed is centered
GUICtrlCreateLabel("Please Select a System to Manage:", 10, 10)
$radio9 = GUICtrlCreateRadio("SERVER - Webserver (192.168.0.10) *", 10, 40, 200, 20)
GUICtrlCreateLabel("* WARNING - This system is hosting VPN, SSH and an Apache Web Server.", 10, 70)
GUICtrlCreateLabel("Ensure there are no active users before continuing.", 50, 90)
$radio10 = GUICtrlCreateRadio("MSERVER - Media Server (192.168.0.11)", 10, 140, 270, 20)
$radio11 = GUICtrlCreateRadio("WORKSTATION - Desktop Computer (192.168.0.12)", 10, 170, 270, 20)
$radio12 = GUICtrlCreateRadio("All Systems *", 10, 260, 120, 20)
GUICtrlCreateLabel("* WARNING - THIS SELECTION WILL AFFECT ALL OF THE ABOVE SYSTEMS", 10, 290)
GUICtrlSetState($radio9, $GUI_CHECKED)
$Back2_Btn = GUICtrlCreateButton("< Back", 75, 350, 70, 25)
$Next3_Btn = GUICtrlCreateButton("Next >", 250, 350, 70, 25)



GUISetState(@SW_SHOW, $RemotePowerManagement)





; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select

        Case $msg = $Cancel_Btn
            ExitLoop

        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop

        Case $msg = $Next_Btn
            If BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED Then
                GUISetState(@SW_HIDE, $RemotePowerManagement)
                GUISetState(@SW_SHOW, $WOLSelectionScreen)
            EndIf
            If BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED Then
                GUISetState(@SW_HIDE, $RemotePowerManagement)
                GUISetState(@SW_SHOW, $PowerDownScreen)
            EndIf

        Case $msg = $Next2_Btn
            GUISetState(@SW_HIDE, $WOLSelectionScreen)
            Local $Confirm = MsgBox(4 + 32 + 0 + 0 + 262144, "Are you sure?", "All the information you need are in the variables $radio5-$radio8")
            If $Confirm = 6 Then
                Local $fWOLSelectionScreen = @ScriptDir & "\WOLAll.cmd"
                FileWriteLine($fWOLSelectionScreen, "echo off")
                FileWriteLine($fWOLSelectionScreen, "cls")
                FileWriteLine($fWOLSelectionScreen, "echo This Command will wake 'SERVER' (192.168.0.10), 'MSERVER'")
                FileWriteLine($fWOLSelectionScreen, "echo (192.168.0.11) AND 'WORKSTATION' (192.168.0.12) From S3 State")
                FileWriteLine($fWOLSelectionScreen, "pause")
                FileWriteLine($fWOLSelectionScreen, "cls")
                FileWriteLine($fWOLSelectionScreen, "echo Sending Packet to 'SERVER'")
                FileWriteLine($fWOLSelectionScreen, "wolcmd 00:1A:4D:7E:1B:94 192.168.0.10 255.255.255.0")
                FileWriteLine($fWOLSelectionScreen, "echo Packet sent to 'SERVER'")
                FileWriteLine($fWOLSelectionScreen, "echo ....")
                FileWriteLine($fWOLSelectionScreen, "echo Now sending Packet to 'MSERVER'")
                FileWriteLine($fWOLSelectionScreen, "wolcmd 00:13:72:98:2F:08 192.168.0.11 255.255.255.0")
                FileWriteLine($fWOLSelectionScreen, "echo Packet sent to 'MSERVER'")
                FileWriteLine($fWOLSelectionScreen, "echo ....")
                FileWriteLine($fWOLSelectionScreen, "echo Now sending to 'WORKSTATION'")
                FileWriteLine($fWOLSelectionScreen, "wolcmd 00:13:72:97:AE:6B 192.168.0.12 255.255.255.0")
                FileWriteLine($fWOLSelectionScreen, "echo packets sent, press any key to comtinue,...")
                FileWriteLine($fWOLSelectionScreen, "pause")
                RunWait(@ComSpec & " /c " & $fWOLSelectionScreen)
            EndIf
            GUISetState(@SW_SHOW, $RemotePowerManagement)

        Case $msg = $Back_Btn
            GUISetState(@SW_HIDE, $WOLSelectionScreen)
            GUISetState(@SW_SHOW, $RemotePowerManagement)

        Case $msg = $Next3_Btn
            GUISetState(@SW_HIDE, $PowerDownScreen)
            Local $Confirm = MsgBox(4 + 32 + 0 + 0 + 262144, "Are you sure?", "All the information you need are in the variables $radio9-$radio12")
            If $Confirm = 6 Then
                Local $fPowerDownScreen = @ScriptDir & "\WOLAll.cmd"
                FileWriteLine($fPowerDownScreen, "echo off")
                FileWriteLine($fPowerDownScreen, "cd C:\SIS")
                FileWriteLine($fPowerDownScreen, "cls")
                FileWriteLine($fPowerDownScreen, "echo THIS WILL PLACE 'SERVER' (192.168.0.10), 'MSERVER' (192.168.0.11) AND 'WORKSTATION' (192.168.0.12) IN SLEEP STATE (S3)")
                FileWriteLine($fPowerDownScreen, "echo ARE YOU SURE YOU WISH TO CONTINUE?")
                FileWriteLine($fPowerDownScreen, "pause")
                FileWriteLine($fPowerDownScreen, "cls")
                FileWriteLine($fPowerDownScreen, "psexec \\mserver -s -d Rundll32 Powrprof.dll,SetSuspendState")
                FileWriteLine($fPowerDownScreen, "psexec \\server -s -d Rundll32 Powrprof.dll,SetSuspendState")
                FileWriteLine($fPowerDownScreen, "psexec \\workstation -s -d Rundll32 Powrprof.dll,SetSuspendState")
                FileWriteLine($fPowerDownScreen, "pause")
                RunWait(@ComSpec & " /c " & $fPowerDownScreen)
            EndIf
            GUISetState(@SW_SHOW, $RemotePowerManagement)

        Case $msg = $Back2_Btn
            GUISetState(@SW_HIDE, $PowerDownScreen)
            GUISetState(@SW_SHOW, $RemotePowerManagement)

    EndSelect
WEnd

Good Luck!

Share this post


Link to post
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
Sign in to follow this  

×