Link to home
Start Free TrialLog in
Avatar of Saleem
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
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

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.
Avatar of ramy050799
ramy050799

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 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(strShortcut_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\Profiles\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)

 
Avatar of Saleem

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 : )
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!
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\Profiles\All Users\Startmenu\Programme\NewGroup\MyApp.lnk", "c:\myapps\myapp.exe")

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
Avatar of Saleem

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
ASKER CERTIFIED SOLUTION
Avatar of WolfgangKoenig
WolfgangKoenig

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If no objections are made in the next 4 days, I will force accept WolfgangKoenig's answer.

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.Shell")
   Select Case dest
       Case DeskTop
            sLinkPath = WshShell.SpecialFolders("Desktop")
       Case StartMenu
            sLinkPath = WshShell.SpecialFolders("StartMenu")
       Case StartUp
            sLinkPath = WshShell.SpecialFolders("StartUp")
       Case Programs
            sLinkPath = WshShell.SpecialFolders("Programs")
   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(sLinkPath & "\" & sName & ".lnk")
   oShellLink.WindowStyle = 1
   oShellLink.HotKey = sHotKey
   oShellLink.TargetPath = sPath
   oShellLink.IconLocation = sIcon
   oShellLink.Description = sName
   oShellLink.WorkingDirectory = 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
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