Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automation and Scripting

General

Automation and Scripting

by  Provogeek  Posted    (Edited  )
As many of you may have found, a large part of a successful Zenworks deployment involves automation and scripting. Many have used the easier to understand .BAT scripts to automate and provide the needed scripting functionality. Others have found and learned VBS scripting. Personally, I found VBS scripting to be pretty confusing and difficult to work with. Recently I have run across a wonderful scripting engine that I have used at a few of my customer sites recently to solve some automation problems I was having. This software package is called Auto IT and can be found at http://www.autoitscript.com/autoit3/ and the software is FREEWARE!!! Do give these guys a donation, you will find this software to be easy to work with and can do some very wonderfully things.

Some examples of what I have done with this software;

This code was written for a customer who wants to use wireless PC's with no NetWare client using only the ZFD Agent logging in through a middle tier. The problem; the workstation does not get an IP address until after desktop initialization. This causes the login process to fail preventing policies and applications to be pushed through the agent. To get a user logged in and to keep the whole process automated, I wrote this script to work with an executable provided by NTS to call the login.

[sub]
;------------------------------------------------------------------------------------
; AutoIt Version: 3.1.0
; Language: English
; Platform: Win9x/NT
; Author: Brent Schmidt (brent@kiscc.com)
;
; Script Function:
; Logs user into eDirectory
;-------------------------------------------------------------------------------------



SplashImageOn("Status", "C:\Zenworks\Splash_01.bmp", 287, 157, -1, -1, 1) ; Place splash screen on desktop

$z = 0
Do
Ping("zenwsimport",250)
If @error = 0 Then
SplashOff()
Opt( "WinTitleMatchMode", 4 )
Run( "C:\Zenworks\XTLoginW.exe -log c:\zenworks\errors.log" )
WinWaitActive ( "classname=#32770" )
ControlSend ( "classname=#32770", "", 104, "USERID" )
ControlSend ( "classname=#32770", "", 106, "PASSWORD" )
ControlSend ( "classname=#32770", "", 107, "{ENTER}" )
$z=1
ElseIf WinExists("Generic Host Process for Win32 Services") Then
WinActivate("Generic Host Process for Win32 Services")
Send("{ENTER}")
Else
Sleep (100)
EndIf
Until $z = 1

; Inform user system is ready to use
MsgBox ( 64, "Ready", "The workstation is ready to use")
[/sub]

One of the biggest problems I had to over come was the sending of login data to the ZFD Agent login window. When Novell coded the login process, they did not name the window. This meant that I could not call the window by name and send data to the specified window. I had to use timing to call the executable, waiting for it to become active using a timer, then sending keyboard command to log the user in. This caused issues with slower systems taking longer to load the executable. It also left a window for a user to screw something up. One of the advanced functions I found allowed me to call the window control ID instead. This meant I did not have to use any timers and was able to send login data directly to the window specified and the user could not interfere with the process. Just took a little RTFM to find the answer to the problem. I have found the manual to be very well written and the many examples included help as well.

AutoIT also includes a nifty program for getting window information. AutoIT Window Info, just a simple program that when executed can provide you with the window name, control ID, button info, mouse and window position info.

This script was used at a customer site to deploy the agent into the customers environment through the login script. It employs a check to remove a previous desktop management package (LANDesk), verify the agent is installed already or not, and install if not done already.

[sub]
; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author: Brent Schmidt <Brent@kiscc.com>
; Company: KIS Computer Center
; Date: 6/8/05
;
; Script Function:
; Zenworks Workstation Agent Automated install
;
; ----------------------------------------------------------------------------
;
; This scipt is intended to be used in a system login script to
; detect workstations that do not have the ZFD Agent installed # if
; the agent is already installed, the script will bypass any attempts
; to install the agent.
;


SplashTextOn ( " Help Desk", "PC Help Desk x7208 - PC software maintenance, do not interrupt this program...", 350, 170, -1, 0, 1,"Courier New Bold", 22, 800 )
Sleep (2000)
;
; Check for and remove first the Intel LANDesk Mgmt Suite's remote Agent
;

If FileExists ( "c:\ldclient\wuser32.exe" ) Then
SplashTextOn ( "Help Desk", "PC Help Desk x7208 - PC software maintenance, do not interrupt this program...", 350, 170, -1, 0, 1,"Courier New Bold", 22, 800 )
RunWait ( "\\Apps01\APPS01\Applications.sys\Install\LANdesk.80\wscfg32 /f /u /noui /reboot" )
SplashTextOn ( "Notice", "LANDesk Agent Removed", 200, 50 )
Sleep (4000)
Exit
Else
SplashTextOn ( "Notice", "LANDesk Agent Already Removed", 200, 50 )
Sleep (4000)
EndIf

;
; Read the workstation registry to detect if the ZFD Agent is already installed.

$ver = RegRead ( "HKLM\SOFTWARE\Novell\ZENworks\ZfD\Agent\Workstation Manager", "Version" )
If $ver = "6.5.1.41208" Then
SplashTextOn ( "Notice", "Agent installed and current", 200, 50 )
Sleep (4000)
SplashOff()
Exit
Else
SplashTextOn ( "Help Desk", "PC Help Desk x7208 - PC software maintenance, do not interrupt this program...", 350, 170, -1, 0, 1,"Courier New Bold", 22, 800 )
RunWait ( "msiexec.exe /i P:\install\ZFDAgent\ZfDAgent.msi /qb-! STARTUP_APPEXPLORER=1 ADDLOCAL=ALL LOGIN_PASSIVE_MODE=0 NAL_SINGLE_TREE=1" )
EndIf

SplashOff()

[/sub]

This script was used to deploy the ZFD agent to over 600+ desktops while the project was running, and there is an expected 2000+ more to be deployed after the engagement. During the deployment, the only problems we ran into were workstations with out W2KSp4 or Xpsp1 (required) or systems with out IE6 installed. Other issues that occurred were isolated problems not related to the deployment. It worked great and just a couple of edit and I (and you) can use this script almost any ware to deploy the ZFD agent.

You will just need to play with the software to get familiar with it. A couple of awesome features; you can compile a script into a self executable to be used on as many systems as you choose. You do not need to install the scripting engine on all PC's the script gets used on. You can even package files with in the executable for installs and deployments.

For personal use, I have used this script engine to write a remote console tool to administer a game server from a remote client. It just provide a GUI front end for the DOS program running in the back ground. The possibilities and uses of this software are enormous and I use it very often now to solve all of my automation and scripting needs.

This software is awesome, you MUST check it out.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top