Jump to content

AutoIT script with parameters, different kinds


Recommended Posts

Hi, I could need some help urgently :-( It seems that I am trying  something that can't be done? First to start an Synology NAS with a WOL command using wake.exe - working as a Batch! Parameters are a Problem and what I have seen in the web/Forum all efforts were not succesful. Could be complicated or me dumb ;-) Ok, second thing is to shutdown the NAS again - works as a Batch (plink.exe), too. But, for shutdown you have to use root and root password via SSH - again, parameters and even more complicated. Thought of using AutoIT because you can compile it and the user won't know pw - any ideas for using in AutoIT? ;-)

Wake NAS:

Got first part by workaround (instead of .bat .cmd now, left the .cmd in Win sys32-folder; no valuable data there):

#include <GuiConstants.au3>
GuiCreate("NAS_Control", 200, 460,-1, -1)
$Radio_1 = GuiCtrlCreateRadio("Start NAS", 20, 40, 150, 20)
$Radio_2 = GuiCtrlCreateRadio("Shutdown", 20, 80, 150, 20)

GuiSetState()
While 1
    $msg = GuiGetMsg()
 Select
 Case $msg = $GUI_EVENT_CLOSE
  ExitLoop
 case $msg = $Radio_1
  MsgBox (0,"Checked", "Start NAS")
  RunWait(@ComSpec & " /c " & "c:\Windows\System32\WakeNAS.cmd")
      exitloop

WORKS ;-)

BUT...

case $msg = $Radio_2
  MsgBox (0,"Checked", "Shutdown")
  RunWait(@ComSpec & " /c " & '"c:\Windows\System32\plink" -ssh -pw -password user@192.168.xxx.yy -m"')
  Execute ("shutdown -h now")
  exitloop

won't do, neither:

ShellExecute("c:\Windows\System32\plink.exe" -ssh ("192.168.xxx.yy" -m) ("user") -pw ("password"))

Don't get the Syntax, read for two days now, tried every Version I found in web...nothing! ANY SUGGESTIONS,PLEASE?

Edited by winterknights
changes
Link to comment
Share on other sites

On ‎25‎.‎03‎.‎2016 at 3:11 PM, winterknights said:

Hi, I could need some help urgently :-( It seems that I am trying  something that can't be done? First to start an Synology NAS with a WOL command using wake.exe - working as a Batch! Parameters are a Problem and what I have seen in the web/Forum all efforts were not succesful. Could be complicated or me dumb ;-) Ok, second thing is to shutdown the NAS again - works as a Batch (plink.exe), too. But, for shutdown you have to use root and root password via SSH - again, parameters and even more complicated. Thought of using AutoIT because you can compile it and the user won't know pw - any ideas for using in AutoIT? ;-)

Wake NAS:

@echo off
%systemroot%\\System32\\wake.exe 00-00-00-00-00-00 192.168.123.255
echo Programm ausgeführt!
pause

Shutdown:

plink -ssh -pw "xxxxxx" root@192.168.123.xx -m command.bat

shutdown -h now

This is what I was looking for:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$var = Ping("DiskStation",250)
If $var Then
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Netzwerkcheck", 507, 248, 402, 14)
GUISetBkColor(0x008000)
$Label1 = GUICtrlCreateLabel("Das Gerät ist im Netz!", 108, 8, 290, 25, $SS_CENTER)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFFE1)
$Pic1 = GUICtrlCreatePic("index.jpg", 84, 48, 338, 149)
$Label2 = GUICtrlCreateLabel("Netzlaufwerk einsatzbereit", 29, 208, 449, 24, $SS_CENTER)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetBkColor(-1, 0xFFFFE1)
$Radio_1 = GuiCtrlCreateRadio("Shutdown", 20, 40, 80, 20)
$Radio_2 = GuiCtrlCreateRadio("Close", 20, 80, 80, 20)
GuiSetState()
While 1
    $msg = GuiGetMsg()
 Select
 Case $msg = $GUI_EVENT_CLOSE
  ExitLoop
 case $msg = $Radio_1
  MsgBox (0,"Checked", "Shutdown NAS")
  Run(@ComSpec & " /c " & 'plink.exe -ssh DiskStation -l root -pw cdullr33 shutdown -h now', "", @SW_HIDE)
Exit
      exitloop
   case $msg = $Radio_2
  MsgBox (0,"Checked", "Close")
    exitloop
     EndSelect
WEnd
 #EndRegion ### END Koda GUI section ###
sleep (500)
Else
Run ("wolcmd.exe 001132555eb1 192.168.109.78 255.255.255.0 7")
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Netzwerkcheck", 523, 272, 419, 15)
GUISetBkColor(0x800000)
$Label1 = GUICtrlCreateLabel("Das Gerät ist nicht im Netz!", 84, 8, 354, 25, $SS_CENTER)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xFFFFE1)
$Pic1 = GUICtrlCreatePic("index2.jpg", 92, 48, 338, 149)
$Label2 = GUICtrlCreateLabel("Das Netzlaufwerk ist in ca. 2 Minuten einsatzbereit", 11, 232, 500, 24, $SS_CENTER)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xFFFFE1)
$Label3 = GUICtrlCreateLabel("Es wird nun gestartet ... einen Moment Geduld!", 37, 200, 449, 24, $SS_CENTER)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, 0xFFFFE1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
sleep (5000)

EndIf

:-) Borrowed and merged :-)

Link to comment
Share on other sites

When posting code please use the code tags ("<>" in the editor) to make your script easier to read :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...