itdaddy
(Starting to like KiXtart)
2006-12-20 06:03 PM
@error handling? and redirection to a text file (append)

Hey kix gurus;
i made this program below all works but i cant do the @error very well.
i dont understand how i can through conditions (see commented out)
how to send the PCname which is $Element (local scope variable)
to its specific failure.txt or success.txt file to
be able to look at the next day on which connections failed and succeeded?
can anyone help me.?
thank you



_______________________________________________________
$FourthAveArray = "ftran1", "ftran2", "ftran3"

For Each $Element In $FourthAveArray


Shell "net use z: \\" + $Element + "\c$"
;if connection error, push pcname to failure.txt
;else if no error push pcname to success.txt
Shell "CMD.EXE /C copy c:\fspcopy\*.mdb z:\fsp\mdb /y"
Shell "CMD.EXE /C time /t"
Shell "net use z: /delete"


Next
_________________________________________________________


Benny69
(MM club member)
2006-12-20 06:16 PM
Re: @error handling? and redirection to a text file (append)

Hi ITDaddy, and welcome to the board.

You should place your code between code tags.

Is the code you are posting part of a logon script or is it part of a utility?

The reason I ask is because if this is a logon script there would be not reason to loop thru all your PC's and you could use the @WKSTA macro to retrieve the PC name.

If this is part of a utility to look at each PC, it will be hard to find out if it had trouble logging in or whatever.

It might be best if you post your entire code so that we can better help you.


**DONOTDELETE**
(Lurker)
2006-12-20 07:35 PM
Re: @error handling? and redirection to a text file (append)

Hey benny69
thanks! i tried to look for quotes are the image tags here the same as quotes
where are they?? the buttons i mean? thanks

"Is the code you are posting part of a logon script or is it part of a utility?"

No; it is a program executed from a batch file like kix32 filename.kix.
I run it on a server through the schedular.
reason being is we run it at night while all workstations are on.
It is for copying some mdb files to workstations. user dink around
while they are downloading these and they get corrupt so we leave
PCs on and run on schedule at night and we want to see which ones fail
and which ones succeed thus the two txt files redirected to.
I made a program in DOS batch that works with ERRORLEVEL just fine
but it is hard to loop through arrays in DOS; i cant find how to do arrays in DOS? nicely! heheeee. Everything works great but i dont know how to redirector PC name to each file upon conditon met. The kicker is
it creates the mapped drive from one admin server thus the /delete
switch so i can go to each pc with mapped drive. i need to do it this way due to after hours.

not logging on i need a failure to connect error like error 53 or 67
in dos i heard in kix if the mapped command fails @Error is set to non zero which is fail? this is the entire code minus the batch file that kix it off. thanks



The reason I ask is because if this is a logon script there would be not reason to loop thru all your PC's and you could use the @WKSTA macro to retrieve the PC name.

If this is part of a utility to look at each PC, it will be hard to find out if it had trouble logging in or whatever.

It might be best if you post your entire code so that we can better help you.


Les
(KiX Master)
2006-12-20 07:43 PM
Re: @error handling? and redirection to a text file (append)

Wazzup with the duaal personality idaddy/itdaddy?

