Page 1 of 1 1
Topic Options
#172264 - 2006-12-31 08:17 PM tcdefinetrigger() help
itdaddy Offline
Starting to like KiXtart

Registered: 2006-12-19
Posts: 145
Loc: Wisconsin
hey kix gurus,

how do use the tcdefinetrigger(). what i mean is i know what parameters to
enter into the function. I just want to disable only (remove the enable checkbox; where is says "scheduled task runs at a specific time")
what process do i need to go through to disable only the task i want on my network?

I have 100 workstations with a task that I want to disable instead of
remoting into each one and doing it manually. it would be nice to use
a foreach loop and disable them all one by one with an array.
but i dont know how to get the function i need to work?
am i making this harder than it seems?
thanks!
ps. i am using Glenn Barnas's great and awesome! tcLib()!!
_________________________
Robert
A+, CCNA, MCP
Network Admin
Credit Union Wisconsin

Top
#172296 - 2007-01-02 03:31 AM Re: tcdefinetrigger() help [Re: itdaddy]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Actually, I think what you really want is the SUSpend option, which disables the event, not just one trigger.

Here's an example to disable any task called "BadTask". You could just as easily check the executable, user ID, or whatever.. We changed the password on the task scheduling account and had to locate every task that used that account on every server (300+) and change the credentials. Took a few minutes to complete.

You need to wrap this into your own code to read the computer names from a file or AD or somewhere...
Code:
; This is in a loop, which enumerates all your 
; remote computers in the variable $Target

  tcInit(1)

  ; just suspend a specific task event
  $Task = "BadTask"
  tcGetEvent($Target, $Task)  ; load the bad task data
  tcDefineTask("SUS=1")       ; set it to Suspend (disable)
  tcSetEvent($Target, $Task)  ; update the task on the target


  ; alternative code, looks at each task for a command name (or other setting)
  ; if the command contains "xyzzy.exe", the task is suspended

  $TaskList = tcGetTasks($Target)
  For Each $Task in $TaskList
    tcGetEvent($Target, $Task)    ; load the task data
    If InStr($a_tcTask[0], "xyzzy.exe")
      tcDefineTask("SUS=1")       ; set it to Suspend (disable)
      tcSetEvent($Target, $Task)  ; update the task on the target
    EndIf
  Next



Read the first section of the manual - it defines the difference between tasks and triggers. An "event" consists of one "task" (what to do) and up to 10 "triggers" (when to do it). It's more likely that you want to disable the task (which disables all triggers!) and not just a trigger.

Unfortunately, the "Suspend" mnemonic isn't as clear as "Disable" could be, but it's Microsoft's code in JT.exe.

Also, be sure to use tcInit(1), which sets the array to nulls, before each read you do. Be sure to READ the event into the array, then use tcDefineT**** to UPDATE the array, so you can write it back. the tcDefineT*** UDFs only manipulate the array - you must first tcGetEvent() to load the array before updating it and writing it back with tcSetEvent().

You probably should also use a tcDefineTask("PWD=xxxxx") to properly set the password before you write the task back. I believe the password is required to perform any updates.

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

Top
#172297 - 2007-01-02 07:40 AM Re: tcdefinetrigger() help [Re: Glenn Barnas]
itdaddy Offline
Starting to like KiXtart

Registered: 2006-12-19
Posts: 145
Loc: Wisconsin
Glenn

sweet! just what I need!...wow! your stuff is awesome!
I will when I am done try to explain what I did (problem and solution) Even though it is nothing like what you have done. For a novice like me, it has revolutionized the way we install one of our programs. And I am getting my feet wet in scripting. We had to opt
out of GPO installs due to the fact it has to be a 'sure thing' to install.
And GPO installs to me are not a sure thing somethings; our financial
software needs to be a sure thing the next business day or no business.
Not at logon can we afford the install! So that is why I had to come up with my own customized batch/DOS/kix script install. And it works like a dream! During the day it copies the files need to run a setup.exe with and /s switch to each workstation (only 100 of them) and the at 545pm
I launch batch/kix file to run the task on all workstations and set some permissions using CACLS command line and walla! done in 5 minutes! the install that is on all workstation simultaneously it seems! We use to
remote into each workstation taking 3 hours (only 100 PCs) the both of us my boss and I. And I thought one day while using scripts, gee why dont I make a big script that does all the work for us? Cause what are we doing?
Basic copying, executing programs that is what scripting is for. My boss
is amazed something that took 3 hours onlys take 5 minutes! It just tooks some time and the division of labor! AND BAM! once my coding is done I will post what I did and explain it. even though it is simple it is powerful. The power of batch and scripts! Problem / Solutions!

Thanks so much for your patience and guidance(I did mean you are a genius!)
It shows man! Freaking awesome! My boss laughs every time he has to uptdate workstation forms. He just copies the mdb files to the copy directory I made and execute my kix prgram. bam files copied done!
Then I we have a scheduled shut down script I made using psshutdown and shutdown (xp style) to run an array and the command with switches to shut off any left on Workstations. though no disrespect to your task schedular.
just looking over what you did with the task schedular like you said you did and run a shutdown on each workstation is the same as what I did but
mine is just using the structure and commands given. You on the other hand
reinvented the wheel and turned it into a Crager Mag! way way cooler than an boring old wheel! took much more genius an much more imagination. I can appreciate thinking like that. That is why I love this scripting stuff.
It really shows genius! Taking something difficult and creating something simple! yeah! KIX! thanks glenn will keep in touch!
And this last bit should do the trick!
_________________________
Robert
A+, CCNA, MCP
Network Admin
Credit Union Wisconsin

Top
#172298 - 2007-01-02 09:42 AM Re: tcdefinetrigger() help [Re: itdaddy]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol. talk about customer well served.
_________________________
!

download KiXnet

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
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.05 seconds in which 0.022 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