Saltar al contenido principal

Búsqueda

Búsqueda

Vbscript To Execute Another Vb Script

Comentarios

9 comentarios

  • Avatar
    Shotaro Ito

    Hi Sean,

    that would be

    Set objShell = CreateObject("WScript.Shell")
    0
  • Avatar
    Legacy Poster

    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
    Moderador

    Try with

     

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

    Hi Domingo,

     

    That actually froze BarTender....

    0
  • Avatar
    Domingo Rodriguez
    Moderador

    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

    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

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

    0
  • Avatar
    Domingo Rodriguez
    Moderador

    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

    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!
    0

Iniciar sesión para dejar un comentario.