Jump to content

Recommended Posts

Hey all,

 

I'm new to AutoIt, and I'm trying to get my feet wet, but I'm pretty overwhelmed. I'm trying to create a script that does a few things for a new computer set up for us, but I'm not even sure where to get started. I sort of laid out my idea for how I want things to go like this, but I could really use some direction. 

 

; Script Start - Add your code below here

; Change Admin Name to "COMPANY"

; Change Admin Password to "xxxxxx"

; Set Password Hint as "Please see documentation"

; Rename PC "Company-Laptop-'xxx'" where 'xxx' is the next available number on tracking spreadsheet

; Disable Notifications "Show me tips about Windows"

; Open this web link "software download"

; Save at prompt

; Run "software set up"

; Pin "program a" to Taskbar

; Delete "program b" Shortcut

; Set "program b" as Default PDF Reader

; Set "program a" as Default Web Browser

; Remove "program c" from Taskbar

 

I appreciate any help. I could outsource, but I'm hoping to learn for myself. 

Thanks!

Share this post


Link to post
Share on other sites

I can see why you're overwhelmed, that's a lot of tasks! I'm fairly experienced with AutoIT and it would take me a while to develop a script that can do all those tasks, specially sometime robust enough to work on many machines. And there may be more suitable tools, such as creating a master image and restoring with Sysprep that might be more applicable.

Start by breaking each task down. Create a test script to tackle only one problem. Don't worry about the user interface, don't worry about the other tasks. Just use hard coded values in the script. When in development I like using "ConsoleWrite" to spit out some debug information while I go. When

When looking at some of these system level changes, see if there's any programmatic API, registry, WMI, commandline tool that can do it. Trying to rely on pure GUI automation (mousemove, click, keystrokes, even controlclick) can be fragile. Your script is doing a lot of admin level stuff so it will need #RequireAdmin at the top.

Admin username / password: Look at Commandline interface via Net: (net User, Net localgroup).

These could be invoked via a Runwait() command. No need to use @COMSPEC because net.exe is separate from the command interpreter cmd.exe.

Password hint may be more difficult

Computer Name: Looks possible via wmic. Looks like you need to know existing name, doable via @ComputerName in AutoIt

Sample wmic code, looking like it's written for batch, is:

wmic computersystem where name="%COMPUTERNAME%" 
     call rename name="NEW-NAME"

Getting name from excel may be a little more involved, especially if Excel isn't installed on the PC. Look at IniRead, and FileRead/FileREadLine/FileReadToArray for potential options to read from a text file.

To download something via http, check InetGet()

Run programs using "Run" if you'll then need to interact with it, or "RunWait" if you want to wait for execution to finish.

Pinning in Windows 7 at least it's just copying or deleting a shortcut into a certain file. Either per user, or one for global. Check our FileCopy() and FileDelete()

 

Once you can get the individual features working, then look at starting to assemble them in one script.

Share this post


Link to post
Share on other sites

Thanks for the tip, TurionAltec! I appreciate your expertise. 

Is there anything else I should know? I've read through the help file, and it's still fairly daunting. Any particular tutorials of note, or useful tips/ticks, or other resources I should check out?

Share this post


Link to post
Share on other sites

I think I've gotten a good start, so far. This is my current progress. I haven't run the body of the script yet, but it gives me an idea of the command that I need to include.

 

#RequireAdmin
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

; Change Admin Name to "COMPANYNAME"
ControlSend ("wmic useraccount where name='Owner' rename COMPANYNAME")

; Change Admin Password to "PASSWORD"
ControlSend ("net user COMPANY NAME PASSWORD")
; Set Password Hint as "Please see documentation"
RegWrite ("HKEY_LOCAL_MACHINE\SAM\SAM\Domains\Account\Users\COMPANYNAME [, "UserPasswordHint", "REG_SZ", "Please see documentation"] )

; Rename PC "COMPANYNAME-Laptop-'xxx'" where 'xxx' is the next available number on tracking spreadsheet (may require GUI for input)

; Disable Notifications "Show me tips about Windows" (Still not sure how to do this one, may need regedit, or GUI prompt)

; Open this web link "web address"
InetGet ("web address", "programABpackage.exe" [, options = 0 [, background = 0]] )

; Run "programABpackage.exe"
RunWait ( "programABpackage.exe" )

; Pin "programA" to Taskbar (need to find default directory)

; Delete "programB" Shortcut (need to find default directory)

; Set "programB" as Default PDF Reader
ControlSend ("assoc .pdf=programB")

; Set "programA as Default Web Browser
ControlSend ("assoc .html=programA")

; Remove Edge from Taskbar (may require mouse automation)

 

Share this post


Link to post
Share on other sites
Posted (edited)

@KVice

All your ControlSend() should be replaced with Run() or RunAs() function; that's because ControlSend() sends an hotkey or raw keys to a GUI control, rather than Run()/RunAs(), which run a command, returning the PID of the application you did run.

For the point about renaming the PC, you could use a CSV file in which you store the needed information, and then manipulate them through _FileReadToArray()/_FileWriteFromArray(); look at those functions in the Help file.

For the point about disabling Windows notifications, take a look at this link :)

By the way, welcome to the AutoIt forums :welcome:

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

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

×
×
  • Create New...