Page 1 of 1 1
Topic Options
#99070 - 2003-03-04 05:37 PM counter
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
Does anyone have a good example of a counter I can use. I have an application I wish to deploy(through the login script)but I only want to deploy this to 500 people per morning as to preserve bandwith.
I looked at the UDF's but did'nt see anything under "Counters".

Thanks!!

Top
#99071 - 2003-03-04 05:45 PM Re: counter
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Just increase a number in a central reg key or .INI file.
_________________________
There are two types of vessels, submarines and targets.

Top
#99072 - 2003-03-04 07:39 PM Re: counter
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
That is actualy what I am trying to do...I am trying to read a central .ini file to see if the number on the first line is >= 500 and if not then run the script.

The problem I am having is figuring out a way to overwrite the first line value. Writeline only wants to append to the file and so my file looks like so:

0
1

when I just want it to goto

1

Any suggestions...is there a command I am missing here

Top
#99073 - 2003-03-04 07:50 PM Re: counter
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
readprofilestring()
writeprofilestring()
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#99074 - 2003-03-04 07:51 PM Re: counter
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
.INI files have a special format and must be read with READPROFILESTRING and written to with WRITEPROFILESTRING.
_________________________
There are two types of vessels, submarines and targets.

Top
#99075 - 2003-03-04 08:33 PM Re: counter
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Silver,

Here is another method of a counter. Not exactly what you're looking for, but an idea for future reference.

Break On
ModifyBackGround

code:
Function ModifyBackGround()
DIM $AddServerKey, $AddBackGroundValue, $CheckBGValue, $UpdateBGValue
IF @INWIN = 1
$SRVR = ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions", "ProductType")
IF $SRVR<>"WinNT"
IF INGROUP("\\@WKSTA\Administrators")<>0
IF NOT keyexist("HKEY_LOCAL_MACHINE\SOFTWARE\MyCompany\SERVER")
$AddServerKey = addkey("HKEY_LOCAL_MACHINE\SOFTWARE\MyCompany\SERVER")
SHELL '%COMSPEC% /C "\\MyServer\MyShare\WHOAMI.EXE" >NUL 2>NUL'
$RC=WRITEVALUE ("HKEY_USERS\.DEFAULT\Control Panel\Desktop", "Wallpaper", "%WINDIR%\Kewlit.com-autopaper.bmp", "REG_SZ")
$AddBackGroundValue = writevalue("HKEY_LOCAL_MACHINE\SOFTWARE\MyCompany\SERVER", "BackGroundUpdate", "0", "REG_DWORD")
ENDIF
$CheckBGValue = VAL(READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\MyCompany\SERVER", "BackGroundUpdate"))
$BGTemp = $CheckBGValue+1
$UpdateBGValue = writevalue("HKEY_LOCAL_MACHINE\SOFTWARE\MyCompany\SERVER","BackGroundUpdate","$BGTemp","REG_DWORD")
IF $CheckBGValue >10
SHELL '%COMSPEC% /C "\\MyServer\MyShare\WHOAMI.EXE" >NUL 2>NUL'
$RC=WRITEVALUE ("HKEY_USERS\.DEFAULT\Control Panel\Desktop", "Wallpaper", "%WINDIR%\Kewlit.com-autopaper.bmp", "REG_SZ")
$AddBackGroundValue = writevalue("HKEY_LOCAL_MACHINE\SOFTWARE\MyCompany\SERVER","BackGroundUpdate","0","REG_DWORD")
ENDIF
ENDIF
ENDIF
ENDIF
EndFunction


Top
#99076 - 2003-03-04 09:18 PM Re: counter
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
Ok...I feel like a complete idiot but I still can't get this thing to work. It now just appends a the number to the .ini file. Code looks like so....

code:
Dim $result, $checkvalue
$checkvalue=ReadProfileString("%LOGLOC%\SMSECCM01\smsupgrade.ini","sms","counter")
$result = $checkvalue+1
WriteProfileString("%LOGLOC%\SMSECCM01\smsupgrade.ini","sms","counter","$result")

Looked in the book and tried many differant ways of using the "" and everything. Still can't get it.

Top
#99077 - 2003-03-04 09:23 PM Re: counter
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
have a look at functions val() and cint()
_________________________
We all live in a Yellow Subroutine...

Top
#99078 - 2003-03-04 09:45 PM Re: counter
sliver Offline
Getting the hang of it

Registered: 2002-09-05
Posts: 94
val() worked great...thanks for the response guys!!!!
Top
#99079 - 2003-03-05 11:20 PM Re: counter
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear sliver,

The problem with using counter as item is, that between a ReadProfileString and
WriteProfileString operation another user tries to run also that application. Impact
will be that your counter doesn't reflect the actual amount of users, who are running
your application.

Also we see that it has to deal with SMS software. In our situation not a problem to
use concept for software. Each user generates in this situation an unique record with
a size of 45 bytes. Another user doesn't have impact on yours. When the specific INI
file gets a size above 500*45 bytes 500 users are active at the same moment to run that
specific part/application.
To prevent possible situations of old entries we will try always to remove such
entries with latest WriteProfileString call.

Our solution is to use following code
code:
$sms_info_file="%logloc%\smseccm01\smsupgrade.ini"
$sms_key=SubStr(@userid+" ",1,3)+" sms"
IF ($GetFileSize($sms_info_file) < 500*45)
IF WriteProfileString($sms_info_file,"sms",$sms_key,"@date @time") ; - yyyy/mm/dd hh:mm:ss -
ENDIF
SHELL '%comspec% /c start /w run_sms.bat'
IF WriteProfileString($sms_info_file,"sms",$sms_key)
ENDIF
ELSE
? "Sorry, no upgrade this moment. Too many users already active."
ENDIF
IF WriteProfileString($sms_info_file,"sms",$sms_key)
ENDIF

greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

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

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