• 0

[VBS] Run at given time...


Question

4 answers to this question

Recommended Posts

  • 0

Well, one way would be to have a loop run (include the API to Sleep) and within the loop check the time you are waiting for.

However, this being said, you are going to use system resources while waiting.

I guess the more important question to ask is why not have the system scheduler launch your script/batch at the time you want it to.

  • 0

basicly, I'm working on a plugin for another program a launch an alarm clock.

I would be set the night before, and place music in a play state at x time.

I know very little about programing, however I've found this in prncnfg.vbs:

           case "-st"
                iIndex = iIndex + 1
                oParamdict.Add kStartTime, "********" & oArgs(iIndex) & "00.000000+000"  

Which lets you launch the script with a time parameter, but don't know how to apply it to a pause until type command.

  • 0

This is my 'plug-in':

dim client 
dim message 

set client = CreateObject( "MeedioClient.MeedioPluginClient" ) 
if client.Connect( "localhost" , 7500 , "" , 0 , 0 ) then 

  'Jumps to alarm screen
  set message = client.NewMessage( "system.jump" )
  message( "target" ) = "alarm"
  message.Send 
  WScript.Sleep( 10 ) 
  client.Flush

  'hides left menu
  set message = client.NewMessage( "control.visible" )
  message( "control" ) = "left-menu-cell" 
  message.Send 
  WScript.Sleep( 10 ) 
  client.Flush

  'stops any playing music
  set message = client.NewMessage( "music.stop" )
  message.Send 
  WScript.Sleep( 10 ) 
  client.Flush

  'sets low volume alarm start
  set message = client.NewMessage( "music.volume" )
  message( "volume" ) = "1"
  message.Send
  WScript.Sleep( 10 ) 
  client.Flush

  'starts alarm song
  set message = client.NewMessage( "music.play-file" )
  message( "artist" ) = "Good Moring"
  message( "caption" ) = "The alarm is running"
  message( "album" ) = "Time to get up..."
  message( "id" ) = "xx"
  message( "file" ) = "D:\Music\Bad Religion\Recipe for Hate\Bad Religion - 01 - Recipe For Hate.mp3"  
  message.Send 
  WScript.Sleep( 10 ) 
  client.Flush  

  'repeats song
  set message = client.NewMessage( "music.repeat" )
  message( "repeat" ) = "on"
  message.Send
  WScript.Sleep( 10 ) 
  client.Flush  

  'sleeps 2 mins
  WScript.Sleep( 120000 )

  'increses vol every 2 mins
  set message = client.NewMessage( "music.volume" )
  message( "volume" ) = "2"
  message.Send
  WScript.Sleep( 120000 ) 
  client.Flush
  set message = client.NewMessage( "music.volume" )
  message( "volume" ) = "3"
  message.Send
  WScript.Sleep( 120000 ) 
  client.Flush

  'increses vol every 1 mins
  set message = client.NewMessage( "music.volume" )
  message( "volume" ) = "4"
  message.Send
  WScript.Sleep( 60000 ) 
  client.Flush
  set message = client.NewMessage( "music.volume" )
  message( "volume" ) = "6"
  message.Send
  WScript.Sleep( 60000 ) 
  client.Flush
  set message = client.NewMessage( "music.volume" )
  message( "volume" ) = "7"
  message.Send
  WScript.Sleep( 60000 ) 
  client.Flush
  set message = client.NewMessage( "music.volume" )
  message( "volume" ) = "8"
  message.Send
  WScript.Sleep( 60000 ) 
  client.Flush
  set message = client.NewMessage( "music.volume" )
  message( "volume" ) = "9"
  message.Send
  WScript.Sleep( 60000 ) 
  client.Flush

end if

As you can see, it's very BASIC stuff.

  • 0

Edit: Hang on, I've apparently go my syntax wrong somewhere. Give me a few minutes...

Edit#2: Ok, I found it. To many "'s and a missing option. Sorry about that.

How about using "at"?

Open up a command prompt, and type in:

at 12:00 /interactive /next:Wednesday wscript script.vbs

Just replace the time and day with when you want it to go off, and replace script.vbs with the path to your script. If you want to make it even easier, just wirte up a simple vbscript that asks for day & time.

Something like:

Option Explicit

Dim batch, day, time

day =  InputBox("Set day:")
time =  InputBox("Set time:")

Set batch = createobject("wscript.shell")
batch.Run "at " & time & " /interactive /next:" & day & " wscript c:\script\script.vbs"

Edited by Dented
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

  • Recent Achievements

    • First Post
      Gladiattore earned a badge
      First Post
    • Reacting Well
      Gladiattore earned a badge
      Reacting Well
    • Week One Done
      NeoWeen earned a badge
      Week One Done
    • One Month Later
      BA the Curmudgeon earned a badge
      One Month Later
    • First Post
      Doreen768 earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      635
    2. 2
      ATLien_0
      260
    3. 3
      Xenon
      164
    4. 4
      neufuse
      142
    5. 5
      +FloatingFatMan
      107
  • Tell a friend

    Love Neowin? Tell a friend!