?
Solved

Script to create application link on desktop

Posted on 2014-03-19
4
Medium Priority
?
651 Views
Last Modified: 2014-03-24
I have pulled out what stubble I have as hair trying to figure this.  I have some code that deletes an old desktop link and creates a new one however, the link I want created has in it's target a command and switch.  Normal creation this works fine, script it and the quotes that are required are passed. Adding code to eliminate quotes results in no space between application executable and switch, add code to inject a space in ANY format results in the preceding and ending quotes showing up again... clues?

Code as follows:

'begin shortcut creation function
strWorkDir ="C:\Directory" 
strAppPath = "c:\Directory\File.exe dbserver=server\instance"
strIconPath ="C:\Directory\File.exe"
'
Set objShell = CreateObject("WScript.Shell") 
objDesktop = objShell.SpecialFolders("Desktop")
Set objLink = objShell.CreateShortcut(objDesktop & "\File.lnk")
'
objLink.Description = "File"  
objLink.IconLocation = strIconPath  
objLink.TargetPath = strAppPath
objLink.WindowStyle = 3 
objLink.WorkingDirectory = strWorkDir 
objLink.Save
'end function

Open in new window

0
Comment
Question by:Bianca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 11

Assisted Solution

by:itguy565
itguy565 earned 2000 total points
ID: 39940136
This should help:

http://support.microsoft.com/kb/244677

WshShell = CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
oMyShortCut= WshShell.CreateShortcut(strDesktop+"\Foxtest.lnk")
oMyShortCut.WindowStyle = 7  &&Minimized 0=Maximized  4=Normal 
oMyShortcut.IconLocation = home()+"wizards\graphics\builder.ico"
oMyShortCut.TargetPath = "c:\Program Files\Microsoft Visual Studio\VFP98\vfp6.exe" 
oMyShortCut.Arguments = '-c'+'"'+Home()+'config.fpw'+'"'
oMyShortCut.WorkingDirectory = "c:\"
oMyShortCut.Save

Open in new window

0
 

Accepted Solution

by:
Bianca earned 0 total points
ID: 39940223
Thank you itguy565,

I didn't bother with the code listed but one key point in the code provided did give me a clue and it was a "duh" moment... "Argument"!  I added this string and objectlink to my code and BINGO... it works. Thanks for steering me in the right direction.
0
 

Author Comment

by:Bianca
ID: 39940243
thank you
0
 

Author Closing Comment

by:Bianca
ID: 39949816
Thank you itguy565, this is how the code played out in the end:

Code as follows:

'begin shortcut creation function
strWorkDir ="C:\Directory"
strAppPath = "c:\Directory\File.exe"
strArgument =  "dbserver=server\instance"
strIconPath ="C:\Directory\File.exe"
'
Set objShell = CreateObject("WScript.Shell")
objDesktop = objShell.SpecialFolders("Desktop")
Set objLink = objShell.CreateShortcut(objDesktop & "\File.lnk")
'
objLink.Description = "File"  
objLink.IconLocation = strIconPath  
objLink.TargetPath = strAppPath
objLink.Argument = strArgument
objLink.WindowStyle = 3
objLink.WorkingDirectory = strWorkDir
objLink.Save
'end function
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question