Page 1 of 2 12>
Topic Options
#189689 - 2008-09-16 01:13 PM more speed?
Jlmartinez Offline
Getting the hang of it

Registered: 2008-05-20
Posts: 75
Loc: Sevilla, Spain
How can I increase the speed of my script? Is there any way to optimize it?
Top
#189691 - 2008-09-16 01:27 PM Re: more speed? [Re: Jlmartinez]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Post a copy and we'll take a look!

There are several optimization methods available through alternate logic, or even different commands or UDFs.

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

Top
#189694 - 2008-09-16 01:55 PM Re: more speed? [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Glenn is right, there are huge amounts of optimizations to be done but they all depend on the script and without knowing anything about it, it's darn hard to help...
_________________________
!

download KiXnet

Top
#189695 - 2008-09-16 02:16 PM Re: more speed? [Re: Lonkero]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
A suggestion before you make any changes, put @time at the beginning and end of your script and re-direct to a log. That way as you make changes, you can have empirical evidence of any improvements.
Top
#189702 - 2008-09-17 01:02 AM Re: more speed? [Re: BradV]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Actually, I like
$STime = @TICKS

your code...

$TTime = cdbl(@TICKS - $STime) / 1000.0
'Total time to run: ' $TTime ' seconds.' ?

which shows time in thousands of a second.

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

Top
#189707 - 2008-09-17 09:09 AM Re: more speed? [Re: Glenn Barnas]
Jlmartinez Offline
Getting the hang of it

Registered: 2008-05-20
Posts: 75
Loc: Sevilla, Spain
I have a kix with many:

"If InGroup("GG-DPT-technic")

;----AGREGAMOS LAS IMPRESORAS DEL SERVICIO----
SHELL "regedit.exe /s "+$ruta+"imp-2-I10010.reg"
SHELL "regedit.exe /s "+$ruta+"imp-2-I10008.reg"
SHELL "regedit.exe /s "+$ruta+"imp-1-0AG05.reg"
SHELL "regedit.exe /s "+$ruta+"imp-2-I10012.reg"
"

Can I replace the shell with something else? addprinter something like?

Top
#189708 - 2008-09-17 09:13 AM Re: more speed? [Re: Jlmartinez]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
You could use the WriteValue() function. It depends a bit on how big the reg imports are if this will save you some time.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#189709 - 2008-09-17 12:55 PM Re: more speed? [Re: Mart]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
While the size of the .reg files can impact speed to some degree, realize that every time you Shell, you start up a new environment, possibly wait for CMD.exe to load and initialize, load and run the command, process the data, etc... The point is, there's significant overhead processing Shell commands instead of using built-in commands and functions.

If your reg files are managing printers, native commands would likely be much faster. If they are generic registry data, Kix has a WriteValue command for single value writes, and LoadHive and LoadKey to natively load registry data from a file.

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

Top
#189711 - 2008-09-17 01:51 PM Re: more speed? [Re: Glenn Barnas]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
Besides the good suggestions given, check for one reg setting (ReadValue) if it's set before you import regs, or even use WriteValue. That should save some time.
Top
#189712 - 2008-09-17 01:52 PM Re: more speed? [Re: Glenn Barnas]
Jlmartinez Offline
Getting the hang of it

Registered: 2008-05-20
Posts: 75
Loc: Sevilla, Spain
my files are managing printer, add printers. How can I use native commands?
Top
#189713 - 2008-09-17 02:00 PM Re: more speed? [Re: Jlmartinez]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
Show us the current script, we can give you advice and/or code suggestions. Besides that look in the KiX documentation (download the kix 4.60 package from the main site) and look at the laundrylist of native commands such as AddPrinterConnection and SetDefaultPrinter.
Top
#189714 - 2008-09-17 02:01 PM Re: more speed? [Re: Jlmartinez]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Kix has the AddPrinterConnection, SetDefaultprinter and DelPrinterConnection functions that you can use to add, set as default and remove printers. How to use them is explained on pages 51/52, 60 and 95/96 of the 4.60 manual that comes with every download.

