Sign in to follow this  
Followers 0
caboose

Convert dos batch to Autoit

5 posts in this topic

Hello, I am very new to autoit, but so far it has made my job so much easier. I need some help in converting a batch file that I have to autoit. Any help on this even just getting started would be great. This batch first tells what database the program I am using is in by finding a key word in the ini and displays it on screen. Then it brings up a cheesy menu that has selections to change the ini thus changing the database. Here is the batch:

:BEGIN

cls

@ECHO OFF

cls

findstr "Prod" c:\windows\program.ini

findstr "Test" c:\windows\program.ini

ECHO.

ECHO *******************************

ECHO ** PLEASE CHOOSE A NUMBER **

ECHO ** FOR THE PROGRAM DATABASE **

ECHO *******************************

ECHO.

ECHO.

ECHO.

ECHO 1. Prod

ECHO 2. Test

ECHO 3. Exit

ECHO.

ECHO.

SET CHOICE=

SET /P CHOICE=ENTER YOUR SELECTION:

if not '%choice%'=='' set choice=%choice:~0,1%

if '%choice%'=='1' GOTO PROD

if '%choice%'=='2' GOTO TEST

if '%choice%'=='3' GOTO EXIT

ECHO "%choice%" is not valid please try again

ECHO.

GOTO BEGIN

:PROD

copy c:\setdb\programprod.ini c:\windows\program.ini

c:\program\program.exe /r (reregisters the program)

cls

EXIT

:TEST

copy c:\setdb\programtest.ini c:\windows\program.ini

c:\program\program.exe /r (reregisters the program)

cls

EXIT

:EXIT

ECHO.

ECHO.

ECHO.

cls

exit

Share this post


Link to post
Share on other sites



Hi,

to start maybe this:

If Not FileExists("c:\windows\program.ini") Then Exit
$ret = InputBox("Chose:", "1.Prod" & @CRLF & "2.Test" & @CRLF & "3.Exit")
Switch $ret
    Case 1
        FileCopy("c:\setdb\programprod.ini", "c:\windows\program.ini")
    Case 2
        FileCopy("c:\setdb\programtest.ini", "c:\windows\program.ini")
    Case 3
        Exit (0)
    Case Else
        MsgBox(16, "Error", "Chose 1,2 or 3")
EndSwitch

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Thanks that helped a lot. I ended up doing it a little differently. The only part I need left is some equivilant to the findstr command in dos. Basically I need some thing to search the ini in the windows folder and return something if it is prod or test before I select a database. Here's what I got so far

#include <GUIConstants.au3>

$Label = GUICtrlCreateLabel("Choose a Program Database", 10, 10)
$ProdID  = GUICtrlCreateButton("Prod", 10, 50, 50, 20)
$TestID   = GUICtrlCreateButton("Test", 80, 50, 50, 20)
$ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)

GUISetState()  

Do
    $msg = GUIGetMsg()
   
    Select
        Case $msg= $ProdID
            FileCopy("c:\setdb\programprod.ini", "c:\windows\program.ini",1)
            run("c:\program\program.exe /r")
        Case $msg= $TestID
            FileCopy("c:\setdb\programtest.ini", "c:\windows\program.ini",1)
            run("c:\program\program.exe /r")
        Case $msg= $ExitID
    EndSelect
Until $msg= $ProdID or $msg= $TestID or $msg = $ExitID

Share this post


Link to post
Share on other sites

Thanks that helped a lot. I ended up doing it a little differently. The only part I need left is some equivilant to the findstr command in dos. Basically I need some thing to search the ini in the windows folder and return something if it is prod or test before I select a database. Here's what I got so far

#include <GUIConstants.au3>

$Label = GUICtrlCreateLabel("Choose a Program Database", 10, 10)
$ProdID  = GUICtrlCreateButton("Prod", 10, 50, 50, 20)
$TestID   = GUICtrlCreateButton("Test", 80, 50, 50, 20)
$ExitID = GUICtrlCreateButton("Exit", 150, 50, 50, 20)

GUISetState()  

Do
    $msg = GUIGetMsg()
   
    Select
        Case $msg= $ProdID
            FileCopy("c:\setdb\programprod.ini", "c:\windows\program.ini",1)
            run("c:\program\program.exe /r")
        Case $msg= $TestID
            FileCopy("c:\setdb\programtest.ini", "c:\windows\program.ini",1)
            run("c:\program\program.exe /r")
        Case $msg= $ExitID
    EndSelect
Until $msg= $ProdID or $msg= $TestID or $msg = $ExitID 
oÝ÷ Ûú®¢×²¢ç[{§¶)ඬzØ^ ÒÜ¢iÖ®¶­s`¢b33c·f"Òæ&VBgV÷C´3¢b3#µFV×b3#¶×fÆRæægV÷C²ÂgV÷C·6V7Föã"gV÷C²ÂgV÷C¶¶WgV÷C²ÂgV÷C´æ÷Df÷VæBgV÷C²¤×6t&÷CbÂgV÷Cµ&W7VÇBgV÷C²Âb33c·f"

Share this post


Link to post
Share on other sites

Perfect. Thank you so much for the help. I guess I kept overlooking iniread in help file.

Share this post


Link to post
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
Sign in to follow this  
Followers 0