-
Jan 28th, 2013, 07:11 AM
#1
Thread Starter
New Member
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
-
Jan 28th, 2013, 04:00 PM
#2
Re: calling another vbs using variable folder name in script
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
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)
-
Jan 28th, 2013, 04:21 PM
#3
Re: calling another vbs using variable folder name in script
Moved to the VBScript forum
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|