?
Solved

run wscript at particular time (not with sched)

Posted on 2003-03-16
3
Medium Priority
?
552 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

770 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