Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

run wscript at particular time (not with sched)

Posted on 2003-03-16
3
Medium Priority
?
563 Views
Last Modified: 2008-01-16
Hello,

I want my computer to run wmplayer.exe at 12am EST and open mms://blahblahblah streaming source then close the wmplayer.exe program after 4am EST.  There's a sumo tournament in Japan I want to watch, but by the time I get home from late night work or weekend stuff it's 3am already and I can't login since the streaming server is already full. :(

Yes, normally you would just put a shortcut into scheduler but since it's an older program it doesn't recognize the newer mms:// header information.

So I'm thinking go wscript?  Sure.

what I'd like to do is:

at midnight, run wmplayer.exe
open mms:// site
at 4am close wmplayer.exe
 
optionally some error checking on stop stream error repeat login would no doubt be useful.

so, how do I use wscript to read the windows clock to "sleep" then act while I'm away?  I can do a time delay but I would have to know what time it is for each program execution.  Instead, how do I read the time and act on it when the clock tolls midnight?  I'm sure it's simple, (I modified a script that turns on and off my speaker har har..), but I don't know how to deal with time.  Docs talk about a delay.  I don't want a delay, but to repeat some functionality of scheduler to run at a specific windows clock time.

any helper examples would be nice, thanks.

cheers
walter

for your info, not related to my question perhaps, is the so simple speaker script.  It's a useful template to run apps as if you're there clicking away.  If your answer is along the same lines that would be fun.

'----script begins----
'toggle-sound.vbs
'Written by Walter Spicer
'based on a script written by Alan Kaplan and Zubair Ahmad
'open sound and toggle mute on or off weee

set WshShell = CreateObject("WScript.Shell")
WshShell.Run "sndvol32.exe"
WScript.Sleep 2000
While WshShell.AppActivate("Volume Control") = FALSE
   wscript.sleep 1000
Wend
WshShell.AppActivate "Volume Control"
WScript.Sleep 200
WshShell.Sendkeys "{TAB}"
WScript.Sleep 200
WshShell.SendKeys "{TAB}"
WScript.Sleep 200
WshShell.SendKeys "{ }" 'yep...it is a space
Wscript.Sleep 500
WshShell.Sendkeys "%{F4}"

'---script ends---
0
Comment
Question by:sf2k
3 Comments
 

Author Comment

by:sf2k
ID: 8157221
ok, I solved it myself.  Found some error code and the right links and chalked up my second script in .vbs .  It really **was** easy.  shock...

I wanted to use Exec and Terminate together, to kill the wmplayer program after 4am (returned as "3" from Hour(Time()) ), but since that didn't work? I opted for a while-loop that tries from midnight to 4am.  

The ntErrorCode is good to lookup, if I had left this script alone, I would have come back to see wmplayer every half second trying to access the site, rather than exiting after running the program.  Good thing I tested.

msdn.microsoft.com resource is there but also try
http://www.winguides.com/scripting/ to cut through the verbage.

here's the result:

'----script begins----
'Written by Walter Spicer
'to log into sumo basho while I'm away ;)


Dim intErrorCode

set oShell = WScript.CreateObject("WScript.Shell")
oHour = Hour(Time())

'between midnight,0, and 4am, 3
While oHour < 3
     oShell.Run "mms://blahblahblah/"
     WScript.Sleep 2000
     
     'end wscript memory process and leave player running
     'or else it will constantly reopen mms:// site argh!!
     intErrorCode =1
     WScript.Quit (intErrorCode)
Wend

While oHour > 3
     WScript.echo "not midnight yet"
Wend

'on close error fix
While oShell.AppActivate("Windows Media Player") = FALSE
   wscript.sleep 2000
Wend

'---script ends---
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 8956474
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

-->PAQ - with points refunded

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

GPrentice00
EE Cleanup Volunteer
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 9012194
Question closed and points refunded

PashaMod
CS Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question