Jump to content

automate your scripts at startup without autostart

Recommended Posts

made a little prog, cause i want most of my progs to start if the computer starts, but i didn't want to use the autostart-thing, cause some people at my work check this quite often and remove progs they don't know or recognize, so i decided to write a value to the registry to automate the start

the prog uses the original windows folder and by now works as it should (haven't discovered any bug yet, but that doesn't mean there ain't any)

here's the code

;this programm uses the registry as autostart_option
;only works as admin
;made by Marten Zimmermann

#include <guiconstants.au3>

GUICreate ("Main", 600, 100, -1, -1, -1, $WS_EX_ACCEPTFILES)
;the regvalue
GUICtrlCreateLabel ("Registryvalue", 10, 10, 100)
$regval = GUICtrlCreateEdit ("", 120, 10, 170)
;the programm
guictrlcreatelabel ("Programm", 10, 40, 100)
$prog = GUICtrlCreateEdit ("", 120, 40, 420, -1, $ES_READONLY, $WS_EX_STATICEDGE + $WS_EX_ACCEPTFILES)
$progbut = GUICtrlCreateButton ("...", 550, 40, 40)
;do as you wish button
$write = GUICtrlCreateButton ("AutoStartIt", 10, 70, 280)
;set the focus on first control
GUICtrlSetState ($regval, $GUI_FOCUS)

while 1
    $msg = GUIGetMsg()
;exit on X
    case $msg = $GUI_EVENT_CLOSE
;what happens at "..."
    case $msg = $progbut
    ;open a filedialog to input the file
        $file = FileOpenDialog("Choose file...",@WorkingDir,"Exe (*.exe)", 1)
    ;if there is a file selected update the edit_control
        if @error <> 1 Then
            GUICtrlSetData ($prog, $file)
;what happens at "AutoStartIt"
    case $msg = $write
    ;call this function

func writeit()
;check if there is a programm chosen
if guictrlread ($prog) <> "" Then
;check if registry-value already exists
    $a = RegRead ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", guictrlread($regval))
;if it doesn't write it
    if @error = -1 Then
        $regvalue = StringReplace(guictrlread($regval), " ", "_")
        $b = RegWrite ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", $regvalue, "REG_SZ", guictrlread ($prog))
    ;check if writing was successful
        if $b = 1 Then
            msgbox (0, "Success", "Programm automated successfully", 2)
            msgbox (0, "Error", "An Error occured while writing", 2)
        msgbox (0, "Error", "Key already exists", 5)
    msgbox (0, "Error", "No programm", 5)

hope this is something useful for you as well

any suggestions?

trying to include admin-mode (changing rights to admin) soon

maybe even multiple files at 1 value


Link to post
Share on other sites


But why should the admins not control the registry autoruns aswell? Most program's autoruns are located there... and by the way most viruses & co. do so too.

But the idea itself is good, I did something similar myself too.


vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvGerman Forums: http://www.autoit.deGerman Help File: http://autoit.de/hilfe vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

Link to post
Share on other sites
  • 2 years later...
  • 2 weeks later...
  • 3 weeks later...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...