Jump to content

Help getting started in autoit


Recommended Posts

Hi,

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.

Thanks

Steven.

@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=http://www.testing.rapidstudio.co.za/ >>"%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"

echo.

echo.

TITLE Wait for Setup.exe

:CHECK_PROCESS

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"

exit

Link to comment
Share on other sites

Here are some functions that could replace the ones you used in the batch file. The help file has examples on all of them if their usage is unclear.

Single line "if" statements work very much like the ones you used. Multiline if statements have to be closed with "endif".

There is no GOTO in autoit. If you need to run a part of your script multiple times its best to place it into a function.

batch                   =>  AutoIt
exists                  =>  FileExists() (yes it works for dirs)
move                    =>  DirMove() / FileMove()
%temp%                  =>  @TempDir
MKDIR                   =>  DirCreate()
xcopy                   =>  DirCopy() / FileCopy()
%userprofile%\desktop   =>  @DesktopDir
echo                    =>  depends on your interface ConsoleWrite() is usefull while testing
atrib                   =>  FileSetAttrib()
del                     =>  FileDelete()

I'm a bit unclear about what goes on between

:CHECK_PROCESS

and

GOTO :CHECK_PROCESS

but take a look at ProcessExists(), ProcessWait(), ProcessWaitClose()

Link to comment
Share on other sites

Hi,

Thanks for the help - We've managed to convert all the scripts.

I'm just having trouble with a shortcut we create.

the shortcut is created fine, but it doesn't show it's icon.

Only if you check the properties of the shortcut and click "choose icon" - it then shows the icon.

Is there a way to resolve this?

Thanks

Steven

Link to comment
Share on other sites

Hi,

if you use FileCreateShortcut (), have you set the icon param and, if you have to, the icon number:

FileCreateShortcut ( "file", "lnk" [, "workdir" [, "args" [, "desc" [, "icon" [, "hotkey" [, icon number [, state]]]]]]] )

Another solution is, to create a shortcut with proper icon settings in your @ScriptDir and just copy it with FileCopy () to the target folder you want to.

;-))

Stefan

Link to comment
Share on other sites

Thanks :idea: Will give it a try.

Now for another one....

On most of the PCs here this works... but on mine it doesn't (the part that makes the files not be read only)

I am on a 64 bit PC - and the files are in program files NOT in program files X86 or wherever the 32 bit programs usually are.

FileCopy("RapidStudio_QuickSupport.exe", @ProgramFilesDir & "\RapidStudio_Support\RapidStudio_QuickSupport.exe",9)

FileCopy("QSApp.ico", @ProgramFilesDir & "\RapidStudio_Support\QSApp.ico",9)

FileCreateShortcut(@ProgramFilesDir & "\RapidStudio_Support\RapidStudio_QuickSupport.exe", @DesktopDir & "\RS_QuickSupport.lnk", @ProgramFilesDir & "\RapidStudio_Support\","", "RapidStudio QuickSupport", @ProgramFilesDir & "\RapidStudio_Support\QSApp.ico", "", "15", @SW_MINIMIZE)

Sleep(60)

If ProcessExists("Setup.exe") then

ProcessWaitClose("Setup.exe")

EndIf

FileSetAttrib(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\*.*", "-R")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Animals\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Baby\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Beach\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Buttons\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Charms\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Cuves\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Everyday Objects\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Floral\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Letters\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Line Art\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Nature\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Paper\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Party\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Postcards\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\rapidstudio logos\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Ribbons 'n Bows\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Romantic\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Simple Lines\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Simple Shapes\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Sport\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Tags\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Travel Africa\thumbs.db")

FileDelete(@ProgramFilesDir & "\RapidStudio\MPR500 Pro 5\Cliparts\Travel Eastern\thumbs.db")

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