Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing Quotes 1

Status
Not open for further replies.

gmagerr

Technical User
Aug 11, 2001
323
US
Hello Everyone
I have a script that creates a desktop shortcut. In the targetpath I need to remove all quotes, so instead of
"c:\MyDirectory\MyProgram.exe"
I would like it to read
c:\MyDirectory\MyProgram.exe
I think windows puts the quotes there by default. Is there a way to strip the quotes out? Thanks.
 
Have a look at the Replace function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Shades of thread329-1200042?

I think windows only puts the quotes there by default if the string specified in TargetPath contains any spaces.

Hugh
 
Thanks for the replies. I tried all of that. Here's what i have
Code:
Call DesktopSC("Internet Explorer (Safe)", "C:\DropMyRights\DropMyRights.exe", "C:\Program Files\Internet Explorer\IEXPLORE.EXE", "C:\DropMyRights")

'==========================================================================
'Useage
'Call DesktopSC ("Test", "C:\Documents and Settings", "C:\Documents and Settings")
'==========================================================================
Sub DesktopSC (strName, strPath, strPath2, strDir)

    If TestMode = True Then
      wscript.echo "=========== Desktop Shortcut ==========" & vbCrLf &_
      "Adding Short Cut  : " & strName &   ".lnk To the desktop"
      'wscript.echo "Target Path       : " & tpath
      'wscript.echo "Working Directory : " & tdir
    End If
    
    Set WshShell = WScript.CreateObject("WScript.Shell")
    strDesktop = WshShell.SpecialFolders("Desktop")
    Set oShellLink = WshShell.CreateShortcut(strDesktop & "\" & strName & ".lnk")
    oShellLink.TargetPath = Chr(34) & strPath & Chr(34) & " " & _
    Chr(34) &  strPath2 & Chr(34)
    oShellLink.WindowStyle = 1
    'oShellLink.Hotkey = "CTRL+SHIFT+F"
    oShellLink.IconLocation = "C:\Program Files\Internet Explorer\IEXPLORE.EXE, 0"
    oShellLink.Description = strName & "Shortcut"
    oShellLink.WorkingDirectory = strDir
    oShellLink.Save

End Sub
 
Sorry wrong one, here's the one I'm trying to fix

Code:
Call DesktopSC("Internet Explorer (Safe)", "C:\DropMyRights\DropMyRights.exe", "C:\Program Files\Internet Explorer\IEXPLORE.EXE", "C:\DropMyRights")

'==========================================================================
'Useage
'Call DesktopSC ("Test", "C:\Documents and Settings", "C:\Documents and Settings")
'==========================================================================
Sub DesktopSC (strName, strPath, strPath2, strDir)

    If TestMode = True Then
      wscript.echo "=========== Desktop Shortcut ==========" & vbCrLf &_
      "Adding Short Cut  : " & strName &   ".lnk To the desktop"
      'wscript.echo "Target Path       : " & tpath
      'wscript.echo "Working Directory : " & tdir
    End If
    
    Set WshShell = WScript.CreateObject("WScript.Shell")
    strDesktop = WshShell.SpecialFolders("Desktop")
    Set oShellLink = WshShell.CreateShortcut(strDesktop & "\" & strName & ".lnk")
    oShellLink.TargetPath = Replace(strPath, Chr(34), "") & " " & Chr(34) &  strPath2
    oShellLink.WindowStyle = 1
    'oShellLink.Hotkey = "CTRL+SHIFT+F"
    oShellLink.IconLocation = "C:\Program Files\Internet Explorer\IEXPLORE.EXE, 0"
    oShellLink.Description = strName & "Shortcut"
    oShellLink.WorkingDirectory = strDir
    oShellLink.Save

End Sub
 
Replace this:
oShellLink.TargetPath = Chr(34) & strPath & Chr(34) & " " & _
Chr(34) & strPath2 & Chr(34)
with this:
oShellLink.TargetPath = Chr(34) & strPath & Chr(34)
oShellLink.Arguments = Chr(34) & strPath2 & Chr(34)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
OH YEAH PH!!! PERFECT!!! Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top