Page 1 of 1 1
Topic Options
#210231 - 2015-05-04 11:03 PM Basic Scripting
kevinj895 Offline
Just in Town

Registered: 2015-05-04
Posts: 4
Loc: Ohio, USA
I just started a new job about a month ago, and the company uses this script. As of now, they use it to map network drives and network printers. They assigned me to look into this script and see what else it can do. I've been researching online and noticing there are vast examples of what you can do with this script. However, none of them seem to be practical. Like some are for games, doing small things here and there. I was wondering if you guys could share with some practical examples of how you use the script or seen others use the script. Can you make it so when you login the computer checks for Windows updates or things of that nature? Please let me know! Thanks!
Top
#210232 - 2015-05-04 11:18 PM Re: Basic Scripting [Re: kevinj895]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
If you are only using Kix for login processing your options are limited to the rights of the user. However, admin scripts are very powerful and can do just about anything. I suggest your start in the manual and then the User Defined Functions (UDFs) and look at all the amazing functions that have already been done for you.

All the UDFs are here -
http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1

How to use UDFs -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81943#Post81943

If you are new to scripting, and/or have ever used vbscript, you will find kixtart very familiar and easy to learn. Powershell (as an alternative), while very powerful, is not very forgiving, and, in my opinion, ugly to read and write.

The best thing to do is ask yourself what you want to automate, and see what is available.


Top
#210235 - 2015-05-05 06:37 PM Re: Basic Scripting [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Games? Games are practical (in their special time and place)!! \:D Welcome to KORG, BTW - If we can't give you ideas for automation, nobody can!

I'm currently developing an automated NOC, with most of the autonomous features written in Kix, and all of the daily system maintenance tasks are now Kix-based, including:
  • Sequencing tasks and scheduling day/night task groups
  • Validating antivirus is installed, running, and definitions are current
  • Clearing all temp folders of stale files
  • Backing up user files (shortcuts, favorites, templates, etc) for ALL users
  • Check the Run and RunOnce keys for unwanted items, removing or reporting their presence
  • Verify workstation time is sync'd with the DC, or PDCe is sync'd with global NTP
  • Collect about 150 computer settings and values for query by the monitoring system
  • Intelligent disk space monitoring, with alarms keyed to a ratio of disk size. Trending of usage is also performed to predict when a disk will cross the alarm threshold so that cleanup or disk management can be performed, or new storage can be provisioned.
  • Disk defragmenter - auto skip SSD drives
  • Disk Health Check - runs ChkDsk and performs a SMART query, reporting any errors found.
The Kix scripts allow local tracking of events, triggering an alarm only after 3 consecutive fault conditions for certain tests, eliminating alarms for temporary transitions (AV definitions outdated or disk capacity at threshold). This allows intelligent monitoring with the least amount of alarms being generated.

In a recent project where we consolidated 4 worldwide domains of about 15 to 25 thousand objects each, I used Kix to query each domain, then compare the results to identify accounts that were already in both domains; pull data from a specific site's OU, format it into Excel, and provide the worksheet to the Site Engineer to verify the information was correct. Once any corrections were made to AD, we'd re-run the report and use the resulting data to create migration-day tracking reports as well as a feed to the Quest tool to pick the accounts to migrate each day.

In a couple of companies, I've used Kix to automate the deployment of software, applications, and web apps.
  • SWDIST - a package of Kix scripts that can deploy any application, patch, or service pack to one or thousands of computers at multiple sites. This was deployed at the FED, serving 5 regional data centers, and at a large travel agency serving 2 data centers and over 450 branch locations. Kix scripts did the deployment, synchronized the deployment servers, managed logging, scheduling, and reporting.
  • At the travel agency, a set of Kix scripts was used to deploy web application updates. The same tool allowed the DEV team to deploy to the DEV servers and validate the package. The Operations team then used the tool to deploy to QA, and after certification, to the PROD servers. Of particular note was the fact that the developers and operations team did not have permission to actually log onto the web servers in any environment - the deploy GUI communicated with a server that verified the user credentials and performed the update by proxy to the target web platforms. A complete rollback capability was also implemented, all in KiXtart.
  • In a role as a Dev-Ops manager, I created Kix scripts to automate the deployment of multiple applications to various targets. The tool allowed the Operations staff to perform the installations without knowledge of the application or the installation process. All they needed to do was download the package and run the installer. Same installer for all apps, yet each app required a different process. Kix again was used for 99% of the code, with a few front-end BAT files to kick off the Kix process.
