grendell2099
17th April 2009 12:09 UTC
Special ShortCut with Short File Paths
I need some help creating a “special†shortcut. I have read a lot of posts here but am not finding my answer. The shortcut is for an Access file with workgroup security so it has a long string by the time you get the 3 filepaths and commands put together. I am trying to use short paths for the necessary files so I do not hit the 256 character limit on the string.
I figured out how to get the quotes in the correct places, but now I cannot get the short file path to show up in the shortcut. It appears correctly in the String2 variable, but the shortcut created has the long path. Below is the code I am using (with short file paths just for testing- the real ones are quite long). Can anyone advise on what I am missing?
# name the installer
outFile "CreateShortCut.exe"
Var String2
!define MyTest "MSACCESS.EXE"
section
SetOutPath $INSTDIR
GetFullPathName /SHORT $String2 "C:\Program Files\Microsoft Office\Office10\MSACCESS.EXE"
DetailPrint $String2
CreateShortCut "TESTshortCut.lnk" $String2 '/user BOB /wrkgrp "F:\WRKGP.mdw"/pwd "PW" "C:\TEMP_JUNK\TEST.mde"' ""
;Quit
sectionEnd
Anders
17th April 2009 12:42 UTC
windows probably thinks its helping out and coverts the path for you
its probably better to create a shortcut to a batch file (or a little nsis app or a windows scripting host script) that runs the command for you
@echo off
start MSACCESS.EXE /foo /bar
cls
only problem with that is that it will flash a black screen for 1 second (you can probably set the shortcut to start minimized)
or a scripting host script, something like
var s=WScript.CreateObject("WScript.Shell");
s.Run("MSACCESS.EXE /param1 \"quoted param\" /param3");
the shortcut would have to execute "$sysdir\wscript.exe" with "$instdir\yourscript.js" as a parameter
BUT, the real way to do this is to use COM automation in a windows scripting host script
in VBScript it would probably look something like
dim acc
set acc = CreateObject("Access.Application")
with acc
.Visible=true
.OpenCurrentDatabase "C:\path\file.mdb"
....etc...
end with
(not that I have ever done any office automation)
grendell2099
17th April 2009 12:57 UTC
Thanks for the input Anders. I had been thinking of this in terms of getting a shortcut set up during installation (there is always one computer with a weird exe location). However, I already use a small NSIS "launcher" to check for updates and open the database... it makes more sense to have the launcher find the correct exe and use it there.
I will approach it that way and see what I come up with.
Anders
17th April 2009 13:05 UTC
with com automation, you don't need to know where the exe is
grendell2099
20th April 2009 11:33 UTC
Thanks again Anders for the assist. I haven't used com automation so I have some studying to do...