At the top of the edit window are a bunch of squares with icons. If you hover your mouse over them you should get tooltips. the double curly quotes ["] one gives you quote tags, the pound [#] code tags.


Benny69
(MM club member)
2006-12-20 09:33 PM
Re: @error handling? and redirection to a text file (append)

I would still like to see your script, but rather than looking for an @Error i would suggest you use something like Ping().

**DONOTDELETE**
(Lurker)
2006-12-20 09:43 PM
Re: @error handling? and redirection to a text file (append)

Hey thanks

but when i first registered it would not let me
and then it said there was another itdaddy but when i looked
there was an idaddy; big diff....i am itdaddy..like whose your IT Daddy
and i dont know who is idaddy? there are no searches for anything that guy.
but please keep me as ITDADDY like my icon/avatar!
thanks

hey any tips on my question?S
thank les
love your avatar that is funny $h$$


**DONOTDELETE**
(Lurker)
2006-12-20 09:51 PM
Re: @error handling? and redirection to a text file (append)

Quote:

FourthAveArray = "ftran1", "ftran2", "ftran3"

For Each $Element In $FourthAveArray


Shell "net use z: \\" + $Element + "\c$"
;if connection error, push pcname to failure.txt
;else if no error push pcname to success.txt
Shell "CMD.EXE /C copy c:\fspcopy\*.mdb z:\fsp\mdb /y"
Shell "CMD.EXE /C time /t"
Shell "net use z: /delete"


Next


benny69 this is my coding!
except the lines commented out.

it loops until array is empty and
at each loop it runs shell commands (or dos commands)
like this:
maps drive z
copies mdb files
removed mapped drive
loop back and do for next pcname
get it


Benny69
(MM club member)
2006-12-20 09:55 PM
Re: @error handling? and redirection to a text file (append)

look an the linky i posted, i think that it is what you are wanting. it will allow you to try to connect to the pc and will give back an error if it can not.

NTDOCAdministrator
(KiX Master)
2006-12-20 10:37 PM
Re: @error handling? and redirection to a text file (append)

Well you tell me what's going on. I changed your Display name to ITDADDY as it shows in the very top post here.

But now it shows you posting as IDADDY so I would assume both accounts are yours, or you sure can imitate the other one pretty good.



Quote:
Profile for idaddy
Member #: 9764
Title: stranger
Total Posts: 4
Registered on: 02/14/06 07:06 AM
vandyker@becu.net


Profile for itdaddy
Picture
Member #: 11768
Title: stranger
Total Posts: 2
Registered on: Yesterday at 07:09 AM
vandyker@charter.net



.


NTDOCAdministrator
(KiX Master)
2006-12-20 10:41 PM
Re: @error handling? and redirection to a text file (append)

As for posting and editing of your posts it should be pretty easy, but for those that need a visual.




.


**DONOTDELETE**
(Lurker)
2006-12-20 10:42 PM
Re: @error handling? and redirection to a text file (append)

you are right maybe some how i messed up when i first registered?
delete idaddy
keep itdaddy; sorry for about the mess up ! i am half blind and maybe i messed up; it looks like i messed up; thanks
sorry


**DONOTDELETE**
(Lurker)
2006-12-20 10:44 PM
Re: @error handling? and redirection to a text file (append)

yes they are both mine becu is my work and charter is my home
delete idaddy yeah that is me; i must have some how register from work and home
sorry just keep itdaddy at the charter.net
thanks sorry for bing a cluts!
my bad!


NTDOCAdministrator
(KiX Master)
2006-12-20 10:44 PM
Re: @error handling? and redirection to a text file (append)

And GONE it is.

itdaddy
(Starting to like KiXtart)
2006-12-20 11:21 PM
Re: @error handling? and redirection to a text file (append)

Code:
$FourthAveArray = "ftran1", "ftran2", "ftran3"

Global $Element

For Each $Element In $FourthAveArray
         
	 
         Shell "net use z: \\" + $Element + "\c$"  
      	 IF @ERROR <> 0
	    REDIRECTOUTPUT (failure.txt, 0)
	    ? $Element
	 Endif     
	
	 ;Shell "CMD.EXE /C copy c:\fspcopy\*.mdb z:\fsp\mdb /y"
	 Shell "CMD.EXE /C time /t"
	 Shell "net use z: /delete"
	 

Next


NTDOC and benny69 sorry for being so blind; i dont see very well
i have glasses and and my fonts are big so sometimes i mess up;

but benny69 here is my code that works; i finally go it to append my failure.txt file; that ping() code was nice but way to complex for me as a beginner but this code puts @Error <> 0 into failure.txt and I will add
30 more computers in my array and give her a final test but i think she is ready; simple yet powerful enough to keep my boss home while this copies mdb files to each pc in the domain effortlessly and keep track of failure to connect network mappings
yeah! merry christmas t you all
robert;D


itdaddy
(Starting to like KiXtart)
2006-12-20 11:21 PM
Re: @error handling? and redirection to a text file (append)

Code:
$FourthAveArray = "ftran1", "ftran2", "ftran3"

Global $Element

For Each $Element In $FourthAveArray
         
	 
         Shell "net use z: \\" + $Element + "\c$"  
      	 IF @ERROR <> 0
	    REDIRECTOUTPUT (failure.txt, 0)
	    ? $Element
	 Endif     
	
	 Shell "CMD.EXE /C copy c:\fspcopy\*.mdb z:\fsp\mdb /y"
	 Shell "CMD.EXE /C time /t"
	 Shell "net use z: /delete"
	 

Next


NTDOC and benny69 sorry for being so blind; i dont see very well
i have glasses and and my fonts are big so sometimes i mess up;

but benny69 here is my code that works; i finally go it to append my failure.txt file; that ping() code was nice but way to complex for me as a beginner but this code puts @Error <> 0 into failure.txt and I will add
30 more computers in my array and give her a final test but i think she is ready; simple yet powerful enough to keep my boss home while this copies mdb files to each pc in the domain effortlessly and keep track of failure to connect network mappings
yeah! merry christmas t you all
robert;D


Witto
(MM club member)
2006-12-21 01:36 AM
Re: @error handling? and redirection to a text file (append)

Why do you Shell for things that can be native KiXtart?
Why map to Z: if yo can also copy to an UNC style path?
Code:
If NOT @LOGONMODE
	Break On
EndIf
Dim $FourthAveArray, $Element
$FourthAveArray = "ftran1", "ftran2", "ftran3"
For Each $Element In $FourthAveArray
	Copy "C:\fspcopy\*.mdb" "\\" + $Element + "\c$\fsp\mdb" /c /h /r
	;? @TIME ;Why display the time?
Next


itdaddy
(Starting to like KiXtart)
2006-12-21 02:52 AM
Re: @error handling? and redirection to a text file (append)

Code:
 If NOT @LOGONMODE
	Break On
EndIf
Dim $FourthAveArray, $Element
$FourthAveArray = "ftran1", "ftran2", "ftran3"
For Each $Element In $FourthAveArray
	Copy "C:\fspcopy\*.mdb" "\\" + $Element + "\c$\fsp\mdb" /c /h /r
	;? @TIME ;Why display the time?
Next


Hi witto

not sure what the IF NOT @LOGONMODE if statement is for?
but i really like your copy/map line of code; i will try that on
my code i sent in. if it maps a drive and then deletes the mapped drive does it? is that what the /c/h/r switches are for is any a drive letter?
i need it to map a drive and then delete it? is that what it does? your code that is? the reason i need it to show time; is i want to see how long it takes to copy to each workstation. but i will try you copy/map line
but it has to create map drive and the delete it for the next pc in the array. and i want it to post all error<>0 items(pcnames) to the text file failure.txt
thanks witto

ps. i am not logging on to these workstations; that is why it is not a logon script; it is a script that is scheduled to run off of a member server that has Domain Admin rights; i made this program so my boss doesnt stay late and have to manaully copy these mdb files to all 100 workstations
it just does it iself and keeps track of the failed network mappings (hopefully indicating the PC is off) so the next day my boss can review and manually update only a few vs 100 pcs. trying to get brownie points using my scripting skills;D


ps. i am just learning kix and i am limited but know how dos works.
;D thanks for teaching me your art!
itdaddy;D


Gargoyle
(MM club member)
2006-12-21 04:21 AM
Re: @error handling? and redirection to a text file (append)

Why are you mapping to drives at all?

If you are member of the local machines admin group (And if you are running in an AD enviroment and are a Domain Admin you are automatically one), you can just copy the file directly via UNC No mapping required. The @error will tell you if was successful or not and generally why (use @Serror)

Code:
$Time = @msec
copy c:\fscopy\*.mdb "\\"+$element+"\c$\fsp\mdb" /c /h /r
If not @error
  ;Write error to logfile
EndIf
$Time = @msec - $time
;Now you have exactly how long it took


NTDOCAdministrator
(KiX Master)
2006-12-21 05:56 AM
Re: @error handling? and redirection to a text file (append)

If these are mdb files why not just share them from one location?

Even Access can handle up to about 250 users (though not very fast).


itdaddy
(Starting to like KiXtart)
2006-12-21 06:47 AM
Re: @error handling? and redirection to a text file (append)

NTDOC

yeah, i am worried about speed though that is a smart idea!

Gargoyle, nice coding; duh on my part..i guess you can UNC it
it will probably run alot faster...and less code..
and the time calc nice! i will use them and let you know.
you guys are awesome. i love kix!


Witto
(MM club member)
2006-12-21 10:09 AM
Re: @error handling? and redirection to a text file (append)

You should read the kix2010.doc included in the KiX2010_453.zip package. It explains "Break", "@LOGONMODE" and all the switches used with "Copy".
Important to know is that in KiXtart, "Break" is per default "Off". This means that when you break a script, p.e. via Task Manager, your computer gets logged of. We (at least I) just presume this is wanted behaviour during Windows Logon.


itdaddy
(Starting to like KiXtart)
2006-12-21 04:44 PM
Re: @error handling? and redirection to a text file (append)

witto

thanks for all your help!

maybe witto really means "dude who is witty!" haahah
thanks again. i am going to try my new code tonight.
see you guys later.D


itdaddy
(Starting to like KiXtart)
2006-12-21 05:56 PM
Re: @error handling? and redirection to a text file (append)

Code:
$FourthAveArray = "ftran1", "ftran2", "ftran3", "SPARE", 
"FACCTG8", "FACCTG1", "FACCTG2"


For Each $Element In $FourthAveArray
          
         
      	 $Time = @msec
	 copy c:\fspcopy\*.mdb "\\"+$Element+"\c$\fsp\mdb" /c /r
	 IF @ERROR <> 0
	    REDIRECTOUTPUT (failure.txt, 0)
	    ? $Element
	 Endif     
 	 $Time = @msec - $Time

	 
	 
	 
	 
	 ;Shell "net use z: \\" + $Element + "\c$"  
	 ;Shell "CMD.EXE /C copy c:\fspcopy\*.mdb z:\fsp\mdb /y"
	 ;Shell "CMD.EXE /C time /t"
	 ;Shell "net use z: /delete"
	 

Next


okay witto

what am i doing wrong i added your code and commented mine out
it wont run? did i type something wrong?
help


Glenn BarnasAdministrator
(KiX Supporter)
2006-12-21 06:47 PM
Re: @error handling? and redirection to a text file (append)

My thoughts...

Code:
; initialize array of computer names
$FourthAveArray = "ftran1", "ftran2", "ftran3", "SPARE", "FACCTG8", "FACCTG1", "FACCTG2"

; enumerate the array
For Each $Element In $FourthAveArray
          
         ; Get the current millisecond count - not good as this is the MSec portion of the current minute
      	 ; $Time = @msec

         ; Get the current millisecond count - not good as this is the MSec portion of the current minute
      	 $Time = @TICKS

	; copy the source to dest - quotes were missing
	 ; copy c:\fspcopy\*.mdb "\\"+$Element+"\c$\fsp\mdb" /c /r

        ; with quotes, and spaces to improve readability - will still fail because "\c$\..." is
	; interpreted as a variable "$", which isn't defined. The strings is interpreted as
	; "\c\fsp...", which is not valid
	; copy "c:\fspcopy\*.mdb" "\\" + $Element + "\c$\fsp\mdb" /c /r


	; corrected copy string - better would be to use Chr(36), or SetOption("NoVarsInStrings", "On")
	copy "c:\fspcopy\*.mdb" "\\" + $Element + "\c$$\fsp\mdb" /c /r

	 IF @ERROR <> 0
	; best practice - enclose string in quotes - "append" is the default - not needed
	; also - capture the return codes, and close the redirection
	;    REDIRECTOUTPUT (failure.txt, 0)
	    $RC=RedirectOutput('failure.txt')
	; "?" is not a print statement - it's a CR/LF.. should come AFTER the message
	;    ? $Element
	    $Element ' - ' @SERROR ?
	    $RC=RedirectOutput('')
	 Endif     
	; get elapsed time for this process - corrected to use TICKS
 	 $Time = @TICKS - $Time


Next


Glenn


Les
(KiX Master)
2006-12-21 07:24 PM
Re: @error handling? and redirection to a text file (append)

Originally Posted By: itdaddy
did i type something wrong?

You failed to wrap the string that is the first parm in quotes.

copy 'c:\fspcopy\*.mdb' '...


Glenn BarnasAdministrator
(KiX Supporter)
2006-12-21 07:41 PM
Re: @error handling? and redirection to a text file (append)

The bigger problem is use of "$" in a string, without NoVarsInStrings, or doubling of the "$". As we saw earlier this week, Doc showed that simple strings would work without quotes.. With the unescaped "$" in the string, it is mis-interpreted and the path will never be found.

An @SERROR should prolly be written to the error log so you know WHY it failed, no just WHERE.

Glenn


itdaddy
(Starting to like KiXtart)
2006-12-21 08:37 PM
Re: @error handling? and redirection to a text file (append)

Glenn and Les

thanks for the help. i think i get it.
1. missing quotes
2. root of C: is looked at like it was variable
escape it out you instruct me; cool!
3. add the @SERROR to find specific error

right?
i will try these and see how it works.
thanks
;D
you guys are awesome


Les
(KiX Master)
2006-12-21 09:48 PM
Re: @error handling? and redirection to a text file (append)

Originally Posted By: Glenn Barnas
The bigger problem is use of "$" in a string


I dunno... the unquoted string would surely bring KiX to its knees as it tries to use the * operator on the first parm. Why does everyone think quotes are optional???


Glenn BarnasAdministrator
(KiX Supporter)
2006-12-21 10:46 PM
Re: @error handling? and redirection to a text file (append)

I never think quotes are optional (except - MAYBE - while golfing, but even that gives me the willies), but Doc just mentioned that unquoted strings usually work - that's all. Quoting the string is absolutely correct, and in my opinion, necessary.

For ITDaddy's benefit -

The "$" is the variable indicator in Kix - everything that follows it, letters, numbers, and some characters - forms a variable name. The "$" by itself is a legal variable name, often used as a "throw-away" var to catch return codes that aren't needed.

The process of converting variable names to their contents is called "variable expansion", and it - by default - occurs inside of strings. Most of us have decided that this is NOT a good thing, specifically for what you are experiencing here. You actually WANT a "$" inside the string, and not the content of a variable.

One way to do it is to "escape" the "$" by doubling it - Kix ignores variable expansion when it sees "$$" and simply puts a single "$" in its place. OK for "quick-n-dirty" scripts, but not for scripts that will see long-term use, or more advanced scripts.

A second form is the use of Chr(36), which is the "$" char. This always works, but is less obvious when debugging, or reading someone else's code.

What's preferred, and what you'll see in most of our scripts, is the command
$RC = SetOption('NoVarsInStrings', 'On')
This tells Kix to ingore the "$" inside of quoted strings (another reason ALL strings should be quoted). This is placed at the beginning of the script. Doing this will prevent any confusion of the "\\server\c$\folder" form of UNC paths.

There are other SetOption values that most of us use, and they force better programming habits by making you declare your vars before use and things like that. Get familiar with the basics of Kix first, then try turning on "Explicit" and see if you declared all your vars..

Glenn


Witto
(MM club member)
2006-12-22 12:02 AM
Re: @error handling? and redirection to a text file (append)

Glenn,
AFAIK, C$ is interpreted as C$, and not as a variable, even when the option "NoVarsInStrings" is "Off". The difference is the $ at the end.
Code:
Break On
Dim $RC
$RC = Dir("\\"+@WKSTA+"\C$\*")
While $RC <> "" AND @ERROR = 0
	? $RC
	$RC = Dir()
Loop

But I also prefer to set "NoVarsInStrings" to "On".


itdaddy
(Starting to like KiXtart)
2006-12-22 12:48 AM
Re: @error handling? and redirection to a text file (append)

glenn
wow! spoken like a real teacher. very well said.
man you write really clear!

i understand. but my script Kitty (not kiddy; since i play with already built scripts and learn some code hee hee!) attempts worked
to do what i need it to do. but i am just learning kix
and have a faint history of learning programming some basic C++ some Fortran, some BASIC, and javascript. i am not a programmer by any means
but i like to play with scripts to learn for my job. and the scripts i have made have always worked. but this forum rocks!
and i do enjoy kix very much..
I am glad I have you dudes around!

Witto thanks to you to for your inputs!


hey glenn seeing your rocket buff you are
did you see on the TV some time ago those rocket buffs
were attempting to build the biggest hobbiest rocket (forgive my bad typing please) ever built and it flopped and then someone build a much smaller but still big rocket and it was so cool watching it blast off; i can see myself do that. cool! are you one of those guys going to build the biggest rockect every for a hobbiest! gosh they said combined it cost like 10,000 USD
and it was cool see the computer chips and modules on the rocket;
do you do that; i bet you program them yourself dont you.
thanks so much;
;D



NTDOCAdministrator
(KiX Master)
2006-12-22 01:49 AM
Re: @error handling? and redirection to a text file (append)

Quote:
but Doc just mentioned that unquoted strings usually work


Not exactly what I said there Glenn, but close.

It would appear that SINGLE Unbroken strings for VARS is able to omit the quotes. I don't think that it should, but it does work and has since 3.6x so fixing it might break other stuff or current scripts.

Normal STRINGS still REQUIRE quotes or will potentially abend or at least alter the expected outcome of the script.


@ITDADDY
Yeah, Glenn is really good at code commenting, better than anyone else I've personally worked with before. He also goes out of his way to try to explain the code for those interested.


.


Glenn BarnasAdministrator
(KiX Supporter)
2006-12-22 01:53 PM
Re: @error handling? and redirection to a text file (append)

Hmm - you are right.. although I seem to recall this being a problem in earlier versions (maybe 10+ years ago in the 16b version?) ;\)

