Jump to content

Run batch then wait till it is finished


Recommended Posts

Hi guys, i am having trouble making autoit wait till my batch file is done before moving on with the rest of the script. to run the batch i use this code.

runwait (C:\batch.batch)

i found this in the help file. Any suggestions?

Thanks

The Juiciest Of The Jons

Link to comment
Share on other sites

RunWait("C:batch.bat")

?

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

A couple of things wrong with your code is the space between the function name and brackets, and no quotations around the file name, so I rewrote it. Does it work now?

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

Can you supply additional au3 code and if possible the batch script code?

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

How about ShellExecuteWait("c:batch.bat"), does that do what you need?

As a side note, are you sure you actually need to use a batch file for what you're doing? Can it be done all in AutoIt?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

As a side note, are you sure you actually need to use a batch file for what you're doing? Can it be done all in AutoIt?

My thoughts exactly. After learning about AutoIT, I converted all my batch scripts.

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

I tried to make the batch into an autoit script but it did not give me the desired results ;) . So it was easier for me to create a batch and then have autoit run it. Here is the batch if you are interested.

@echo off
if exist c:fwiplist.txt goto Label1
echo.
echo Cannot find c:fwiplist1.txt
echo.
Pause
goto :eof
:Label1
for /f %%i in (c:fwiplist1.txt) do call :Sub %%i
goto :eof
:Sub
set state=alive
ping -n 1 %1 | find /i "bytes=" || set state=dead
if %state%==alive echo %1 is %state% >> c:results.txt
if %state%==dead echo %1 is %state% >> c:results.txt

Water the shellexecutewait worked. Thanks :) , also if you have a suggestion on turning my batch into a script (if i can) i would appreciate it. Also thanks for the help.

Jon

The Juiciest Of The Jons

Link to comment
Share on other sites

Try this:

#include <File.au3>
Global $aFile
If Not FileExists("c:fwiplist.txt") Then
    MsgBox(64, "Error", "Cannot find c:fwiplist1.txt")
    Exit
EndIf
_FileReadToArray("c:fwiplist.txt", $aFile)
$File = FileOpen("C:results.txt", 1)
For $I = 1 To $aFile[0]
    If Not Ping($aFile[$I]) Then
        FileWriteLine($File, $aFile[$I] & " is dead" & @CRLF)
    Else
        FileWriteLine($File, $aFile[$I] & " is alive" & @CRLF)
    EndIf
Next
FileClose($File)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

bored ftw

#include <File.au3>

$sFile = "C:fwiplist.txt"
$sResults = "C:results.txt"

If FileExists($sFile) Then
    _Sub()
    Exit
Else
    msgbox(16 + 262144, "Script", "Cannot find " & $sFile)
    Exit
EndIf


Func _Sub()
    Local $asIP
    Local $iTimeout = "2000" ;Whatever timeout value you want
    If FileExists($sResults) Then FileMove($sResults, "C:results-" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & ".txt")
    $hResults = FileOpen($sResults, 1)
    _FileReadToArray($sFile, $asIP)
    ProgressOn("Scanning IPs", "Checking IP Addresses From File", "Please Wait...")
    For $i = 1 To $asIP[0]
        If Ping($asIP[$i], $iTimeout) Then
            Sleep(100)
            FileWrite($hResults, "ALIVE: " & $asIP[$i] & @CRLF)
        Else
            $iError = @error
            Switch $iError
                Case 1
                    $sError = "Host Offline"
                Case 2
                    $sError = "Host Unreachable"
                Case 3
                    $sError = "Bad Destination"
                Case 4
                    $sError = "Other Error"
            EndSwitch

            FileWrite($hResults, "DEAD: " & $asIP[$i] & " - Error: " & $iError & " = " & $sError & @CRLF)
        EndIf
        ProgressSet(Round($i / $asIP[0] * 100), Round($i / $asIP[0] * 100) & "% Complete", "Checking IP Addresses From File")
    Next
    ProgressSet(100, "DONE!", "IP Check Complete")
    Sleep(2000)
    FileClose($hResults)
EndFunc
Edited by mechaflash213
Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

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