Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Microsoft VBScript runtime error: Object doesn't support this property or method: 'WScript.Sleep'

Reply
 
Old 09-03-2008   #1 (permalink)
Mark Dougherty


 
 

Microsoft VBScript runtime error: Object doesn't support this property or method: 'WScript.Sleep'

I have a VBscript that uses the "WScript.Sleep 10000" command to pause
briefly.



When I run the VBscript interactively from a command-line, the Sleep
function works perfectly.



If I run the VBscript from a scheduled Windows task or invoke the VBscript
from inside a VB application, I get the following error message:



StartStopWindowsService.vbs: Microsoft VBScript runtime error: Object
doesn't support this property or method: 'WScript.Sleep'



Any ideas why the Sleep command generates this runtime error when launched
from a scheduled task or inside a VB app? Any workarounds?



Thank you,



Mark Dougherty

St. Louis, Missouri



My System SpecsSystem Spec
Old 09-03-2008   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Microsoft VBScript runtime error: Object doesn't support this property or method: 'WScript.Sleep'


"Mark Dougherty" <dougherty@xxxxxx-stl.com> wrote in message
news:%23Z%23BXVeDJHA.5316@xxxxxx
Quote:

>I have a VBscript that uses the "WScript.Sleep 10000" command to pause
> briefly.
>
>
>
> When I run the VBscript interactively from a command-line, the Sleep
> function works perfectly.
>
>
>
> If I run the VBscript from a scheduled Windows task or invoke the VBscript
> from inside a VB application, I get the following error message:
>
>
>
> StartStopWindowsService.vbs: Microsoft VBScript runtime error: Object
> doesn't support this property or method: 'WScript.Sleep'
>
>
>
> Any ideas why the Sleep command generates this runtime error when launched
> from a scheduled task or inside a VB app? Any workarounds?
>
>
>
> Thank you,
>
>
>
> Mark Dougherty
>
> St. Louis, Missouri
>
>
The cscript and wscript host applications provide the Wscript object. The
VBScript must be launched by cscript or wscript for this object to be
available. VB has the Timer object that can be used for similar purposes.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 09-03-2008   #3 (permalink)
Mark Dougherty


 
 

Re: Microsoft VBScript runtime error: Object doesn't support this property or method: 'WScript.Sleep'

Richard, thanks for the prompt response! Here's a little more info...

The VBscript is called from inside a batch file and then the calling batch
file is scheduled as a Windows task or is called from inside a VB app.

The batch file is called StartStopWinServ.Bat and it contains the line:

cscript //nologo c:\scripts\StartStopWindowsService.vbs MyServer Stop
SqlServer >> C:\LogFile.Txt

If the batch file is run interactively - no problems. The rest of the
script works fine, just the Sleep function errors out (and then aborts the
rest of the script).

I'm aware of the VB Timer object, but I need the sleep function inside my
VBscript.

Any suggestions?

Thanks,

Mark


My System SpecsSystem Spec
Old 09-03-2008   #4 (permalink)
James Whitlow


 
 

Re: Microsoft VBScript runtime error: Object doesn't support this property or method: 'WScript.Sleep'

"Mark Dougherty" <dougherty@xxxxxx-stl.com> wrote in message
news:eXeceneDJHA.5060@xxxxxx
Quote:

> Richard, thanks for the prompt response! Here's a little more info...
>
> The VBscript is called from inside a batch file and then the calling batch
> file is scheduled as a Windows task or is called from inside a VB app.
>
> The batch file is called StartStopWinServ.Bat and it contains the line:
>
> cscript //nologo c:\scripts\StartStopWindowsService.vbs MyServer Stop
> SqlServer >> C:\LogFile.Txt
>
> If the batch file is run interactively - no problems. The rest of the
> script works fine, just the Sleep function errors out (and then aborts the
> rest of the script).
Just out of curiosity, have you tried using the AT scheduler to schedule
it to run interactivly? Is this even something you can consider?

at.exe 16:00 /Interactive "[path]\StartStopWinServ.Bat"


My System SpecsSystem Spec
Old 09-03-2008   #5 (permalink)
mayayana


 
 

Re: Microsoft VBScript runtime error: Object doesn't support this property or method: 'WScript.Sleep'

If you can call another script from that
script you can do it. In other wordds, if
you put another .vbs file in the same path,
or on a path known to the original script,
you can call a sub in your original script
like so:

Sub Sleep(MSecs)
Dim Ret
On Error Resume Next
Ret = SH.Run("sleeper.vbs " & MSecs, , True)
End Sub

The second script, sleeper.vbs, then contains
only this:

Dim Arg
on error resume next
Arg = WScript.Arguments(0)
wscript.sleep Arg

The last parameter of the Run function set to True
causes it to wait until the called process finishes. So by
causing a sleep in the second script you get a sleep
in your original script. You use it like so:

Sleep 5000 '-- causes 5 second sleep.

Quote:

> Richard, thanks for the prompt response! Here's a little more info...
>
> The VBscript is called from inside a batch file and then the calling batch
> file is scheduled as a Windows task or is called from inside a VB app.
>
> The batch file is called StartStopWinServ.Bat and it contains the line:
>
> cscript file://nologo c:\scripts\StartStopWindowsService.vbs MyServer
Stop
Quote:

> SqlServer >> C:\LogFile.Txt
>
> If the batch file is run interactively - no problems. The rest of the
> script works fine, just the Sleep function errors out (and then aborts the
> rest of the script).
>
> I'm aware of the VB Timer object, but I need the sleep function inside my
> VBscript.
>
> Any suggestions?
>
> Thanks,
>
> Mark
>
>

My System SpecsSystem Spec
Old 09-04-2008   #6 (permalink)
Mark Dougherty


 
 

Re: Microsoft VBScript runtime error: Object doesn't support this property or method: 'WScript.Sleep'

"James Whitlow" <jwhitlow.60372693@xxxxxx> wrote in message
news:OKFFrJgDJHA.528@xxxxxx
+
Quote:

> Just out of curiosity, have you tried using the AT scheduler to
schedule
Quote:

> it to run interactivly? Is this even something you can consider?
>
> at.exe 16:00 /Interactive "[path]\StartStopWinServ.Bat"
>
I have tried running it as an interactive scheduled task (a foreground
command window pops up and you can see the batch file execute) and it still
fails with the same error.

Mark


My System SpecsSystem Spec
Old 09-04-2008   #7 (permalink)
James Whitlow


 
 

Re: Microsoft VBScript runtime error: Object doesn't support this property or method: 'WScript.Sleep'

"Mark Dougherty" <dougherty@xxxxxx-stl.com> wrote in message
news:Onb52opDJHA.4696@xxxxxx
Quote:

> "James Whitlow" <jwhitlow.60372693@xxxxxx> wrote in message
> news:OKFFrJgDJHA.528@xxxxxx
> +
Quote:

>> Just out of curiosity, have you tried using the AT scheduler to
> schedule
Quote:

>> it to run interactivly? Is this even something you can consider?
>>
>> at.exe 16:00 /Interactive "[path]\StartStopWinServ.Bat"
>>
>
> I have tried running it as an interactive scheduled task (a foreground
> command window pops up and you can see the batch file execute) and it
> still
> fails with the same error.
I wonder if perhaps VBScript on your computer is damaged. The reason
that I think it might be is that I created a batch file with your command:

cscript //nologo c:\scripts\StartStopWindowsService.vbs MyServer Stop
SqlServer >> C:\LogFile.Txt

...and a VBScript called 'StartStopWindowsService.vbs' that contained
only a single command, 'WScript.Sleep 5000'. I set an interactive AT task to
execute the batch file. When it ran, I saw the DOS box popup for 5 seconds
and disappear. I repeated the experiment and took out the '/Interactive'
switch. I did not see a DOS box (obviously), but I did see cscript.exe
appear in Task Manger for 5 seconds.


My System SpecsSystem Spec
Old 09-04-2008   #8 (permalink)
Richard Mueller [MVP]


 
 

Re: Microsoft VBScript runtime error: Object doesn't support this property or method: 'WScript.Sleep'


"James Whitlow" <jwhitlow.60372693@xxxxxx> wrote in message
news:%23yBpGxpDJHA.3484@xxxxxx
Quote:

> "Mark Dougherty" <dougherty@xxxxxx-stl.com> wrote in message
> news:Onb52opDJHA.4696@xxxxxx
Quote:

>> "James Whitlow" <jwhitlow.60372693@xxxxxx> wrote in message
>> news:OKFFrJgDJHA.528@xxxxxx
>> +
Quote:

>>> Just out of curiosity, have you tried using the AT scheduler to
>> schedule
Quote:

>>> it to run interactivly? Is this even something you can consider?
>>>
>>> at.exe 16:00 /Interactive "[path]\StartStopWinServ.Bat"
>>>
>>
>> I have tried running it as an interactive scheduled task (a foreground
>> command window pops up and you can see the batch file execute) and it
>> still
>> fails with the same error.
>
> I wonder if perhaps VBScript on your computer is damaged. The reason
> that I think it might be is that I created a batch file with your command:
>
> cscript //nologo c:\scripts\StartStopWindowsService.vbs MyServer Stop
> SqlServer >> C:\LogFile.Txt
>
> ...and a VBScript called 'StartStopWindowsService.vbs' that contained
> only a single command, 'WScript.Sleep 5000'. I set an interactive AT task
> to execute the batch file. When it ran, I saw the DOS box popup for 5
> seconds and disappear. I repeated the experiment and took out the
> '/Interactive' switch. I did not see a DOS box (obviously), but I did see
> cscript.exe appear in Task Manger for 5 seconds.
>
>
Also, Wscript.Sleep requires WSH 5.1 or greater (as I recall). I can't image
your OS is that old, but Sleep was not supported on Win9x unless WSH was
upgraded.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 11-19-2008   #9 (permalink)


vista home basic 32bit
 
 

Re: Microsoft VBScript runtime error: Object doesn't support this property or method:

Hi i have similar doubt

I have a .vbs file that need to be run at system boot up.

how do i do it?


when the file boots up..the results of that file are made into a .csv(comma separated values)

i need to store this file on the network

how shall i do it?

and i dont have any administrative rights

regards
Pranay Mathur
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
capture the error message as a property object PowerShell
438 Object doesn't support this property or method VB Script
Microsoft VBScript runtime error VB Script
Microsoft Visual C++ Runtime Library box with Runtime Error Vista General
Microsoft Visual C++ Runtime Library ...Runtime Error Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46