Or maybe I'm just thinking of other languages where it is a problem. Still, it's best not to use Var_ID chars in strings. It won't be a problem in this specific example, but consider something like
Code:
$e=4
"C$e" ?

which produces C4 - a potentially explosive result. Just because a letter preceeds the "$" doesn't mean it won't get interpreted.

I have a picture hanging in my office - a guy using his laptop at a funeral. The caption says "just because you CAN doesn't mean you SHOULD!" Outside of KixGolf, it's a good rule for programming.

ITDaddy: I may come across like a teacher because it's hard to shake 15+ years teaching IT subjects, including Unix and MCSE. As for rocketry, it's a blast, but no where near that expensive. The average rocket costs about $200 to build (parts/paint/epoxy), and flies with a $100 flight computer (records altitude and speed, fires 2 ejection charges for parachute deployment), and my larger rockets sometimes use a $600 avionics package that transmits real-time flight telemetry, including speed, altitude, and GPS location. The motors cost between $30 and $150. All of these costs are one-time purchases of reusable items. Fuel for the motors can run between $2 and $200 per flight for the rockets that I fly, although there are larger rockets that are much more expensive to build and fly. I build in the winter and fly in the summer, rarely spend more than an average of $200/month on the hobby.

Glenn


itdaddy
(Starting to like KiXtart)
2006-12-22 09:17 PM
Re: @error handling? and redirection to a text file (append)

