Solved

Script to create application link on desktop

Posted on 2014-03-19
4
606 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
  • 3
4 Comments
 
LVL 11

Assisted Solution

by:itguy565
itguy565 earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
thank you
0
 

Author Closing Comment

by:Bianca
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now