Error using WSH Run method with long path names

Discussion in 'AutoCAD' started by Jimmy Bergmark, Dec 25, 2003.

  1. Using short paths it works but not with long paths, why?

    Using Vlisp this doesn't work:
    (setq WshShell (vlax-create-object "WScript.Shell"))
    (vlax-invoke-method wshshell 'Run """C:\\Program Files\\Autodesk\\Autodesk
    Express Viewer\\ExpressViewer.exe"" C:\\New Folder\\Test.DWF" 3 :vlax-false)

    On the other hand this works:
    (vlax-invoke-method wshshell 'Run "calc.exe" 3)

    or

    (vlax-invoke-method wshshell 'Run
    "C:/Progra~1/Autodesk/Autode~1/Expres~1.exe C:\\New Folder\\Test.DWF" 3
    :vlax-false)

    Using VBA it works:
    Public Sub test()
    Dim WshShell
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run """C:\Program Files\Autodesk\Autodesk Express
    Viewer\ExpressViewer.exe"" ""C:\New Folder\Test.DWF""", 3, False
    End Sub

    --
    Best Regards, Jimmy Bergmark
    CAD and Database Developer Manager at www.pharmadule-emtunga.com
    Take a look at the trial version of SmartPurger or
    download some freeware at www.jtbworld.com
    More on AutoCAD 2004;
    www.jtbworld.com/autocad2004.htm
    www.jtbworld.com/autocad2004tips.htm
     
    Jimmy Bergmark, Dec 25, 2003
    #1
  2. Check your quotes:

    (vlax-invoke-method
    wshshell
    'Run
    "\"C:\\Program Files\\Autodesk\\Autodesk Express
    Viewer\\ExpressViewer.exe\" C:\\Temp\\Test.DWF"
    3
    :vlax-false)


    Note that I wrapped the long filename in escaped quotes (\") and only a
    single outer pair of quotes for the entire string.


    --
    R. Robert Bell, MCSE
    www.AcadX.com


    | Using short paths it works but not with long paths, why?
    |
    | Using Vlisp this doesn't work:
    | (setq WshShell (vlax-create-object "WScript.Shell"))
    | (vlax-invoke-method wshshell 'Run """C:\\Program Files\\Autodesk\\Autodesk
    | Express Viewer\\ExpressViewer.exe"" C:\\New Folder\\Test.DWF" 3
    :vlax-false)
    |
    | On the other hand this works:
    | (vlax-invoke-method wshshell 'Run "calc.exe" 3)
    |
    | or
    |
    | (vlax-invoke-method wshshell 'Run
    | "C:/Progra~1/Autodesk/Autode~1/Expres~1.exe C:\\New Folder\\Test.DWF" 3
    | :vlax-false)
    |
    | Using VBA it works:
    | Public Sub test()
    | Dim WshShell
    | Set WshShell = CreateObject("WScript.Shell")
    | WshShell.Run """C:\Program Files\Autodesk\Autodesk Express
    | Viewer\ExpressViewer.exe"" ""C:\New Folder\Test.DWF""", 3, False
    | End Sub
    |
    | --
    | Best Regards, Jimmy Bergmark
    | CAD and Database Developer Manager at www.pharmadule-emtunga.com
    | Take a look at the trial version of SmartPurger or
    | download some freeware at www.jtbworld.com
    | More on AutoCAD 2004;
    | www.jtbworld.com/autocad2004.htm
    | www.jtbworld.com/autocad2004tips.htm
    |
    |
    |
     
    R. Robert Bell, Dec 25, 2003
    #2
  3. Jimmy Bergmark, Dec 25, 2003
    #3
  4. Glad to have helped.



    | Thanks for remembering me of \"
    |
     
    R. Robert Bell, Dec 25, 2003
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.