#99070 - 2003-03-04 05:37 PM
counter
|
sliver
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
|
|
|
|
#99072 - 2003-03-04 07:39 PM
Re: counter
|
sliver
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
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
readprofilestring() writeprofilestring()
|
|
Top
|
|
|
|
#99075 - 2003-03-04 08:33 PM
Re: counter
|
NTDOC
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
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
|
|
|
|
#99078 - 2003-03-04 09:45 PM
Re: counter
|
sliver
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
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.
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|