This is how i do it
you have to put quotes between long names with spaces like "Program Files" path_longName function does it.
regardsCode:Dim objShell As Object Set objShell = CreateObject("Wscript.Shell") Dim szScriptPath As String szScriptPath = path_longName(appDir & "\Scripts\Copy2Output.cmd") objShell.Run ("%comspec% /K " & szScriptPath & " " & szoutdir), 1, True Function path_longName(str As String) As String Dim firstPhrase, secoundPhrase As String Dim word As String Dim sztmp As String Dim i, j, l, k As Integer sztmp = str path_longName = sztmp firstPhrase = "" lastPhrase = "" word = "" ' Add "" betweent folders in the path if space exist in the folder name i = Len(sztmp) l = 3 ' For first loop entry, determine "drive letter:\" For j = 3 To i firstPhrase = Left(sztmp, l) ' Cut 1 phrase k = i - j ' To get another letter secoundPhrase = Right(sztmp, k) ' Cut 2 phrase + another k letter word = Replace(sztmp, firstPhrase, "") ' delete 1 phrase word = Replace(word, secoundPhrase, "") ' Delete 2 phrase If InStr(word, "\") Or j = Len(sztmp) Then ' Check if folder name include "\" ' Delete "\" word = Replace(word, "\", "") ' Check if spaces exist in the world If InStr(word, " ") > 0 Then word = Chr(34) & word & Chr(34) If j = Len(sztmp) And Right(sztmp, 1) <> "\" Then path_longName = firstPhrase & word & secoundPhrase Else path_longName = firstPhrase & word & "\" & secoundPhrase End If End If l = j ' Send parameter to cut 1 phrase End If Next j End Function




Reply With Quote
