Sign in to follow this  
Followers 0
jagreenwood

RunWait() issue

8 posts in this topic

Hello, I'm new to this forum but I've been using AutoIt for about a year now.

I wrote an AutoIt script to automate the installation of Microsoft patches. This script uses the RunWait() function in the following format:

RunWait("Windows\XP\WindowsXP-KB921398-x86-ENU.exe /quiet /norestart")

This script works as expected and executes the arguments with no issues.

Now, if I call this exact same script with another script (.bat), the arguments are ignored.

I tried the function ShellExecuteWait(), but it seems to want to run out of the path that the .bat file is in rather then the path that my AutoIt script is run.

Any ideas on what is going on? I'd like to execute the patch with the specified arguments.

Thank you!

Share this post


Link to post
Share on other sites



Welcome to the forum. :)

RunWait("Windows\XP\WindowsXP-KB921398-x86-ENU.exe /quiet /norestart")

-You should put in the entire path of the exe and the working directory parameter.

Now, if I call this exact same script with another script (.bat), the arguments are ignored.

Do you get any errors or the update starts up without the silent install?

Share this post


Link to post
Share on other sites

Welcome to the forum. :)

-You should put in the entire path of the exe and the working directory parameter.

Do you get any errors or the update starts up without the silent install?

Hi there, the reason I'm not using the entire path is that this script is typically run off a CDROM or USB stick. And now I'm adding functionality to run it off the harddrive. I'm plan to do this by having autoexec.bat call my AutoIt script on reboot. I'm hoping to keep my AutoIt script unaltered, so that I can run it in all three of these forms. Could I use @WindowsDir to make this part work?

I don't get any errors when the script is executed via the .bat; it only simply installs without silent mode.

Share this post


Link to post
Share on other sites

Ok...I dont think u need the autoexec.bat file....You can do everything in ONE script....Let me know the exact steps that you need to take to install the updates...

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Have you tried using /Passive along with /quiet /norestart?

Edit: Didn't properly read earlier post :)

Edited by ksmith247

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Share this post


Link to post
Share on other sites

Ok...I dont think u need the autoexec.bat file....You can do everything in ONE script....Let me know the exact steps that you need to take to install the updates...

The big picture is a little more complicated then I have described so far; I was trying to limit it to my current issue.

Basically, I've this this script that installs patches based on what OS (WIN2K3, WINXP, WINXP Embedded) it is running on. I distribute this via CDROM image and it is to be executed off the CDROM for WIN2K3 and WINXP. WINXP Embedded has to be executed off of a USB stick because the only interface it has is USB. All that works great.

BTW this is updated and released on a quarterly basis.

Now I have to do the same thing but with centralized remote patch distribution to ~15 nodes. I don't want to reinvent the wheel so I want to utilize my existing CDROM image for part of this. I'll spare you all the details of my design, but after all the media is transferred from the server to the clients, I've decided to reboot the machine to start the install from a known state instead of risk one of the clients failing due to the finicky behavior of Windows, thus autoexec.bat.

My design is solid, but AutoIt is preventing me from progressing. Why does RunWait() ignore arguments when the script is called from another script?

thanks for your incite :)

Share this post


Link to post
Share on other sites

Ignoring switches is odd behaviour and I would look at the @WorkingDir as an issue perhaps causing it. Since you are using a relative path and I am not sure if the current directory is correct to start with, then some code to check maybe suitable to avoid issue.

Try adding the below before your RunWait() to see if the working directory that your script starts with is what you need when using "windows\XP".

If Not FileExists('Windows\XP') Then
    If FileExists(@ScriptDir & '\Windows\XP') Then
        If Not FileChangeDir(@ScriptDir) Then
            MsgBox(0x40000, @ScriptName, 'Unable to change @WorkingDir to ' & @ScriptDir)
            Exit 1
        Else
            MsgBox(0x40000, @ScriptName, '@WorkingDir is ' & @ScriptDir, 5)
        EndIf
    Else
        MsgBox(0x40000, @ScriptName, 'Unable to find the hotfixes path')
        Exit 2
    EndIf
Else
    MsgBox(0x40000, @ScriptName, 'Found Windows\XP', 5)
EndIf

:)

Share this post


Link to post
Share on other sites

I'd do this more like

CODE
$path = "C:\windows\temp"

RunWait(chr(34) & $path & "\WindowsXP-KB921398-x86-ENU.exe" &chr(34) &" /quiet /norestart", $path, @SW_ENABLE)

the chr(34) will put " " around your execute. and using $path as a working dir makes you use the same workingdir as the executable.


Welcome to the internet :) where men are men! Women are men! and 16 year old women are FBI agents!

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