Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Suggestions

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,49659
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Suggestions
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Suggestions - 7/18/2007 8:54:15 AM   
  DiGiTAL.SkReAM


Posts: 1194
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
I have found myself in need of a script being run once every few minutes, on an ongoing basis, for as long as the server is running.
Basically, I want to check for the existence of a file, for example, once every 2 or 3 minutes, round the clock.  Now, I have all the code put together, and COULD do it with a set of scripts and the task scheduler, but... that just seems really kludgy to me.

What I want to ask is... when you guys/gals get into a situation where you need to have some script or command run over and over every few minutes, what do you use?  A set of scripts?  A third-party app?

Thanks,
DS

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury
 
 
Post #: 1
 
 RE: Suggestions - 7/18/2007 9:22:14 AM   
  DiGiTAL.SkReAM


Posts: 1194
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
Ne'ermind, I'm writing a mini-app that will be run as a service and will do this for me.  Of course, I am using vb 2005 express, so who knows how "mini" this thing will be. <sigh>

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 2
 
 RE: Suggestions - 7/18/2007 6:40:54 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
I don't think there's anything "kludgy" about using the Task Scheduler at all.  That's what it's there for.

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 3
 
 RE: Suggestions - 7/19/2007 1:14:49 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
If you are monitoring for a file to appear, I would do it with a WMI event sink. Then you won't have to use the scheduler at all.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ginolard)
 
 
Post #: 4
 
 RE: Suggestions - 7/19/2007 1:41:20 AM   
  DiGiTAL.SkReAM


Posts: 1194
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
Thanks.  The existance of a file was just an example of a task to perform.  I am actually using WMI to monitor the status of the UPS attached to the server.  In the event of a On Battery event, if it lasts longer than 2 minutes, I will hibernate all the machines on the network, stop the exchange, blackberry, and SQL services, and hibernate the servers.


_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: Suggestions - 7/19/2007 8:34:40 AM   
  Fredledingue


Posts: 383
Score: 0
Joined: 5/9/2005
From:
Status: offline
Why can't you run the script forever with a 2~3 minutes sleep in a loop?

_____________________________

Fred

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 6
 
 RE: Suggestions - 7/20/2007 4:57:26 AM   
  DiGiTAL.SkReAM


Posts: 1194
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
Because I won't have any way of knowing if the script has crashed or is still working.  by starting a new script, I am basically starting with a clean slate and can chekc for status.

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to Fredledingue)
 
 
Post #: 7
 
 RE: Suggestions - 7/20/2007 8:41:39 AM   
  Skie

 

Posts: 58
Score: 0
Joined: 3/2/2006
Status: offline
I'd use an HTA with an interval set to run every 2-3 minutes.  That way, it could even generate the result in a pretty window, even if that result is just an error.

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 8
 
 RE: Suggestions - 7/20/2007 11:30:48 AM   
  DiGiTAL.SkReAM


Posts: 1194
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
I don't want to see the result.  The results would be pretty obvious - the lights in the building are all out, and UPS's are beeping like crazy. lol

After much battle with Vb.express.2005.crapola, I decided to kludge it and go with task scheduler. *sigh*

Here's the logic flow, as it stands right now.

Once a minute, kicks off a script (named appropriately enough, KickOff.vbs) that:
1> Check for power.out file.
    1a> If file eixsts, exit.
    1b> If file does not exist, continue
2> Check for process named cs_service.exe
    2a> if process exists, kill it.
3> Spawn CheckUPS.vbs script using a copy of cscript.exe named cs_service.exe
4> Exit

CheckUPS.vbs
1> Check UPS status via WMI
    1a> if On A/C power, exit
    1b> If on Battery power, continue
2> Create a file named power.out
3> Begin a counter, C1
4> In a Do...Loop, check the UPS staus.
    4a> if on A/C power, exit
    4b> if still on battery, continue
5> For every second that the UPS is on battery, increment the C1 counter.
6> if C1 = 120, spawn Power_Down.vbs
7. Exit

Power_Down.vbs
1> Get a list of workstations currently online on the network
2> Send a hibernate command to each of these.
3> After they are hibernated, stop the exchange and blackberry services on the exchange server
4> hibernate the exchange server
5> Stop the SQl service on the local server
6> Set a flag int he registry that the server hibernated after 2 minutes battery time.
7> hibernate the local server

Changes to the above will be:
a) Instead of a power.out file, will use a flag in the registry.
b) Will Clear the flags upon first run after a hibernate


i have 99% of the code written, and tested in sections.  I am now trying to find the time to test the whole thing and portablize (is that a word?) the code so that it will run on various networks/servers, and not just mine.  Once done, will post int he post yer code section.

Thanks for the tips, folks.

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to Skie)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Suggestions Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts