Jump to content

Script not working


Recommended Posts

Hi guys,

I have searched and searched and I cannot figure this out. I am trying to use autoit to automate certain tasks for a post image installation checklist. I am using the recorder to capture keystrokes. Initially I got the error about the AUrecord function not being defined (not sure why there is an _ in one part, but not in another. It makes the script not work.) So I either add the underscore where there is none or remove the one that exists in the script and then it runs without error (at least none that I can see).

But that is the problem, after that, nothing actually happens. The script doesn't seem to error out, but it doesn't actually seem to ever do anything. Would anyone be able to help me out? Below is the code of the script that the recorder is spitting out. I had to make modifications where the '.' and the '/' are because for some reason the recorder changed those to squares (like unrecognized characters). Right now this script is just trying to run windows updates. I will add more things to it once I can figure out why this script doesn't work.

#region ---Au3Recorder generated code Start (v3.3.7.0) ---

#region --- Internal functions Au3Recorder Start ---
Func _Au3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
EndFunc

Func _WinWaitActivate($title,$text,$timeout=0)
WinWait($title,$text,$timeout)
If Not WinActive($title,$text) Then WinActivate($title,$text)
WinWaitActive($title,$text,$timeout)
EndFunc

_AU3RecordSetup()
#endregion --- Internal functions Au3Recorder End ---

_WinWaitActivate("Au3Record","Address: C:\Program ")
Send("{LWINDOWN}r{LWINUP}")
_WinWaitActivate("Run","Type the name of a p")
Send("wuauclt.exe{SPACE}/{SHIFTDOWN}s{SHIFTUP}elf{SHIFTDOWN}u{SHIFTUP}pdate{SHIFTDOWN}u{SHIFTUP}m{BACKSPACE}nmanaged{ENTER}")
#endregion --- Au3Recorder generated code End ---
Link to comment
Share on other sites

  • Moderators

Hi, justlearning, welcome to the forum. To be honest, the code returned by the Recorder can sometimes be a mess (as is true in your case). Rather than trying to fix it, can you please describe in detail the steps you're trying to accomplish (I see you're calling windows update, but is there more?). There is definitely going to be an easier way to accomplish what you are trying to do.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thank you for your response. There are a few tasks that I would like to accomplish with this. First I would like to run windows update and install all updates. Then I would like to run the lenovo system update and install all of those updates. And finally, I would like to install a couple of files that we have stored on a file share. I am pretty much a total n00b when it comes to these things. I can look at the code and understand it (mostly), but writing my own is where I fall short. Any assistance would be greatly appreciated!

Link to comment
Share on other sites

Most of the installation programs can be run from the command line. Functions can be selected by command line switches.

Windows Update: Run WUAUCLT

Lenovo System Update

No need to automate the GUI.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Most of the installation programs can be run from the command line. Functions can be selected by command line switches.

Windows Update: Run WUAUCLT

Lenovo System Update

No need to automate the GUI.

Thank you for your response. If you look at my script you see that it was calling WUAUCLT with the appropriate switch. What I am trying to do is automate everything using AutoIt. Do you have suggestions how to do so?

Link to comment
Share on other sites

Hi

What water meant was more in these lines:

Instead of automating a GUI for running a command line as you do here...

_WinWaitActivate("Au3Record","Address: C:\Program ")
Send("{LWINDOWN}r{LWINUP}")
_WinWaitActivate("Run","Type the name of a p")
Send("wuauclt.exe{SPACE}/{SHIFTDOWN}s{SHIFTUP}elf{SHIFTDOWN}u{SHIFTUP}pdate{SHIFTDOWN}u{SHIFTUP}m{BACKSPACE}nmanaged{ENTER}")
#endregion --- Au3Recorder generated code End ---

... call it directly from AutoIt, as for example here:

ShellExecuteWait("wuauclt.exe","/SelfUpdateUnmanaged")
Link to comment
Share on other sites

Well said :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hi

What water meant was more in these lines:

Instead of automating a GUI for running a command line as you do here...

... call it directly from AutoIt, as for example here:

ShellExecuteWait("wuauclt.exe","/SelfUpdateUnmanaged")

Thank you! EDIT: Just another question, for each command line switch must it be separated by a comma and quotation marks?

Could someone please let me know what commands would allow me to call a file on a network location?

Edited by justlearning
Link to comment
Share on other sites

The same ShellExecuteWait can call a file on a network share...for example

ShellExecuteWait("\\computername\direcory\executable.exe")

Or if you need to copy files, you could use FileCopy.

Excellent. So one last question, for each command line switch for wuauclt.exe does it need to be separated by a comma and another set of quotation marks?

For example

shellexecutewait("wuauclt.exe","/selfupdatenow /r") OR shellexecutewait("wuauclt.exe","/selfupdatenow","/r")

Which would be the correct format? In the editor it looks like the second way is correct, I would just like to verify (I run the script and nothing new seems to happen, that is why I am asking).

Thanks again guys!

Link to comment
Share on other sites

Each comma denotes a new parameter for ShellExecuteWait, so your first example is correct.

Excellent! Thanks!

While this next question is not autoit related, maybe someone knows the answer. We have found that wuauclt.exe /detectnow updates the computer, but it only does the critical updates. Does anyone know of a switch to pull the optional updates as well? I have been googling this and have found exactly nothing.

Link to comment
Share on other sites

Excellent! Thanks!

While this next question is not autoit related, maybe someone knows the answer. We have found that wuauclt.exe /detectnow updates the computer, but it only does the critical updates. Does anyone know of a switch to pull the optional updates as well? I have been googling this and have found exactly nothing.

I think what you will find is that it updates according to its configurations. That configuration is in the registry... you could try to "RegWrite" the values that configure it to do the updates you want , then do the "ShellExecute"

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

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