Jump to content

Running a vbs file with cscript and variables


Recommended Posts

Hey guys/gals, I hope that this is an easy question and probably just a formatting issue....

I have a vbs file that is located at a location which is stored in the variable $VBSPath. I am trying to execute the vbs file within a script using cscript.exe. I found some other posts in regards to vbs files and cscript but none of them talk about having the path to the vbs file in a variable(at least that I could find). I have tried a whole slew of different combinations of the following command but I'll just include the one I have entered at the moment.

RunWait(@Comspec & " /c cscript.exe " & $VBSPath, @SW_HIDE)

Thanks in advance!

Link to comment
Share on other sites

Hey guys/gals, I hope that this is an easy question and probably just a formatting issue....

I have a vbs file that is located at a location which is stored in the variable $VBSPath.  I am trying to execute the vbs file within a script using cscript.exe.  I found some other posts in regards to vbs files and cscript but none of them talk about having the path to the vbs file in a variable(at least that I could find).  I have tried a whole slew of different combinations of the following command but I'll just include the one I have entered at the moment.

RunWait(@Comspec & " /c cscript.exe " & $VBSPath, @SW_HIDE)

Thanks in advance!

I'm going to go ahead and assume that you're having an error when you run your command. :)

Again assuming that you're assigning a path to a VBS script to the $VBSPath variable, a fairly likely cause for error is that there's a space or other problem character in the path to the script file. You can double-quote the path by using pairs of " characters inside the string declarations, or else declare your strings using single ' quote characters which will let you use " characters inside the strings.

$VBSPath = "G:\foo\problem name.vbs"
RunWait(@Comspec & ' /c cscript.exe "' & $VBSPath & '"', @SW_HIDE)

You also know that if there's any GUI functionality in your VBS script that you have to use WSCRIPT.EXE?

Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Link to comment
Share on other sites

See, I knew it was just a formatting issue! Thanks Dave. I did have to mod your code due to another formatting issue, Didn't include the "" for the path info runwait requires.

Final code:

$VBSPath = "G:\foo\problem name.vbs"

RunWait(@Comspec & ' /c cscript.exe "' & $VBSPath & '"', "",@SW_HIDE)

Thanks again!

Link to comment
Share on other sites

  • 12 years later...
  • Moderators

cu0x,

You obviously did not notice that the post above yours was made nearly 13 years ago. Please do not necro-post like this again.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...