|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
When creating shortcuts
I'm writing a program that at the end it creates a program shortcut, I pass to the target path a string from a string variable. My problem is when the shortcut is created the target path includes the quote marks " at the bigining and end of the string. I realize that a string variable need the " marks and when I pass the same variable to a text box the " marks do not show up. Does anyone know how to remove the " marks from the shortcut target path?
Thanks |
|
#2
|
|||
|
|||
|
Are you sure you want to? If you have paths that have spaces you need the quotes, like in "c:\Program Files\Some Program"
This path will fail from code if you don't have the quotes.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
|||
|
|||
|
Quote:
Thanks Doug, I need to remove the "" because when I double click the new shortcut it fails due to path not found, When I remove the "" then the shortcut works just fine. The program I'm writing this for should not ever have long file names requiring the "" marks. Thanks for the post. |
|
#4
|
||||
|
||||
|
Quote:
How do u create program shortcuts in VB? Thanks in advance if u can send sample code. |
|
#5
|
|||
|
|||
|
Shortcut code
Quote:
dev77 Thanks for your post! The first thing you must check when creating a shortcut is if you have a reference to Windows Script Host Object Model by navigating from the project menu to references. In the references window look for Windows Script Host Object Model and place a check mark in the check box. If you don’t see Windows Script Host Object Model, then click the Browse button, the window should open to System32, look for the wshom.ocx file. Double click the ocx file. Click the OK button on the references window. Once done copy the code below: Place the following two lines in the General Declarations section: 'Used to create a shortcut Dim Shell As WshShell Dim Shortcut As WshShortcut Place the following lines in your Sub: 'This initializes the object WshShell Set objShell = New WshShell 'This initializes the object WshShortcut 'Place the complete path to where you want to create the .LNK file. You must include the .LNK extension Set objShortcut = objShell.CreateShortcut(Your .LNK file path here) 'Place the Target path here. Note the target path is the path to the exe file you are creating the shortcut for. objShortcut.TargetPath = Target path here. 'optional - any command line supported by the file indicated in txtTarget.Text 'objShortcut.Arguments = xxxx 'optional - a valid icon file : = Note if you are using the same icon as the target do not use the line below. objShortcut.IconLocation = Icon path here 'Saves the shortcut. objShortcut.Save |
|
#6
|
||||
|
||||
|
Quote:
Thanks Journeyman, Tried the code and its working. One more question is can i create a shortcut on desktop using VB code ? If yes, how? |
|
#7
|
|||
|
|||
|
Quote:
Using the code above dim another string variable something like strMyDesktpPth = WshShell.SpecialFolders("Desktop") then use this variable in the following line: Set objShortcut = objShell.CreateShortcut(strMyDesktpPth & "\Myfile.lnk") This should work. Journeyman |
|
#8
|
||||
|
||||
|
It worked.
Thanks... |
|
#9
|
|||
|
|||
|
dev77 did you have the same problem I'm having in my original post?
Journeyman |
|
#10
|
|||
|
|||
|
Journeyman,
Did you ever find a way to remove the qoute marks in the Targetpath? Having the same issue. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > When creating shortcuts |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|