Glenn

thanks about the rocket stuff

NTDOC and Glenn

I know this is not a kix thing or maybe could be.
but is there a command line that can turn on and off job schedule?
not AT commands but say i have a job scheduled already but want say a program run by jobscheduler to execute the final command (pseudo code: shut self off)
is there??

thanks dudes!


Les
(KiX Master)
2006-12-22 09:29 PM
Re: @error handling? and redirection to a text file (append)

Do you mean like NET STOP the task scheduler? Why not?

itdaddy
(Starting to like KiXtart)
2006-12-22 10:06 PM
Re: @error handling? and redirection to a text file (append)

les
explain NET STOP will stop job schedular in windows
say a job i called FSPcopy.job??

can i start and stop job with NET STOP and is there a START?


====================================
Hey guys; hope this dont offend anyone but i dabble alittle in perl
and found this cool perl script we use for our mobile laptop to different
subnets;when our trainer goes from site to site she just clicks
on a separate batch i mad and walla new TCP setting to hook up to localized network; works slick as snot;enjoy!
Perl script that changes TCP gateway ip and dns by batch file


NTDOCAdministrator
(KiX Master)
2006-12-22 10:46 PM
Re: @error handling? and redirection to a text file (append)

No but Glenn has a slick tool for doing it. I'll let him explain or share the details.