One of the reasons that Kix is so versatile (IMHO) is that it offers many admin-level features built-in, such as the ability to read, enumerate, and write the registry, read/write INI files, and has a wealth of pre-built add-on functions (UDFs). I have a fairly extensive UDF Library on my web site with about 180 UDF files and over 200 actual UDFs. The KGen utility (free download from my site) lets you use this library as if it were part of the core Kix package, automatically identifying and loading any required UDF into a finished script project. It also performs a "sanity check" to look for undeclared or duplicate declared vars, mismatched objects or command pairs, and other general syntax issues.

Of course, I also have a login script written in Kix, available for commercial use. Code free, has a GUI management tool, and it's FAST (usually completing even the most complex configurations in under 7 seconds).

Any questions - just ask, and we'll be happy to provide ideas and suggestions! (and don't forget to check out the Script Vault - click the Forums link above and scroll to the bottom of the page.)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#210236 - 2015-05-05 09:06 PM Re: Basic Scripting [Re: Glenn Barnas]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
Also don't forget to check out Kixforms. It's an add on .dll that allows for the creation of GUI elements. When combined with the powers of kix, it becomes possible to create entire user applications.
Top
#210237 - 2015-05-05 09:42 PM Re: Basic Scripting [Re: ShaneEP]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Kixforms is for GUI?? \:D

Well, I guess it is, but - the extensions it provides allows Kix scripts to be run as low impact system services (with SrvAny) via Timer or OnEvent operations, or even implement TCP/IP Socket communications between client and server. We worked on a System Interrogation Tool a while back that took about 90 seconds to perform about 30 WMI queries. Adding KixForms.DLL and writing a Sockets listener reduced that query to about 4 seconds!

Glenn

PS - http://www.kixforms.org is a site dedicated to KF. You can find a task scheduler manager GUI written in KiXtart/Kixforms on my web site.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#210238 - 2015-05-06 09:56 AM Re: Basic Scripting [Re: kevinj895]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Hi Kevin,

Like Glenn said, games can be practical at its own time and place. They will get you some time to relax but mostly, creating them will improve your scripting skills.

Kixtart was initially intended as a logon script processor but has grown beyond that since the first release.
We use it as a modular logon script that:
  • Sets printers (default and extra);
  • Maps drives;
  • Configures Outlook profiles and signatures;
  • Performs a periodic software inventory;
  • Sets various company default system settings;
  • Performs periodic maintenance tasks.


I have also developed some applications that help our marketing people getting their promotions out in the open (off course they also use other tools), our HR department to notify everyone involved when a new employee is hired or an employee is leaving, our logistics department to create CMR documents in fourfold (kind of shipping document here in The Netherlands) and my own department as a GUI for our asset database. More is coming so it is still very much alive in our company.

Languages like VBS and PowerShell are also able to do (most) of these tasks but I like the simplicity of kixtart and the way you can get things done with a relatively small amount of code. Kixforms is a great add-on to create a nice GUI to create applications that regular users can also use without having to work in the command window and without the need for them to understand kixtart. Kixforms does require the installation of an extra DLL on each system that will be running a script that uses kixforms. There are two flavors, classic and .net. I only use the .net version but that all depend on what you need and personal preference,

If you need any help, just create a post here and I’m sure we can help.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#210252 - 2015-05-11 10:05 PM Re: Basic Scripting [Re: Mart]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Games? Whut? Where?



Games are the best way to get used to a language ... well, I'm still playing sometimes with the language I loved first ;\)
_________________________



Top
#210258 - 2015-05-12 04:01 PM Re: Basic Scripting [Re: Jochen]
Anonymous
Unregistered


What I think I wanted to boil it down to actually is see if I can have the script check for Windows updates on logging into Windows, and also check to see if the script could also remove network printers. Printers that aren't actually on the network that aren't used anymore. I appreciate all the replies back, I've been so busy trying to read it all and go through all the UDFs and what not.
Top
#210259 - 2015-05-12 04:02 PM Re: Basic Scripting [Re: Anonymous]
Anonymous
Unregistered


And my profile is acting fuzzy, guess it just posted as anonymous, but I'm replying as kevinj895 lol
Top
#210260 - 2015-05-12 10:13 PM Re: Basic Scripting [Re: Anonymous]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
If you're looking for Windows Updates stuff, check my web site for the WUStools - there's a library of Kix UDFs that deal with Windows Updates - check update status, pending updates, even trigger an update process. There's a sample script that uses the library in the package. I have a package for my clients that uses an enhanced version of this script to schedule server updates within a precise change window.

Removing printers has been discussed quite a bit, getting the local list of installed printers and determining if they are still available. There's one important thing to remember about this - you'll be enumerating the registry to find the installed printers.. enumerate them all and then perform the checks and removals. If you check and remove one at a time, the enumeration process resets and you'll find every-other printer!

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#210262 - 2015-05-13 09:46 AM Re: Basic Scripting [Re: Anonymous]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Below is an example of how to check the printers and remove what is no longer needed/available. This is basically how we do it in our logon script. The code below is a bit simplified and some company specific stuff has been removed. We have most settings and lists in INI files (nice way to easily make changes without having to dig into the code) and have extensive logging for all steps just to see what goes wrong when something goes wrong but for a proof of concept this is not really needed imho.

 Code:
