Page 1 of 1 1
Topic Options
#196455 - 2009-10-22 07:49 PM Restarting Kix script upon widows restart
Georges_K Offline
Getting the hang of it

Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
well, I'm glad to have you guys here, because at least I know I have someone to fall back on when I'm stuck ... guess what.. I'm stuck!! \:\)

I've been recently writing a series of small projects, which will hopefully get all bundled together, for my school district, so that I fully automate the setup of lab machines, and others.

In order to do this, I'm dealing with a lot of script tracking upon reboots , to track which reboot I'm at, and what tasks need to be done, and when to do the cleanup after the work has been done.

I'm using AdminScriptEditor, and am bundling the scripts that contain elevated privilege account in EXE files.
The problem I'm having is that I am not able to get these scripts to run upon reboot. I have tried 3 methods:
1- on the initial script, I make a copy of that script to the Documents and settings\All Users\Start Menu\Programs\Startup, hoping that it would run -- that's a no go. nothing happens on the reboot.

2- Tried to place the path to the script in HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce. That seems to run, only once, upon reboot, my script runs again, and it re-places the entry in the RunOnce key, but yet, nothing runs on subsequent reboots.

3- Tried to place the path to the script in HKLM\Software\Microsoft\Windows\CurrentVersion\Run. That apparently just starts the exe as a process, but doesn't really execute it. (I had even tried to place the /d parameter when compiling it), just to make sure I'm not missing it running, also tried without /d.

I know that the script runs, because if I just run the exe manually, it seems to do what it's supposed to, but manually isn't enough, as it's part of an automated setup process.

Has any of you seen this problem with Windows? or is this something specifically with Kix files? I still haven't tried to write a batch file and trigger the KIX script straight from the source code, instead of the compiled exe. would that be worth a try? or am I missing something blatantly obvious?

Sorry for the long post, I'm hoping to be able to find some answers to this.

Thanks in advance for your help !
_________________________
Network Specialist
Chino Unified School District

Top
#196457 - 2009-10-22 08:29 PM Re: Restarting Kix script upon widows restart [Re: Georges_K]
Georges_K Offline
Getting the hang of it

Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
ok guys, so just quick update. It looks like the problem is really with compiling the exe.
only when the script is an EXE, does it hang as a process upon start, but never really does anything.

I tried to trigger the same script by pointing to the Kix file directly: c:\windows\kix32 c:\kix\modreg.kix , and that worked like a charm.

Though that narrows down the problem, it still doesn't solve it. Any ideas?
_________________________
Network Specialist
Chino Unified School District

Top
#196459 - 2009-10-23 12:38 AM Re: Restarting Kix script upon widows restart [Re: Georges_K]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
I have a script that interfaces with WSUS - called WUS.KIX. You can download the WSUS Library package from my web site. You'll also need to download the tcLib package for scheduled task management..

Review the WUS.KIX script - you'll learn how to use the task control library to create a scheduled task to run "At Startup" using specific credentials. It works quite well.. We use the WUS script to precisely schedule the installation of WSUS-based updates to our servers. The script creates a restart task, runs updates, reboots, then repeatedly downloads & installs updates, rebooting after each set of updates. When no more updates are installed, or the last set of updates does not require a reboot, the "At Startup" task is removed.

We're about to publish an update to this tool in a few weeks, but the current code will provide enough ideas for you to do what you need. I have another tool that "wakes up" and checks for software install requests, allowing us to schedule updates and installs on our servers without intervention - it uses similar logic to install software and continue after repeated reboots.

The concept of using runas or other tools for elevated rights management is dodgy at best. Using a scheduled task is easy to implement (4 lines of code using tcLib.UDF and JT.exe) and allows great flexibility in how it is run, when it runs, and what account is used to run it. It can be managed locally or remotely, as well. I'm about a week away from publishing a tool that will allow a non-admin user to run a script that checks for a set of circumstances and requests that a task requiring admin rights be run - it is scheduled and run within seconds, without ever exposing the admin tool to the user - all via scheduled tasks. Powerful! I strongly recommend you check it out.

Glenn

PS - the tcLib UDF can be downloaded from the resource pages on my web site. You will need to register to download the WSUS Library, and you can download the complete Task Control library as well, which includes the JT.exe, sample code, the tcLib library, and full documentation.
_________________________
Actually I am a Rocket Scientist! \:D

Top
#196461 - 2009-10-23 05:04 AM Re: Restarting Kix script upon widows restart [Re: Glenn Barnas]
Georges_K Offline
Getting the hang of it

Registered: 2005-02-17
Posts: 83
Loc: Chino, CA
Wow. Thanks so much Glenn! This sounds like a pretty powerful tool you created. I'm definitely going to check it out.
At this point, I don't have a WSUS server, so I'm not sure how I'll use it in that context. I currently run LANDesk for path management and windows updates, so I'm ok in that arena.

The scripts I'm writing are very specific to actually setup a machine for a new user automatically (joining to the domain, installing our tools, setting up outlook profile, printers, etc...) ... LANDesk doesn't quite go that far, as powerful as might be \:\)

The libraries that you created sound like they would be quite helpful in what I'm trying to do. For this particular case, I actually managed to get things to work exactly like I want them. (for some reason, the Run key in the registry doesn't like running Kix scripts...), so I'm placing the file temporarily in the Startup menu, and deleting it once the number of reboots required is met (as well as do a bunch of additional cleanup.)

I'll go check your website now...

Thanks again!
_________________________
Network Specialist
Chino Unified School District

Top
#196464 - 2009-10-23 10:03 AM Re: Restarting Kix script upon widows restart [Re: Georges_K]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I've got an series of KiXtart scripts which I use to do an unattended bare metal build of our Citrix servers including operating system, Citrix and all the applications.

They're quite complex and contain proprietary information so I can't post the lot.

If you'd like the main controlling script to look at the techniques I use for things like restarts then I should be able to sanitise it - let me know if you are interested.

Top
#196465 - 2009-10-23 11:52 AM Re: Restarting Kix script upon widows restart [Re: Georges_K]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Georges

You don't need a WSUS server - I just meant that the WUS.KIX script in my WSUS library uses the same technology that you're trying to accomplish.. it needs to run a process using specific credentials through multiple reboots.

The key is the tcLib library and JT.exe, which allow a simple method for creating, updating, and deleting scheduled tasks. The WUS script shows how to initialize the library, create the task, and then - when the process is complete - remove the task. You could probably "steal" those lines of code and use them directly in your script.

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

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 1607 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.059 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