We help IT Professionals succeed at work.

calling a .vbs script from vbscript.

Hi

How can I call sleep.vbs from my vb script?
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMiliseconds As Long)

Sub test()
'how to call sleep.vbs???
End Sub

Open in new window

sleep.vbs
Comment
Watch Question

CERTIFIED EXPERT
Commented:
Shell "Wscript.exe C:\sleep.vbs"

Author

Commented:
thanks for your prompt reply.
The code got stucked at line 3 Char 1

Error Type mismatch: 'Sleep'
Kamaraj SubramanianApplication Support Analyst

Commented:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMiliseconds As Long)  
  
Sub test()
Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run "C:\sleep.vbs", 6, True
set wshshell = nothing
End Sub 

Open in new window

Author

Commented:
itkamaraj: thanks for offering your help.
There is a error 424 missing object on line 4 of your code.
CERTIFIED EXPERT
Commented:
You didn't wrote which vb you're using. If you're using VB6, try Shell command:
Dim RetVal
RetVal = Shell("c:\windows\system32\wscript.exe c:\sleep.vbs", 1)

Open in new window

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Hi, I'm very confused by your request.

You have this code:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMiliseconds As Long)

Open in new window


which is VBA, or VB6 code, and is a sleep function in itself.  You do not need VBScript code to perform a sleep, since you have this.

What are you trying to achieve?

Rob.
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
Just curious, what are you trying to accomplish.  There may be other ways to introduce a delay in the main program without a call to a VBS that just does a SLEEP command.

~bp

Author

Commented:
Sorry for the confusion caused, I was trying to experiment with the sleep function. Thanks for all the help.