Languages - DevSource
DevSource: Microsoft Developer Resource DevSource Home Sponsored by Microsoft Home Add Ons Architecture Languages Techniques Using VS Forums
Home arrow Languages arrow Page 3 - KiXtarting Your Scripts
KiXtarting Your Scripts
By Lynn Greiner

Rate This Article: Add This Article To:

KiXtarting Your Scripts - ' More Admin Tasks '
( Page 3 of 3 )

Performing tasks based on user population (an office location or department, for example) is a matter of creating If or Case statements around the keyword InGroup.

It will look at the current user's group memberships in Active Directory, and perform the specified actions based on that membership.

ADVERTISEMENT

For example, if each location has a file server, you want users to connect to the local machine for best performance.

Just make sure each user is a member of a suitable group, and the job is simple.

Deploying files is easy, too.

Say the network folks have changed the corporate VPN's connection parameters. You have to get the new settings, which live in a .pcf file, out to users.

The following checks that the necessary directory exists, deletes the old files, and puts the new ones in their place.

$path = ("C:\Program Files\Vendor Systems\VPN Client\Profiles\")
$net = (\\domain\netlogon\pcf\)
$pri = ("New-Primary-connection.pcf")
$sec = ("New-Secondary-Connection.pcf")
If Exist($path)
; If the files are already there, do nothing
	If Exist($path+$pri) AND Exist($path+$sec)
	Else
		DEL $path+"*.*"
		Copy $net+"*.*" $path
	EndIf
EndIf

KiXtart contains a nice collection of macros that return everything from the date to the MAC address of the PC's NIC. And if that's not enough, its COM support lets you venture out and grab additional functionality.

Want to warn users a few days before their passwords will expire? The macros @MAXPWAGE (the maximum allowable) and @PWAGE (the user's password's age), and a little arithmetic lets you decide when to generate a message box. The code to generate warnings, if there are less than ten days to go, looks like this:

$TimeLeft = @MAXPWAGE - @PWAGE
If $TimeLeft < 10
	$ = MessageBox("Your password will expire in " + $TimeLeft + " days")
EndIf

What else can KiXtart do? The list goes on and on. String manipulations, of course, calls to run scripts within scripts, calls to run external programs or Windows commands — you can even shut down the computer.

The current version of KiXtart (4.50), for the first time, allows you to pre-tokenize your scripts, speeding execution and enhancing security. It also has an INCLUDE command, letting you combine several script files into one at execution time.

Want more ideas? Sample scripts may be found on KiXtart.org, or on Microsoft's Script Center. For a language tutorial, try the online manual, or Bob Kelly's Agility Press book, Start to Finish Guide to Scripting with KiXtart, an excellent guide to the language.



 
 
>>> More Languages Articles          >>> More By Lynn Greiner
 



Microsoft's Future: A Chat With Their CTO, Barry Briggs

Play Video >

All Videos >

Julia explores the Robotics Studio!

Read now >

Messages to Bill Gates!

Read now >

View Now
DevSource RSS FEEDS
XML Want an easy way to keep up with breaking tech news? And the Get DevSource headlines delivered to your desktop with RSS.