Announcement

Collapse
No announcement yet.

Problems calling a vb sript from a vbscript

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems calling a vb sript from a vbscript

    I am new to VB scripting so please be patient with me.

    I am trying to "call" or "execute" a VB script file from within a VB Script.

    The problem is that if the .vbs file has a space in the name, or a space in the path to the file name, then WSHShell.run always fails. If there are no spaces in the file name or to the path to the .vbs file, the code works perfectly. Even when I used the fully quotated UNC path name, WSHShell.run still fails.

    Here is the code I am using that does NOT work:

    Set WSHShell = CreateObject("WScript.Shell")
    WSHShell.Run "Map Printers.vbs"
    ' or
    WSHShell.Run "Scripts\Map Printers.vbs"

    Here is the code I am using that DOES work:

    Set WSHShell = CreateObject("WScript.Shell")
    WSHShell.Run "MapPrinters.vbs"
    ' or
    WSHShell.Run "scripts\MapPrinters.vbs"


    What is the correct syntax required to use to run a VB script from a VB script which has spaces in the filename or spaces within the path to the file name?

    Thanks in advance,

    Bob Seeds

  • #2
    Re: Problems calling a vb sript from a vbscript

    WSHShell.Run "Map Printers.vbs"
    The filename contains spaces. There for you must put the "path\file" between quotes.
    The quotes you use are nessesary in vbs to wrap text. So there must be extra quotes added to the filename. But, you can not do it like this:
    wrong: WSHShell.Run ""path to\Map Printers.vbs""
    Because the next single quote would be a end of string to the vbscript.
    You must use double sets of quotes if it is for within the stringvalue quotes, like this:
    good: WSHShell.Run """path to\Map Printers.vbs"""

    (Or, replace the double set of quote-signs for the ascii value of one quote-sign
    http://www.google.com/search?q=vbs+q...a+string&meta= )

    \Rems
    Last edited by Rems; 31st January 2008, 22:13.

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: Problems calling a vb sript from a vbscript

      Thank you verrrry much!

      Comment


      • #4
        Re: Problems calling a vb sript from a vbscript

        oops , there were to many quotes in the samples I showed.

        I have now corrected the samples in my previous script.


        \Rems

        This posting is provided "AS IS" with no warranties, and confers no rights.

        __________________

        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts

        Comment

        Working...
        X