0

For example, if I have two vbscript files: A.vbs and B.vbs. I would like the vbscript in B.vbs to execute A.vbs, such peudo-code would look like the following:

'B.vbs
execute("A.vbs")

Just as simple as this line, but I couldn't really find a valid syntax to accomplish such task. Hope someone could help me out, thanks.

4 Answers 4

1
Dim oShell 
Set oShell = Wscript.CreateObject("WScript.Shell")
oShell.Run "name_of_vbs_file_here.vbs"   
Set oShell = Nothing 
Sign up to request clarification or add additional context in comments.

1 Comment

that will execute a script yes but without any interaction with the calling script
0

The following will execute a.vbs as it were a part of the calling script itself

include "a.vbs" 

sub include(script)
  dim fso, file
  set fso = createObject ("Scripting.Filesystemobject")
  if fso.FileExists (script) then 
    set file = fso.OpenTextFile (script)
    executeGlobal file.ReadAll ()
    file.Close 
    set file = nothing 
  end if 
  set fso = nothing 
end sub 

Comments

0
Dim Shell
Set Shell = CreateObject ("WScript.Shell")
Shell.Run "a.vbs"

You can also spice it up a little by adding things like "SendKeys" or other Shells.

Comments

0
createobject("wscript.shell").run"a.vbs"

or if your files aren't in the same folder

createobject("wscript.shell").run"""C:\Users:\User:\YourFolder\a.vbs"""

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.