Page 1 of 1 1
Topic Options
#129700 - 2004-11-17 02:45 PM Run part of script only on first Monday of month
CJD Offline
Fresh Scripter

Registered: 2004-11-02
Posts: 11
As the title says, I need to run part of my logon script ONLY on the first Monday of each month (for auditing PCs). Here's what runs right now, and the scheduling is done by the settings in the exe file.

IF INGROUP("Domain Users")
RUN '\\server\xxx.exe'
?Audit is running in the background"
ENDIF

However, the settings for the audit program don't allow you to specifiy something as specific as the first Monday of the month. If anyone has an example of something similar they would like to share, it would really help out. Thanks.

Top
#129701 - 2004-11-17 02:54 PM Re: Run part of script only on first Monday of month
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
haven't given it too much thought, but something like this might work

Code:

if @day = "Monday" and @mdayno < 8
? "First Monday of the month
endif

_________________________
Eric

Top
#129702 - 2004-11-17 02:55 PM Re: Run part of script only on first Monday of month
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
ummm ... will this work ?

Code:


if @wdayno = 1 and @mdayno < 8
"Today is the first monday of this month"
endif




this is only reliable of course if it runs every day of week
_________________________



Top
#129703 - 2004-11-17 02:57 PM Re: Run part of script only on first Monday of month
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
dang ^~
_________________________



Top
#129704 - 2004-11-17 03:26 PM Re: Run part of script only on first Monday of month
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Of course if one logs on many times on that Monday, it will run at every logon. Better to write a flag in the registry or an INI file or some other method to see if it had run already.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#129705 - 2004-11-17 03:29 PM Re: Run part of script only on first Monday of month
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
your right Les, I knew there was something fishy with that !
_________________________



Top
#129706 - 2004-11-17 03:40 PM Re: Run part of script only on first Monday of month
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
yeah it's just a start. and like jochen pointed out, if nobody logs on that monday, it won't run either. so it is definitely lacking some needed logic.
_________________________
Eric

Top
#129707 - 2004-11-17 03:41 PM Re: Run part of script only on first Monday of month
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
nope, it's reliable always.
if a script is said to be run only on first monday, then it must not run otherwise, even though it would not run because of that for years.

the code is reliable.
just that the logic behind the ruling could be worked out a bit.

like, "run once a month" would be neat.
thus it would run on first logon of the month only, no matter what day it is.
something like this:
Code:

If ReadValue('HKCU\Software\KiXtart','lonks_val')<>@monthno
Run "myProggie"
$=WriteValue('HKCU\Software\KiXtart','lonks_val',@monthno,'REG_SZ')
EndIf

_________________________
!

download KiXnet

Top
#129708 - 2004-11-17 03:42 PM Re: Run part of script only on first Monday of month
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
lol, I wrote little bit too long that Shiat!
to those who wonder, it's reply to the jochens dang post
_________________________
!

download KiXnet

Top
#129709 - 2004-11-17 04:19 PM Re: Run part of script only on first Monday of month
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
ok. borrowing from jooel, maybe something like this would work

Code:

if ReadValue('HKLM\Software\YourCompany\Audit','Month')<>@monthno
if @day = "Monday" or @mdayno > 7
if ingroup("Domain Users")
run "\\server\xxx.exe"
? "Audit is running in the background"
endif
$=writevalue('HKLM\Software\YourCompany\Audit','Month',@monthno,'REG_SZ')
endif
endif

_________________________
Eric

Top
#129710 - 2004-11-17 04:23 PM Re: Run part of script only on first Monday of month
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
ok,

back to the problem ... implementing Les' suggestion, how about this :

Code:


$sFlagKey = "HKEY_CURRENT_USER\Software\KiXtart\"

if @wdayno = 3 and @mdayno < 8 and not val(readvalue($sFlagKey, "FirstMondayFlag"))
;run your shtuff here!
if @error = 0 ; or whatever it takes
$_ = writevalue($sFlagKey, "FirstMondayFlag", 1, "REG_DWORD")
endif
else
$_ = writevalue($sFlagKey, "FirstMondayFlag", 0, "REG_DWORD")
endif



_________________________



Top
#129711 - 2004-11-17 04:23 PM Re: Run part of script only on first Monday of month
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The prob with HKLM is perms.

I really hate crap like that running at logon. It is this sort of thing that encourages users to never logoff. It should be setup as a sceduled task instead.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#129712 - 2004-11-17 04:27 PM Re: Run part of script only on first Monday of month
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
beaten again
K, I will quit posting for today

_________________________



Top
#129713 - 2004-11-18 12:41 AM Re: Run part of script only on first Monday of month
Anonymous
Unregistered


Quote:

Of course if one logs on many times on that Monday, it will run at every logon. Better to write a flag in the registry or an INI file or some other method to see if it had run already.




That part I can take care of. There is an option in the settings for the exe that you select that makes it run only once a day. I've been too busy to try implementing any of the suggestions today, but I'll let you guys know what works. Thanks for the help, and keep the suggestions coming.

Top
#129714 - 2004-11-18 02:49 AM Re: Run part of script only on first Monday of month
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11163
Loc: Boston, MA, USA
If a script needs to run on mondays then I'd schedule it via the Task Scheduler, especially if it is an audit script. It would even run under a different user account, thus the chance that a user is closing the audit program is minimized. Also, the whole thing could be scheduled via admin script and no changes to a logon script are required.
_________________________
There are two types of vessels, submarines and targets.

Top
#129715 - 2004-11-18 11:02 AM Re: Run part of script only on first Monday of month
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22344
Loc: OK
I think your idea of the first monday is still screwed up.
you can never get 100% hit if you limit the audit to single day of the month.

running it once a month is a different thing, and to that you got provided code on silver platter already.
_________________________
!

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 310 anonymous users online.
Newest Members
Praveer, Ollero, rayyo, Foxlicht, DonChild
17742 Registered Users

Generated in 0.039 seconds in which 0.012 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