Help getting started in autoit

I was told autoit will be much better then bat files to help do some cleaning up after our software installation.
The black batch script box is very unprofessional, and sometimes people close it before it can finish processing.
We're under a very tight dedline, far behind schedule. I'm struggling a bit getting used to the new syntax.
I'm posting the bat text here, if anyone can please help give some examples of how autoit handles the functions we're using so we can get the new script tied down as soon as possible, we'd really appreciate the help.

@echo off
TITLE Backup Albums
if exist C:\RapidStudio_Albums MOVE /Y C:\RapidStudio_Albums %temp%
TITLE Copy Shortcuts
if not exist "C:\Program Files\RapidStudio_Support" MKDIR "C:\Program Files\RapidStudio_Support"
xcopy QSApp.ico "C:\Program Files\RapidStudio_Support" /Y
xcopy RapidStudio_QuickSupport.exe "C:\Program Files\RapidStudio_Support" /Y
xcopy RapidStudio_QuickSupport.exe %userprofile%\desktop /Y
echo [InternetShortcut] >"%userprofile%\desktop\RapidStudio Web.url"
echo URL= >>"%userprofile%\desktop\RapidStudio Web.url"
echo IconFile=C:\Windows\System32\url.dll >>"%userprofile%\desktop\RapidStudio Web.url"
echo IconIndex=0 >>"%userprofile%\desktop\RapidStudio Web.url"
TITLE Wait for Setup.exe
set found=N
for /f "tokens=*" %%a in ('tasklist ^| findstr /i "Setup.exe"') do set found=Y
rem echo Process=Setup.exe
rem echo found =%found%
> wait.bat echo ^@CHOICE ^/T %%1%% ^> NUL ^/D y
call wait.bat 5
del wait.bat
if "%found%"=="Y" echo Process is still running...
if "%found%"=="Y" GOTO :CHECK_PROCESS
echo Process has stopped
TITLE Change attributes
attrib -R "C:\Program Files\RapidStudio\MPR500 Pro 5\*.*"
DEL /S /Q /F /A:S "C:\Program Files\RapidStudio\MPR500 Pro 5\thumbs.db"
DEL /S /Q /F "C:\Program Files\RapidStudio\MPR500 Pro 5\thumbs.db"
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bryan ButlerCommented:
Autoit it for GUI testing automation.  It would not make sense to use it for anything else really.  Definitely not this type of thing.  Powershell would be the best thing to use, but it's only installed by default on win7.
I suggest using AutoIT, it works awesome, I'm a network admin and I use it everyday. I've converted your bat code to AutoIT
; Backup Albums

If FileExists ( "C:\RapidStudio_Albums" ) Then FileMove ( "C:\RapidStudio_Albums", @TempDir , 1 )

; Copy Shortcuts

If Not FileExists ( "C:\Program Files\RapidStudio_Support" ) Then DirCreate ( "C:\Program Files\RapidStudio_Support" )
FileCopy ( "QSApp.ico", "C:\Program Files\RapidStudio_Support" , 1 )
FileCopy ( "RapidStudio_QuickSupport.exe", "C:\Program Files\RapidStudio_Support" , 1 )
FileCopy ( "RapidStudio_QuickSupport.exe", @DesktopDir , 1 )
FileCopy ( "source", "dest" , 1 )
FileCopy ( "source", "dest" , 1 )

$file = FileOpen(@DesktopDir & "\RapidStudio Web.url", 1)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")

FileWrite($file, "[InternetShortcut]" & @CRLF)
FileWrite($file, "URL=" & @CRLF)
FileWrite($file, "IconFile=C:\Windows\System32\url.dll" & @CRLF)
FileWrite($file, "IconIndex=0")


ProcessWaitClose ( "Setup.exe" )

FileSetAttrib ( "C:\Program Files\RapidStudio\MPR500 Pro 5\*.*", "+R" )

FileDelete ( "C:\Program Files\RapidStudio\MPR500 Pro 5\thumbs.db")

Open in new window

StevenHookAuthor Commented:
Thanks so much.
Is is possible to detect where the software is installed id they customise the installation path?
Perhaps from the registry?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Yeah, you could do a registry read like this: $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\RapidStudio", "installDir")

Exact registry path depends on how RapidStudio would write to registry of course.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bryan ButlerCommented:
Very nice gimosuby!  I stand corrected.  I guess they are just wrappers for the most part, so it should work fine too.  I have really only used it for GUI tests and forgot about all the functions autoit has.  Thanks for the code too!
You're welcome. You can do amazing things with AutoIT, I have it do a lot of stuff at my company and the help file is very thorough. Glad I could help.
StevenHookAuthor Commented:
Another glitch....
The section that deleted the thumbs.db isn't working.
I think it might be because the files are hidden? or "system files"?
Is there a way around this?
Strange, I was able to delete a thumbs.db file just fine with filedelete()
You can try this:

FileSetAttrib("C:\Program Files\RapidStudio\MPR500 Pro 5\thumbs.db" ,"-RHS")

to clear its read-only, system, or hidden file status.

Alternatively you could run your own batch file lines in a hidden command prompt window like this:

Run(@ComSpec & " /c " & 'DEL /S /Q /F /A:S "C:\Program Files\RapidStudio\MPR500 Pro 5\thumbs.db"', "", @SW_HIDE)
Run(@ComSpec & " /c " & 'DEL /S /Q /F "C:\Program Files\RapidStudio\MPR500 Pro 5\thumbs.db"', "", @SW_HIDE)
StevenHookAuthor Commented:
Awesome - Thanks.
Will stick to auto it with the -RHS
StevenHookAuthor Commented:
Ok, Last one I think.
how can I delete files that match a criteria recursively?
I want to delete all the thumbs.db in the whole program folder and all sub folders?
This should do the trick:
Dim $FolderName = "C:\Program Files\RapidStudio"


Func ScanFolder($SourceFolder)
	Local $Search
	Local $File
	Local $FileAttributes
	Local $FullFilePath

	$Search = FileFindFirstFile($SourceFolder & "\*.*")

	While 1
		If $Search = -1 Then

		$File = FileFindNextFile($Search)
		If @error Then ExitLoop

		$FullFilePath = $SourceFolder & "\" & $File
		$FileAttributes = FileGetAttrib($FullFilePath)
		if $File = "thumbs.db" then FileDelete($FullFilePath)

		If StringInStr($FileAttributes,"D") Then ScanFolder($FullFilePath) ;Resursive



Open in new window

Bryan ButlerCommented:
Thanks for the points as gimosuby was awesome here.  The recursion is very nice!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.