calling another vbs using variable folder name in script-VBForums
Results 1 to 3 of 3

Thread: calling another vbs using variable folder name in script

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    1

    calling another vbs using variable folder name in script

    I have an hta which when a button is pressed calls another vbs
    This worked using the real folder path, but I have changed it so it's a variable:

    staff_path= "\\servername\applications\backgrounds\STAFF_SUBJECT_MENUS"


    Now this line works fine to set the background picture for the hta:


    <BODY BACKGROUND=staff_path&"\"&"admin_resources.jpg">

    But this line doesn't when it tries to run a vbs:

    Sub assist
    Set objShell = CreateObject("WScript.Shell")
    result = objShell.run staff_path&"\"&msra_prompt.vbs
    End Sub

    I get "expected end od statement"

    Original line which worked was:

    Sub assist
    Set objShell = CreateObject("WScript.Shell")
    result = objShell.run("""\\servername\applications\backgrounds\STAFF_SUBJECT_MENUS\msra_prompt.vbs""")
    End Sub

    Can someone please give me a clue?
    Thanks
    Dan

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    3,184

    Re: calling another vbs using variable folder name in script

    Quote Originally Posted by danny_chev View Post
    But this line doesn't when it tries to run a vbs:

    Code:
    Sub assist
    Set objShell = CreateObject("WScript.Shell")
    result = objShell.run staff_path&"\"&msra_prompt.vbs
    End Sub
    I get "expected end of statement"
    When a function returns its result to a variable, its parameters should be enclosed in parentheses. If the return value is discarded, then the parentheses should be left out.

    Code:
    Result = objShell.Run(staff_path & "\msra_prompt.vbs")
    Try this:

    Code:
    staff_path = "\\servername\applications\backgrounds\STAFF_SUBJECT_MENUS\"    'Append trailing slash
    
    Sub Assist()
        CreateObject("WScript.Shell").Run """" & staff_path & "msra_prompt.vbs"""
    End Sub
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3
    Super Moderator Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,521

    Re: calling another vbs using variable folder name in script

    Moved to the VBScript forum
    Joacim Andersson
    If anyone's answer has helped you, please show your appreciation by rating that answer.
    I'd rather run ScriptBrix...
    Joacim's view on stuff.

    MVP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.