Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old November 26th, 2004, 11:28 PM
Journeyman Journeyman is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 20 Journeyman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 19 m 18 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old November 27th, 2004, 02:09 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 22 h 23 m 39 sec
Reputation Power: 181
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

Reply With Quote
  #3  
Old November 27th, 2004, 09:00 PM
Journeyman Journeyman is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 20 Journeyman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 19 m 18 sec
Reputation Power: 0
Quote:
Originally Posted by Doug G
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.


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.

Reply With Quote
  #4  
Old November 29th, 2004, 07:43 AM
dev77's Avatar
dev77 dev77 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: On d Earth ofcourse..!!
Posts: 440 dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 4 Days 16 h 13 m 33 sec
Reputation Power: 372
Quote:
Originally Posted by Journeyman
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

How do u create program shortcuts in VB?
Thanks in advance if u can send sample code.

Reply With Quote
  #5  
Old November 30th, 2004, 02:14 AM
Journeyman Journeyman is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 20 Journeyman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 19 m 18 sec
Reputation Power: 0
Shortcut code

Quote:
Originally Posted by dev77
How do u create program shortcuts in VB?
Thanks in advance if u can send sample code.



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

Reply With Quote
  #6  
Old December 4th, 2004, 01:52 AM
dev77's Avatar
dev77 dev77 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: On d Earth ofcourse..!!
Posts: 440 dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 4 Days 16 h 13 m 33 sec
Reputation Power: 372
Quote:
Originally Posted by Journeyman
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

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?

Reply With Quote
  #7  
Old December 5th, 2004, 02:55 PM
Journeyman Journeyman is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 20 Journeyman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 19 m 18 sec
Reputation Power: 0
Quote:
Originally Posted by dev77
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?



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

Reply With Quote
  #8  
Old December 6th, 2004, 04:36 AM
dev77's Avatar
dev77 dev77 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: On d Earth ofcourse..!!
Posts: 440 dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level)dev77 User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 4 Days 16 h 13 m 33 sec
Reputation Power: 372
It worked.
Thanks...

Reply With Quote
  #9  
Old December 6th, 2004, 11:02 PM
Journeyman Journeyman is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 20 Journeyman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 19 m 18 sec
Reputation Power: 0
dev77 did you have the same problem I'm having in my original post?

Journeyman

Reply With Quote
  #10  
Old December 29th, 2004, 12:49 PM
Brasv Brasv is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 1 Brasv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question When creating shortcuts

Journeyman,
Did you ever find a way to remove the qoute marks in the
Targetpath? Having the same issue.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > When creating shortcuts


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT