![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 > > 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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). it to run interactivly? Is this even something you can consider? at.exe 16:00 /Interactive "[path]\StartStopWinServ.Bat" |
My System Specs![]() |
| | #5 (permalink) |
| | 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 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 Specs![]() |
| | #6 (permalink) |
| | 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 Quote: > it to run interactivly? Is this even something you can consider? > > at.exe 16:00 /Interactive "[path]\StartStopWinServ.Bat" > command window pops up and you can see the batch file execute) and it still fails with the same error. Mark |
My System Specs![]() |
| | #7 (permalink) |
| | 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 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. 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 Specs![]() |
| | #8 (permalink) |
| | 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 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. > > 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 Specs![]() |
| | #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 Specs![]() |
![]() |
| 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 | |||