Jump to content

Autostart Program/Script


anixon
 Share

Recommended Posts

I am new to scripting so many thanks to all subscribers who have helped me get this far and who have contributed some excellent code and idea's.

This is a script which runs in Startup. On a warm or cold boot it is designed to launch a home surveillance program together with its monitor (a scripted utility that checks and keeps it running in the event of an unauthorised closure).

It appears to work without any obvious issues.

Any comments would be appreciated ;) Ant

; Check internet connectivity
;

$IsCon=DllCall("WinInet.dll","int","InternetGetConnectedState","int_ptr",0,"int",0)
while $iscon[0] = 0
  $i = 0
  do
     beep(500,150)
     sleep(100)
     Beep(500,150)
     sleep(100)
   $i = $i + 1  
  Until $i = 2
     sleep(5000)
  $IsCon=DllCall("WinInet.dll","int","InternetGetConnectedState","int_ptr",0,"int",0)
wend

; Check that INI file exists
;
If Not FileExists(@ScriptDir & "\anyprogram.ini") Then 
  MsgBox(0, "anyprogram", "Unable to read anyprogram.ini")
  Exit
EndIf

; Read INI file variables
;
$var = IniRead(@ScriptDir&"\anyprogram.ini", "Kautostart", "mode", "0")
$var5 = IniRead(@ScriptDir&"\anyprogram.ini", "stealth", "mode", "0")
$var7 = IniRead(@ScriptDir&"\anyprogram.ini", "mymonitor", "mode", "0")

; Check for autostart setting
;
If $var() = '' then
   MsgBox(0, "anyprogram", "anyprogram.INI is not configured to run anyprogram AutoStart")
   Exit
Endif

;Set Stealth Mode
;
if $var5() = 1 then 
  Opt("TrayIconHide", 1)
EndIf

; Close these processes if running
;
ProcessClose("mymonitor.exe")
$PID = ProcessExists("mymonitor.exe")
  If $PID Then ProcessClose($PID)
ProcessClose("anyprogram.exe")
$PID = ProcessExists("anyprogram.exe")
  If $PID Then ProcessClose($PID)

;Open these processes
;
Run('c:\program files\program\anyprogram.exe')
Sleep(5000)
If $var7() = 1 then
  Run (@ScriptDir&"\mymonitor.exe")
EndIf
Sleep(5000)
  Run(@scriptdir&"\anyprogram1.exe")
Sleep(5000)
Exit
;
;End of Script
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...