Glenn BarnasAdministrator
(KiX Supporter)
2006-12-22 11:55 PM
Re: @error handling? and redirection to a text file (append)

Net Stop will stop the task scheduler service, and affect all scheduled tasks. If you want to control individual task events, or even specific triggers of a selected task, the tcLib library will get the job done. It's posted here on KORG, but the latest version is available from my web site. It's too big to be easily maintained here.

tcLib consists of a KiX library of functions, and Microsoft's JT.exe. Once you place JT.exe into a folder in your PATH (like the Windows folder), just include the tcLib in your script and disabling (suspending) a task is as easy as:
Code:
tcInit()
tcDefineTask('taskname', 'SUS=1')
$RC = tcSetEvent('hostname', ' taskname')


One of the cool things about tcLib (and the task scheduler) is that you can define a task event without a trigger (time to run), and then use tcExecute('host', 'eventname') to run it with the defined credentials anytime you need to. This is how I implement a network-wide power shutdown process. Each system has a shutdown command, and a single system monitors the UPS array and invokes the scheduled task on the other systems to shut them down.

Glenn


itdaddy
(Starting to like KiXtart)
2006-12-23 01:09 AM
Re: @error handling? and redirection to a text file (append)

so what you are saying Glenn is
i can have my foreach loop with the array list of PC names
and put variable names in place of hostname and keep the taskname the same.?


