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
Re: calling another vbs using variable folder name in script
Quote:
Originally Posted by
danny_chev
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
Re: calling another vbs using variable folder name in script
Moved to the VBScript forum