Vbscript To Execute Another Vb Script S’abonner

0
Avatar
Legacy Poster

I've been trying the following, and get an error "<Line 2: : Object required: 'WScript'>"

 

What am I doing wrong here?

 

Dim objShell

Set objShell =
Wscript.CreateObject("WScript.Shell")

objShell.Run "\\servername\file\anotherfile\testscript.vbs"

 

I'd appreciate any help! Many thanks! :)

Sean

9 commentaires

0
Avatar
Shotaro Ito
Actions pour les commentaires Permalien

Hi Sean,

that would be

Set objShell = CreateObject("WScript.Shell")
0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Okay, now I have:

 

Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "\\servername\file\anotherfile\testscript.vbs"
 
But I'm getting another error <Line3: : Unknown script error.>
0
Avatar
Domingo Rodriguez
Modérateur
Actions pour les commentaires Permalien

Try with

 

dim ObjShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "cscript \\servername\file\anotherfile\testscript.vbs"
 
 
instead
0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Hi Domingo,

 

That actually froze BarTender....

0
Avatar
Domingo Rodriguez
Modérateur
Actions pour les commentaires Permalien

What is your testscript doing exactly? Have you tried with a very simple "MsgBox ()" one?

 

I just tried to run these lines without having actually a .vbs program to launch, but I received a command prompt dialog saying that the VBS wasn't found, so at least it performed the command...

 

Also, what is the purpose of running the VBScript within another VBScript? Can you just not paste the VBScript code directly in BarTender or automate BarTender in a different fashion?

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Long story short, if you update a component's VB Scipt, it wont update the OTHER files that component is being used on. I want the component to refer to a master script so all my 1000+ files can update together.

 

Here is the script: left(Application.SystemUsername, 7) & ".png"

 

The component is an image looking in a certain folder, and this script tells it the file name to be looking for by formatting a user's username

0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

I'm guessing my BarTender script may need some kind of subroutine to pull that value back from the testscript

0
Avatar
Domingo Rodriguez
Modérateur
Actions pour les commentaires Permalien

Have you tried running a different VBScript Testscript, such as just:

 

MsgBox ("This is a test")

 

 

Will this one work when using 

 

dim ObjShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "cscript \\servername\file\anotherfile\testscript.vbs"
0
Avatar
Legacy Poster
Actions pour les commentaires Permalien

Found a solution! Here it is if anybody is curious:

 

Component script:

Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile("\\server\file\anotherfile\testscript.vbs")
body = ts.ReadAll
ts.Close
Execute body
 
File script:
value= 'whatever you want to script!
 
This will make a component that refers to a master script!

Vous devez vous connecter pour laisser un commentaire.