|
-
Apr 8th, 2007, 03:36 PM
#1
Thread Starter
New Member
Adding to TargetPath of a Shortcut
Ok, after searching for hours in these forums for the answer to my question, I decided to sign up and ask it myself. I have been trying to figure how to search for an exe file on the computer, create a shortcut of it, and add some command line parameters to the targetpath. After searching I have found this code:
Code:
Option Explicit
Private Sub Command1_Click()
'This will Create a ShortCut of Notepad in our desktop, its name is "Notepad", minimize windows when run, use the 2nd icon as the Shortcut icon.
Create_ShortCut "C:\WINDOWS\NOTEPAD.EXE", "Desktop", "Notepad", , 7, 1
End Sub
Sub Create_ShortCut(ByVal TargetPath As String, ByVal ShortCutPath As String, ByVal ShortCutname As String, Optional ByVal WorkPath As String, Optional ByVal Window_Style As Integer, Optional ByVal IconNum As Integer)
Dim VbsObj As Object
Set VbsObj = CreateObject("WScript.Shell")
Dim MyShortcut As Object
ShortCutPath = VbsObj.SpecialFolders(ShortCutPath)
Set MyShortcut = VbsObj.CreateShortcut(ShortCutPath & "\" & ShortCutname & ".lnk")
MyShortcut.TargetPath = TargetPath
MyShortcut.WorkingDirectory = WorkPath
MyShortcut.WindowStyle = Window_Style
MyShortcut.IconLocation = TargetPath & "," & IconNum
MyShortcut.Save
End Sub
I am using that to create my shortcut. So I have that part done. However when I try adding a string to the end of it, it puts the string in the quotes of the target path. I want it on the outside.
Now I have a basic knowledge of VB and have taken a high school course in it, but if your going to post a really complicated code, could you please explain it to me? That's why I had to create a thread, because the other threads are too confusing to understand. Thanks for your help. I look forward to your reply.
Also, how are you suppose to copy and paste the code in the code tags? It copies he numbers along with it.
Last edited by gamerkd17; Apr 8th, 2007 at 03:50 PM.
-
Apr 8th, 2007, 04:08 PM
#2
Lively Member
Re: Adding to TargetPath of a Shortcut
Cant answer your first question cause i forgot how and cant find the app which i did it in, but...
 Originally Posted by gamerkd17
Also, how are you suppose to copy and paste the code in the code tags? It copies he numbers along with it.
Check this out:
http://vbforums.com/showthread.php?t=458328
Works very nice, or you can click the "Quote" button on the post which you want the code from then do the normally copy/paste from the editing box.
Ill peek around and try and find the app which i added a string to a Short-Cut... only used it onece and cant rember how, sorry.
_
~ What was once an opinion, became a fact, to be later proven wrong... ~
-
Apr 9th, 2007, 02:21 PM
#3
Thread Starter
New Member
Re: Adding to TargetPath of a Shortcut
Thanks. It's nice to people actually are willing to help you with your problems. I signed up for another forums and everyone didn't bother to help. I really hope you find that app.
-
Jun 3rd, 2007, 03:52 PM
#4
Hyperactive Member
Re: Adding to TargetPath of a Shortcut
OK... I can create the desktop icon but need to add a parameter to the end. It MUST be outside the last quote or the link will not run. The parameter is picked up by my VB app so it knows to do a special task.
My line of code...
.TargetPath = Path & "\" & Filename & ".exe " & Parameter
This is what I get in the icon properties...
"C:\Program Files\Live Update\LU Service.exe -upgrade"
This is what I need...
"C:\Program Files\LU Service\LU Service.exe " -upgrade
Help!!!
-
Jun 3rd, 2007, 06:12 PM
#5
Thread Starter
New Member
Re: Adding to TargetPath of a Shortcut
Yea I never got my problem solved for this. Instead I took a different approach. Project I was doing is over now anyway...
-
Jun 4th, 2007, 05:51 PM
#6
Hyperactive Member
Re: Adding to TargetPath of a Shortcut
I found it!!
use .Arguments and you can get it
.Arguments = "-upgrade"
"C:\Program Files\LU Service\LU Service.exe " -upgrade
-
Jun 4th, 2007, 11:00 PM
#7
Thread Starter
New Member
Re: Adding to TargetPath of a Shortcut
Cool. Could have used that months ago. But oh well..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|