Break on

;Set available printers
$printers = "\\server\printer01;\\server\printer02;\\server\printer03"
;Split printers on ;
$printers = Split($printers, ";")

;Get all installed network printers.
;Set the key that should be enumerated.
$key = "HKCU\Printers\Connections"
;Enumerate network printers key.
$oldprinters = ArrayEnumKey($key)

;Do stuff for each value
For Each $value in $oldprinters
	;Split the value on the comma.
	$value = Split($value, ",")
	;Put the value back together so that is shows the correct path to the printer.
	$oldprinter = "\\" + $value[2] + "\" + $value[3]
	If AScan($printers, $oldprinter) = -1
		? $oldprinter + " is no longer available and will be removed."
		$rc = DelPrinterConnection($oldprinter)
	Else
		? $oldprinter + " is still available."
	EndIf
Next
Sleep 5

;===== The code below is a UDF. It is ready for use and does not need to be changed. =====
;
;NAME          ArrayEnumKey
;
;ACTION        Creates an array of names of the subkeys contained in a registry key or subkey
;
;AUTHOR        Jens Meyer (sealeopard@usa.net)
;
;VERSION       1.2 (added error codes)
;              1.1
;
;DATE CREATED  2001/12/05
;
;DATE MODIFIED 2003/05/17
;
;KIXTART       4.12+
;
;SYNTAX        ARRAYENUMKEY($subkey)
;
;PARAMETERS    SUBKEY
;              Required string containing the key or subkey for which the subkeys will be enumerated
;
;RETURNS       Array containing the subkeys
;
;REMARKS       none
;
;DEPENDENCIES  none
;
;EXAMPLE       $retcode=arrayenumkey('HKEY_USERS')
;
;KIXTART BBS   http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000064
;
Function arrayenumkey($regsubkey)
	Dim $retcode, $subkeycounter, $currentsubkey, $subkeyarray
	
	If Not KeyExist($regsubkey)
		Exit 87
	EndIf
	
	$subkeycounter = 0
	Do
		$currentsubkey = EnumKey($regsubkey, $subkeycounter)
		If Not @ERROR
			ReDim preserve $subkeyarray[$subkeycounter]
			$subkeyarray[$subkeycounter] = $currentsubkey
			$subkeycounter = $subkeycounter + 1
		EndIf
	Until @ERROR
	
	$arrayenumkey = $subkeyarray
	Exit 0
EndFunction
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#210268 - 2015-05-15 05:29 PM Re: Basic Scripting [Re: Mart]
kevinj895 Offline
Just in Town

Registered: 2015-05-04
Posts: 4
Loc: Ohio, USA
Glenn - Trying to download your WUS toolkit and I keep getting a lot of the "500 - Internal server error."

Mart - Thanks, I'll look into that script and see what I can use. The company right now that handles our script said something like that could not be done so we obviously wanted to explore and see if it could. Thanks.

Top
#210269 - 2015-05-15 10:27 PM Re: Basic Scripting [Re: kevinj895]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Kevin - the site is operational now. I'm monitoring the site root but not the old ASP-based sub-site that has the library stuff.. it ran out of resources and hung. Sorry about that!

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#210270 - 2015-05-16 11:33 PM Re: Basic Scripting [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Were you ever able to make a zip of the free files to make it easier to download without all the tab and other html stuff Glenn?
Top
#210271 - 2015-05-18 10:15 AM Re: Basic Scripting [Re: kevinj895]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
 Originally Posted By: kevinj895

....
The company right now that handles our script said something like that could not be done so we obviously wanted to explore and see if it could. Thanks.


I'm sorry but then they do not know how or do not want do do it. The example below shows that is is possible. We have been using it like this for many years now.


Edited by Mart (2015-05-18 10:15 AM)
Edit Reason: Typo.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#210279 - 2015-05-20 02:42 PM Re: Basic Scripting [Re: Mart]
kevinj895 Offline
Just in Town

Registered: 2015-05-04
Posts: 4
Loc: Ohio, USA
Download links still do not work just an FYI.
Top
#210301 - 2015-05-28 03:06 PM Re: Basic Scripting [Re: kevinj895]
kevinj895 Offline
Just in Town

Registered: 2015-05-04
Posts: 4
Loc: Ohio, USA
Glenn,

Is there any way you could provide me with your script(s) that check for Windows updates? Thanks

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 382 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.074 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org