Jump to content

Recommended Posts

Posted (edited)

Like this guy here, I'm a big fan of Windows "ShellNew" template entries. I have a right-click list of items so long that I'm embarassed. But I found the default AutoIt template a little too sparse for my liking. Since most of my scripts are for automated software installs, I modified the default AutoIt script and placed it in the Windows\ShellNew directory so when I right-click on my desktop and choose new AutoIt file, the script below automatically populates the new file.

Keep in mind this script may or may not be useful for folks that do development or automate other tasks. But becasue I'm not an AutoIt OG like @Melba23 or @water, this script keeps me from going back and forth to the help file to remember the syntax for, example, shortcuts, message boxes or creating carriage returns:

#cs ----------------------------------------------------------------------------
 AutoIt Version: 3.3.14.2
 Author:         Copyleft
 Script Function: New Unattended Setup Template
#ce ----------------------------------------------------------------------------
#RequireAdmin
#include <MsgBoxConstants.au3> ; remove if no message box function
#include <File.au3>
#include <TrayConstants.au3> ; remove if no tray function

$SetupDir= "D:\PROGRAMS\MyCustomProgramPath"
$IconDir = "C:\Bin\Icons"
$serial1 = "Serial number"
$Proces  = "MyApp.exe"

; create setup folder (test. some programs fail with existing directory)
If not FileExists($SetupDir) Then DirCreate($SetupDir)

; Setup triggers
RunWait(@ComSpec & ' /c command', @SW_HIDE) ; runs Windows command
RunWait(@COMSPEC & '/c AUTORUN_BAT.CMD', @SW_HIDE) ; runs batch file
ShellExecute(
RunWait(

; for fill-in forms
ControlSetText("MyApp", "", "Edit1", $serial1)
ControlClick("MyApp", "", "Button1")

; New Shortcut
FileCreateShortcut($SetupDir & "\MyApp.exe", @StartMenuCommonDir & "\Programs\MyStuff\MyApp.lnk", $SetupDir, "", "Manage MyApp installations", $IconDir & "\CustomIcon.ico", "" , 0, @SW_SHOWNORMAL)

; If | then | else
If ProcessExists("MyApp.exe") Then ; Check if MyApp process is running.
    ProcessClose("MyApp.exe")
Else
    
; Add configuration settings
sleep(1000)
RegWrite('HKCU\Software\AMP Soft\MyApp', 'Language','REG_DWORD',Number('0'))

; Relocate startmenu directory and delete desktop shortcut to unclutter user software environment
DirMove ("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\MyApp", @StartMenuCommonDir & "\Programs\UtilitiesDirectory")
DirMove ("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\MyApp", @StartMenuDir & "\Programs\UtilitiesDirectory")
FileDelete (@DesktopCommonDir & "\MyApp.lnk")
FileDelete (@DesktopDir & "\MyApp.lnk")

;double line message box
MsgBox(64, "MyApp", "MyApp has been installed" & @LF & "shortcuts have been installed . .", 3)
EndIf

; end
Exit

 

 

Edited by copyleft

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