Any other registry settings for your printers can be done with for example the WriteValue function like Glenn suggested.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#189715 - 2008-09-17 02:09 PM Re: more speed? [Re: Arend_]
Jlmartinez Offline
Getting the hang of it

Registered: 2008-05-20
Posts: 75
Loc: Sevilla, Spain
If InGroup("GG-DPT-AULAFORMACION")
SHELL "regedit.exe /s "+$rute+"imp-2-I01101.reg"
EndIf

If InGroup("-DG-Agriculture")
SHELL "regedit.exe /s "+$rute+"imp-2-I13104.reg"
SHELL "regedit.exe /s "+$rute+"imp-2-I13005.reg"
SHELL "regedit.exe /s "+$rute+"imp-2-I13101.reg"
EndIf

This is a part. This is repeated for groups very much, around 50. What would be a more optimal way.All this is to add printers to register in HKCU\Printers\connections. Thanks

Top
#189716 - 2008-09-17 02:13 PM Re: more speed? [Re: Jlmartinez]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
AddPrinterConnection will do just fine to add printers and SetdefaultPrinter will set the default printer you need.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#189721 - 2008-09-17 04:30 PM Re: more speed? [Re: Mart]
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 309
Loc: STRASBOURG, France
Hi,

if all .reg files are independent, you could start regedit with RUN instead of SHELL.

Printers will be added in background but your script kix continues !!!
_________________________
Christophe

Top
#189722 - 2008-09-17 04:55 PM Re: more speed? [Re: ChristopheM]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 686
Loc: Maryland, USA
I would question if you really need to write to the registry at every log in. How about reading from the registry to see if the value exists? If not, then write.
Top
#189727 - 2008-09-17 11:01 PM Re: more speed? [Re: BradV]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yes, if that is printer script, just do:
if not primapstate("\\myserver\myprinter")
; do the printer stuff
endif

that should be as fast as it can be...
_________________________
!

download KiXnet

Top
#189729 - 2008-09-18 08:43 AM Re: more speed? [Re: Lonkero]
Jlmartinez Offline
Getting the hang of it

Registered: 2008-05-20
Posts: 75
Loc: Sevilla, Spain
"you really need to write to the registry at every log in??"


Only when I add a new printer to print server, but that's not something I would control.

Top
#189751 - 2008-09-19 11:51 AM Re: more speed? [Re: Jlmartinez]
edjekroketje Offline
Fresh Scripter

Registered: 2008-09-19
Posts: 20
Loc: Amsterdam, the Netherlands
This is an interesting topic. Since we can do with a speed improvement in our script ourselves, i have opened a similar topic myself. Will try to help here. I can see that the addprinter command works fine. Also the delprinter to disconnect printers if not neccasary. I'm wondering if that will work with wildcards as well?


Edited by edjekroketje (2008-09-19 04:36 PM)
Edit Reason: Possible violation of forumrules
_________________________
Still thinking about a good signature

Top
#189752 - 2008-09-19 12:15 PM Re: more speed? [Re: edjekroketje]
Mart Moderator Offline
KiX Supporter
*****

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

Posting your issue (although similar to the original poster’s issue) in someone else’s thread is considered hijacking and is not approved by the other members on this board and certainly not by the mods and admins because it puts the focus of the thread on your issue and not the one the original poster had.
Please start your own thread and (if needed) include a link to this thread.

Ok, all that being said I see lots of ways to improve on your script. Remove the goto’s, remove the use of bat(ch) files, etc….


[edit]
BTW: Welcome to the board \:\)
[/edit]


Edited by Mart (2008-09-19 12:18 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 557 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.067 seconds in which 0.024 seconds were spent on a total of 14 queries. Zlib compression enabled.

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