Solved

Script to create application link on desktop

Posted on 2014-03-19
4
636 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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

688 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