this is what i want to do; i have this setup.exe program that uses a /s switch for default install; there is no msi file for it.
and I dont want to use a zap file and have employees choose to install.
i leave the workstations on at night my script copies a new setup.exe
file to a folder called C:\Add\scripts and in there i have a install.cmd
i put in the local pc job schedular and run as Domain Admin on a schedule time period andthen it changes permission on some folders using CACLS command. i do this cause 3rd party msi installer packages i think are flacky
so i use batch commands and some kix and job schedualar and it works slick
but i want it to disable the install.job after it sets permissions with CACLS command.but i dont know how. so i can use this tcl library liek i say above?
just loop it and how do put a var in place of hostname? so i can run through each pc; i am goingto use my foreach arry filler loop like i had startedout with? GPO installer program are sweet and easy in GPO
but hard to find a full version one that really works and wil stay working when patches and updates are applied. you know. so i do it simple;
my motto is use whatyou got! once i have it setup it works great!
what you think?


NTDOCAdministrator
(KiX Master)
2006-12-23 01:13 AM
Re: @error handling? and redirection to a text file (append)

I thought you was MCSE 2000/2003 certified and you do that type of setup?

Boy your users could have FULL admin rights in no time with that method.

Just add a few commands of their own to the file. Boot from a Windows PE and take rights to that folder if needed. Then add or remove stuff as they see fit without you ever being the wiser.


itdaddy
(Starting to like KiXtart)
2006-12-23 01:46 AM
Re: @error handling? and redirection to a text file (append)

working on mcse not yet
what do you mean NTDOC explain
the the schedular cant be run without admin rights
and the permissions on the folders have to be there or else it wont run
explain what you mean..

it just.
copies at night to each pc the setup.exe file
then it runs the file with admin rights only
then it sets permission with those folders only
then shuts off.

NTDOC explain where i am fuk$$ up


itdaddy
(Starting to like KiXtart)
2006-12-23 01:50 AM
Re: @error handling? and redirection to a text file (append)

Quote:
oy your users could have FULL admin rights in no time with that method.

Just add a few commands of their own to the file. Boot from a Windows PE and take rights to that folder if needed. Then add or remove stuff as they see fit without you ever being the wiser.


