Saleem
asked on
Shortcut at Windows Start Menu
I used to develop access applications, and I like to code my setup without using the packaging and deployment wizard. I cannot find the code in visual basic that I can use to add the group, item and shortcut at the windows start menu.My OS is Windows Me.
Please help me.
Thank you // By Saleem
Please help me.
Thank you // By Saleem
Search for setup1.vbp on your PC. This is the code that installs application on PCs. You will find the code you need (and many more) in there.
Hi Saleem,
Here you will find what you need just be patient and follow the steps
http://www.vbworld.com/articles/customsetup/
Good Luck:))
Here you will find what you need just be patient and follow the steps
http://www.vbworld.com/articles/customsetup/
Good Luck:))
Here is the VB code to do this:
-->
Public Sub CreateShortCut(strShortcut _Path As String, strShortcut_Target As String)
Dim Scriptshell As IWshShell_Class
Set Scriptshell = New IWshShell_Class
Set oShellLink = Scriptshell.CreateShortCut (strShortc ut_Path)
oShellLink.TargetPath = strShortcut_Target
oShellLink.Save
End Sub
<--
Its a little tricky ...
Important:
You must links the "Windows Script Host Object Model (V1.0)" in your VB project file!
Then you can call the sub like this:
Call CreateShortCut(C:\WINNT\Pr ofiles\All Users\Startmenu\Programme\ New Group\MyApp.lnk", "c:\MyApp\myapp.exe")
MyApp stands for your application. This should work fine for WINNT.
MfG
Wolfgang Koenig (WoK)
-->
Public Sub CreateShortCut(strShortcut
Dim Scriptshell As IWshShell_Class
Set Scriptshell = New IWshShell_Class
Set oShellLink = Scriptshell.CreateShortCut
oShellLink.TargetPath = strShortcut_Target
oShellLink.Save
End Sub
<--
Its a little tricky ...
Important:
You must links the "Windows Script Host Object Model (V1.0)" in your VB project file!
Then you can call the sub like this:
Call CreateShortCut(C:\WINNT\Pr
MyApp stands for your application. This should work fine for WINNT.
MfG
Wolfgang Koenig (WoK)
ASKER
I tried that but I got an error message!
Hi!
Here's a file for you over the net:
Download...
http://www.vb-helper.com/Howto/shortcut.zip
Description: Create shortcuts on the desktop or in the Start menu (3K)
Another radical method would be to open up the code that makes up your deployment wizard (*.frm files) and try to decipher the mess. Maybe the code is there (tried that when I was a beginner in VB - freaked out as a beginner and haven't attempted since after many years).
That's it!
glass cookie : )
Here's a file for you over the net:
Download...
http://www.vb-helper.com/Howto/shortcut.zip
Description: Create shortcuts on the desktop or in the Start menu (3K)
Another radical method would be to open up the code that makes up your deployment wizard (*.frm files) and try to decipher the mess. Maybe the code is there (tried that when I was a beginner in VB - freaked out as a beginner and haven't attempted since after many years).
That's it!
glass cookie : )
What for an error and in which code line ?
Important:
You must links the "Windows Script Host Object Model (V1.0)" in your VB project file!
Important:
You must links the "Windows Script Host Object Model (V1.0)" in your VB project file!
The function CreateShortCut has two parameters:
First is path and name of the shortcut
Second is the target path and name of the object which will be linked:
For instance:
Call CreateShortCut("C:\WINNT\P rofiles\Al l Users\Startmenu\Programme\ NewGroup\M yApp.lnk", "c:\myapps\myapp.exe")
The "myapp.exe" must exist
MfG
Wolfgang Koenig
First is path and name of the shortcut
Second is the target path and name of the object which will be linked:
For instance:
Call CreateShortCut("C:\WINNT\P
The "myapp.exe" must exist
MfG
Wolfgang Koenig
I use a real nice tool called CreateInstall to deploy access-based solution.
With it you could:
.Create registry entries
.Create desktop shorcut
.Single/multi volume packages
.Create program folder
.Store and register COM objects.
and many more...
I really love it on first sigth.
http://www.gentee.com
With it you could:
.Create registry entries
.Create desktop shorcut
.Single/multi volume packages
.Create program folder
.Store and register COM objects.
and many more...
I really love it on first sigth.
http://www.gentee.com
ASKER
Wolfgang Koenig
thank you for your help. Would u pls write the call with an example!
My Os is windows me
waiting your ansewr
saleem
thank you for your help. Would u pls write the call with an example!
My Os is windows me
waiting your ansewr
saleem
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If no objections are made in the next 4 days, I will force accept WolfgangKoenig's answer.
costello
Community Support Moderator @ Experts-Exchange
costello
Community Support Moderator @ Experts-Exchange
Hi
Enum ShortCutDest
DeskTop
Programs
StartMenu
StartUp
End Enum
Public Function CreateLink(dest As ShortCutDest, ByVal sName As String, ByVal sPath As String, Optional HotKey As String = "", Optional sIcon As String = "", Optional sWorkingDirectory As String, Optional sSubFolder As String = "")
Dim WshShell As Object
Dim oShellLink As Object
Dim sLinkPath As String
Set WshShell = CreateObject("WScript.Shel l")
Select Case dest
Case DeskTop
sLinkPath = WshShell.SpecialFolders("D esktop")
Case StartMenu
sLinkPath = WshShell.SpecialFolders("S tartMenu")
Case StartUp
sLinkPath = WshShell.SpecialFolders("S tartUp")
Case Programs
sLinkPath = WshShell.SpecialFolders("P rograms")
End Select
On Error Resume Next
If sSubFolder <> "" Then
sLinkPath = sLinkPath & "\" & sSubFolder
If Dir(sLinkPath) = "" Then MkDir sLinkPath
End If
On Error GoTo 0
Set oShellLink = WshShell.CreateShortCut(sL inkPath & "\" & sName & ".lnk")
oShellLink.WindowStyle = 1
oShellLink.HotKey = sHotKey
oShellLink.TargetPath = sPath
oShellLink.IconLocation = sIcon
oShellLink.Description = sName
oShellLink.WorkingDirector y = sWorkingDirectory
oShellLink.Save
Set oShellLink = Nothing
Set WshShell = Nothing
End Function
' Now imagine you distribute Calculator :)
Private Sub Command1_Click()
' Create link on desktop
CreateLink DeskTop, "Calculator", "c:\windows\calc.exe", "CTRL+SHIFT+C", "calc.exe,0", "c:\windows"
' Create link in StartMenu
CreateLink StartMenu, "Calculator", "c:\windows\calc.exe", "CTRL+SHIFT+C", "calc.exe,0", "c:\windows"
' Create link in StartUp menu
CreateLink StartUp, "Calculator", "c:\windows\calc.exe", "CTRL+SHIFT+C", "calc.exe,0", "c:\windows"
' Make a Group "WinCalc" in programs menu and create shortcats there
'Main shortcut
CreateLink Programs, "Calculator", "c:\windows\calc.exe", "CTRL+SHIFT+C", "calc.exe,0", "c:\windows", "WinCalc"
' Help Shortcut
CreateLink Programs, "Calculator Help", "c:\windows\help\calc.hlp" , "", "winhlp32.exe,0", "c:\windows", "WinCalc"
' URL shortcut
CreateLink Programs, "Visit our web site", "http://www.microsoft.com", , , , "WinCalc"
End Sub
Cheers
Enum ShortCutDest
DeskTop
Programs
StartMenu
StartUp
End Enum
Public Function CreateLink(dest As ShortCutDest, ByVal sName As String, ByVal sPath As String, Optional HotKey As String = "", Optional sIcon As String = "", Optional sWorkingDirectory As String, Optional sSubFolder As String = "")
Dim WshShell As Object
Dim oShellLink As Object
Dim sLinkPath As String
Set WshShell = CreateObject("WScript.Shel
Select Case dest
Case DeskTop
sLinkPath = WshShell.SpecialFolders("D
Case StartMenu
sLinkPath = WshShell.SpecialFolders("S
Case StartUp
sLinkPath = WshShell.SpecialFolders("S
Case Programs
sLinkPath = WshShell.SpecialFolders("P
End Select
On Error Resume Next
If sSubFolder <> "" Then
sLinkPath = sLinkPath & "\" & sSubFolder
If Dir(sLinkPath) = "" Then MkDir sLinkPath
End If
On Error GoTo 0
Set oShellLink = WshShell.CreateShortCut(sL
oShellLink.WindowStyle = 1
oShellLink.HotKey = sHotKey
oShellLink.TargetPath = sPath
oShellLink.IconLocation = sIcon
oShellLink.Description = sName
oShellLink.WorkingDirector
oShellLink.Save
Set oShellLink = Nothing
Set WshShell = Nothing
End Function
' Now imagine you distribute Calculator :)
Private Sub Command1_Click()
' Create link on desktop
CreateLink DeskTop, "Calculator", "c:\windows\calc.exe", "CTRL+SHIFT+C", "calc.exe,0", "c:\windows"
' Create link in StartMenu
CreateLink StartMenu, "Calculator", "c:\windows\calc.exe", "CTRL+SHIFT+C", "calc.exe,0", "c:\windows"
' Create link in StartUp menu
CreateLink StartUp, "Calculator", "c:\windows\calc.exe", "CTRL+SHIFT+C", "calc.exe,0", "c:\windows"
' Make a Group "WinCalc" in programs menu and create shortcats there
'Main shortcut
CreateLink Programs, "Calculator", "c:\windows\calc.exe", "CTRL+SHIFT+C", "calc.exe,0", "c:\windows", "WinCalc"
' Help Shortcut
CreateLink Programs, "Calculator Help", "c:\windows\help\calc.hlp"
' URL shortcut
CreateLink Programs, "Visit our web site", "http://www.microsoft.com", , , , "WinCalc"
End Sub
Cheers
Saleem
Please finalise this question, even if nobody gave you a satisfactory answer - in that case just let me know and I will be happy to refund your points to you.
If someone did give you a satisfactory answer, please accept the comment as the answer. If you are having problems doing that let me know.
Please do *not* ignore this request. To the other participants in the thread - if no response is forthcoming alert me and I will take action.
Regards
modder
Community Support Admin
Please finalise this question, even if nobody gave you a satisfactory answer - in that case just let me know and I will be happy to refund your points to you.
If someone did give you a satisfactory answer, please accept the comment as the answer. If you are having problems doing that let me know.
Please do *not* ignore this request. To the other participants in the thread - if no response is forthcoming alert me and I will take action.
Regards
modder
Community Support Admin
Useful link: http://www.mvps.org/vbnet/code/shell/shshortcutcheat.htm