CD boots disabled! on all workstations! in bios!
2nd please explain where the commands they will run if i have RUN disable
in policy!
dont slam me too much; i am not that dumb! hee hee
but explain NTDOC where they will run the commands from if i have CD diabled form boot
and (though you can use BartPE from boot up windows!
the job scheduler is admin rights the machine is not.
run is removed CD boot is disable as well as USB disabled in bios

so explain where i may have said something wrong

WIP: MCSE buut i do not see my security breach explain big guy!
oh yeah i have the cacls file deleted when done and the setup.exe deleted
when done


itdaddy
(Starting to like KiXtart)
2006-12-23 01:54 AM
Re: @error handling? and redirection to a text file (append)

NTDOC
if you have great msi builder let me know i would rather
use my GPO (mcse skills) to assign my install to computer vs my
scripting but work is cheap! trying to make it easy and secure.
but please explain in detail where you see i am screwing up
GPO is the preferred but with out software you have to modify it.


NTDOCAdministrator
(KiX Master)
2006-12-23 02:01 AM
Re: @error handling? and redirection to a text file (append)

The issue is that you should not have a file that contains commands that will run with elevated Privileges residing on the local box (imho)

It is quite simple to run the BIOS and change (unless you have also password protected the BIOS, but that too could be problematic for you as an Admin when you or other support personnel need to work on it). You can also boot from USB devices now days as well.

Bottom line is that when ever possible it is better to keep as much as possible off of the local box that contains control features.
Use GPO when and where possible, you can force GPO refresh as well if needed.

Or at the very least keep the control file on a server where you have control of it at all times.


itdaddy
(Starting to like KiXtart)
2006-12-23 02:11 AM
Re: @error handling? and redirection to a text file (append)

Quote:
The issue is that you should not have a file that contains commands that will run with elevated Privileges residing on the local box (imho)


NTDOC
i see what you mean but we run Defrag with admin rights cause you have to.
but when the job is done i make sure it deletes them. when the copy takes place from the server it copies setup.exe and cacls1.bat program to local pc and runs with admin rights at night time when all are gone.

i am aware of programs that can run on local machines and do things to Active Directory as well. i have seen them...but in this case i am still looking for a MSI package which would prefer and yes, the Self healing technology i like as well. i dont want to use zap files and publish them; it needs to be done at night so all is ready in the morning. so i am still looking for the gpo way. nice that big MS$$ didnt make and MSI installer to package stuff up and to allow addes switches. But i think even MCSEs have to sort of jerry rigs stuff; but since my files are delete when done off of each pc and the job will be disabled; i feel okay; but like i said i am looking for the gPO way cause it is slick and self healing is great.
this software package we have is cheesy! but my scripting works.
the only thing is the install via job schedular with admin rights while
all are gone home. and then deletes self. and disble job !
so doing my best; i have talked with cert mcse and they even say theyhave had to do stuff like that! but echo what i do try to get msi.
amem to that!

Merry christmas guys!
hey NTDOC next time before you slam me; be easy! big guy!
WIP means work in progress and get all the facts i have done my homework
and disable many things in bios and password out with our admin pass word
for our admins on each pc so i am working it!

have agood one dude!

Robert(itdaddy)


NTDOCAdministrator
(KiX Master)
2006-12-23 02:20 AM
Re: @error handling? and redirection to a text file (append)

LOL - No problem. Didn't mean it as a slam.

Merry Christmas guy.


itdaddy
(Starting to like KiXtart)
2006-12-23 02:42 AM
Re: @error handling? and redirection to a text file (append)

thanks NTDOC

hahaa might be my precious IT ego! ahahhaha
i really try hard to do things right; i am pissed that MS$$ doesn't have a nice MSI tool to create custom MSI packages? do they? i haven't seen one.
and it is nice that 3rd party vendors get to make some money making them
but they get pricey when you want a good one that is well supported.
and well i try to use what we got on hand. but i will keep looking.
i am going to talk with our financial vendor they should make us their own msi when we get it from them but they are cheesy i think! it is on a windows platform you would think they would be able to do that!
hey this forum has a spell checker; better use it huh cool!
very cool! if i find a cool msi packager i will send it to this forum!


NTDOCAdministrator
(KiX Master)
2006-12-23 03:00 AM
Re: @error handling? and redirection to a text file (append)

Well can't vouch for any of them but here are some links maybe you'll find useful.

Advanced Installer 4.6.2
http://www.advancedinstaller.com/

Auto Installer 1.3
http://www.digitalliquid.com/dldata/soft.html

Installer2GO
http://dev4pc.com/installer2go_download.html

INF Generator
http://www.inner-smile.com/dl_inf.htm

Windows 2000 Resource Kit Tool : Installation Monitor
http://www.microsoft.com/downloads/detai...&displaylang=en

NSIS (Nullsoft Scriptable Install System)
http://nsis.sourceforge.net/Main_Page

RedShift - Installation System
http://www.stormdance.net/software/redshift%20freestyle/download.htm


.


itdaddy
(Starting to like KiXtart)
2006-12-23 06:34 PM
Re: @error handling? and redirection to a text file (append)

thanks NTDOC
will look into them
now let us go and celebrate christmas!

haahha
or should i say hooooohooohooooo
my son coming from california; we are going snowboarding! yeah!
freaking going to break my legs! oucch
see you guys next week!


itdaddy
(Starting to like KiXtart)
2006-12-25 12:42 AM
Re: @error handling? and redirection to a text file (append)

Hey Glenn

can you point me to your tcLib functions? and how to set it up on one of my servers. so let me get this straight if i read you right? or am i dreaming.

i can say put the script engines on that say server in choice,
then i can (after setting up a certain task on each PC in my domain)
basically invoke all PCs task in paticular with just say a script running from a server say for example. One click, turns on all the schedules to run? and i can turn them off with the same script?
if that were true point me in the right direction genius!


Sealeopard
(KiX Master)
2006-12-25 05:47 PM
Re: @error handling? and redirection to a text file (append)

Just search the UDF Forum for scheduler related UDFs, there's Glenn's tclib UDF and my ScheduleTask UDF.

Les
(KiX Master)
2006-12-25 05:55 PM
Re: @error handling? and redirection to a text file (append)

or just follow the link in Glenn's sig to http://www.innotechcg.com/

itdaddy
(Starting to like KiXtart)
2006-12-26 02:25 AM
Re: @error handling? and redirection to a text file (append)

SeaLeopard and Les
thanks will do!
merry christmas funny us techies still look at these forums
while the rest enjoy turkey and ham and cookies;
we are surfing the web! and our tech forums; true nerds we are!
ahahhaha

thanks guys!
will tell you how it turns out!
wow! wow! wow ~i just look at his stuff; wow if i can pull this off
i can work my magic; and have this install work freaking sweet
will show what i did when i get this perfect and post code here. when done to; but i think it is going to be great!
yeahhh! if i can get it to work!


itdaddy
(Starting to like KiXtart)
2006-12-26 06:00 PM
tcLib Help

Hey guys (Glenn)
I want to use your tcLib functions.
I want do this.
I have this script that copies a new setup.exe, first.bat, second.bat files to the root of c: on each PC in our domain. Then I want to create and execute a task to run the first.bat which executes setup.exe with an /s switch and then runs the second.bat file(on each PC).

How do I setup credentials for these functions, and the path to the first.bat program for this task to run with?

I am confused. I tried to add the tcInit() in a kix file and run it with say kix32 test1.kix command line and it didn't know what the tcInit() was.
I have in the running folder JT.exe and the tcLib.kxf.
What am I doing wrong does anyone have an example of how and where to place what in what file?
itdummy!
ps. i guess what i might be saying is where do i include the tcLib.kxf
and tcInit(). do i include it in my kix file and if so how ??????
==========================================================
what i want to do:
something like this (my pseudo code)
so how do include the lib tclib() and do i set it to (1)?
my thinking it goes into a kix file *.kix something but how?

foreach $Element
tcDefineTask()
tcExecute()
next
sleep 60 minutes
foreach $Element
tcTerminate()
next





Glenn BarnasAdministrator
(KiX Supporter)
2006-12-26 08:11 PM
Re: tcLib Help

1. READ the document in the DOCS folder from the ZIP you downloaded - it has a lot of examples, including a step-by-step process for defining, deleting, and changing a task event.

2. Make sure you place JT.EXE into the \Windows folder, or some other folder that is in your PATH. It will NOT WORK otherwise, unless you modify the tcInit() udf, as shown below.
Code:
    ; Define the path to the JE.EXE command. This should be simply 'jt.exe'
    ; if JT.EXE is in the system PATH.
    $tcJTEXE = 'jt.exe'

3. Like any other UDF, you need to place it into your script, either directly or via call or include statements.

If you simply want to interactvely run a task using alternate credentials, look for the runnas.exe tool, which works like RunAs, but accepts the password on the command line.

Glenn


itdaddy
(Starting to like KiXtart)
2006-12-26 11:30 PM
Re: tcLib Help

Code:
INCLUDE tcLib.kxf

tcLib()
tcExecute("flend1","fspinstall")


Glenn
be patient with me I am a bit rusty!
above is an already existing scheduled task on the workstation in our domain.I was just testing a basic script to get it running to see if i have
my setup correct. can you guide me a little on my terrible code?

okay above i have a file called test.kix
and i have kix32.exe and its driver in C:\windows and the jt.exe in C:\windows so it is in the path and can be accessed universally. I get that.
but how do you include the kxf file for me to use the tcLib() functions.
I am a bit rusty on this: once i get it included correctly and i already have the jt and kix engines in place. I just need to include the kxf library to use the functions in my kix doc correct? and just follow your examples in your KIX tcLib document; i see them.

robert(itdummy)


Sealeopard
(KiX Master)
2006-12-27 12:22 AM
Re: tcLib Help

Please see the FAQ on how to use UDFs. Also, strat with re-creating some of Glenn's samples before you move on to coding your own scripts, this will help you understand how to use tcLib. and for smaller tasks you can always use the ScheduleTask UDF, which also schedules tasks but doesn't have all the bells and whistles that glenn offers. Then again, sometimes, simple is sufficient.

itdaddy
(Starting to like KiXtart)
2006-12-27 12:59 AM
Re: tcLib Help

sealeopard,


awwwaaa I see thanks! sorry guys for reinventing the wheel!
oops my bad! newby!!!!!!!!!!!!!
thanks a bunch