Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a shortcut on the desktop to Access (runtime)? 5

Status
Not open for further replies.

kaiana

Programmer
Sep 6, 2002
85
0
0
AU
I have created an exe using VB6 that creates a shortcut to a database (Access). The exe is run on the completion of the Database(P&D) install. The exe shows a form saying "Do you wish to create a shortcut on the desktop?" YES NO. The exe works fine and creates a shortcut including custom Icon on the desktop. The problem I am having is the target path opens my database in access and not as a runtime. I have been unable to find a way to put the runtime path ("C:\Program Files\Common Files\Microsoft Shared\Access Runtime\Office10\MSACCESS.EXE")followed by (/Runtime"C:\Program Files\PERT\PERT.mdb")into the target path.

first it rejects the double path. When i place the second path into the .Arguments I get the double path but it rejects the /.

any sugestions ?

I have included my code.

It works great with .exe's and .mdb"s I have noticed alot of threads looking for a shortcut creater so I will spell it out.

Create a form with a yes and no buttons
make reference to 'Windows Script Host Object Model'Its near the end

paste the following code
-------------------------------------------------------

Private Sub Command1_Click()
' yes click
CreateMyShortcut "C:\Program Files\PERT", "PERT.lnk"
End
End Sub
________________________________________________________

Private Sub Command2_Click()
' no click
End
End Sub

---------------------------------------------------------

Create a new module and paste the following

---------------------------------------------------------
Option Explicit

Public Sub CreateMyShortcut(strTarget As String, strShortCutName As String, Optional strStartIn As String = "", Optional strArguments As String = "")
Dim wsh As Object
Dim sf As Object
Dim Shortcut As Object

Set wsh = CreateObject("wscript.shell")
Set sf = wsh.SpecialFolders

' Creates shortcut on desktop
Set Shortcut = wsh.CreateShortcut(sf("AllUsersDesktop") & "\" & strShortCutName)
Shortcut.TargetPath = "C:\Program Files\Common Files\Microsoft Shared\Access Runtime\Office10\MSACCESS.EXE"
Shortcut.IconLocation = "C:\Program Files\PERT\pert.ico"
Shortcut.WorkingDirectory = "C:\Program Files\PERT\"
Shortcut.Description = "DEVELOPED BY iASSIST SOFTWARE DEVELOPERS"
Shortcut.Arguments = "C:\Program Files\PERT\PERT.mdb"
Shortcut.Save

' Creates shortcut in statrup
Set Shortcut = wsh.CreateShortcut(sf("AllUsersStartup") & "\" & strShortCutName)
Shortcut.TargetPath = "C:\Program Files\PERT\PERT.mdb"
Shortcut.IconLocation = "C:\Program Files\PERT\pert.ico"
Shortcut.WorkingDirectory = "C:\Program Files\PERT\"
Shortcut.Arguments = strArguments
Shortcut.Save

End Sub

___________________________________________________________


Let me know if this helps anyone

I would like to thank all members of this forum for all your priceless information.
 
Kaiana,

Try this format:

"C:\Program Files\Access 97 Runtime\Msaccess.exe" /excl /runtime "C:\Program Files\Sample\test_db.mdb"

LLDevel
 
Thanks lldevel but the problem is that code wont accept anything outside the "" so if I put

"path" /Runtime

then a runtime error occures rejecting the /

If I put

"Path" & "/" & "Runtime"

The Path no longer contains the inverted commas

What I require is the path to look like this

"C:\Program Files\Common Files\Microsoft Shared\Access Runtime\Office10\MSACCESS.EXE" /Runtime "C:\Program Files\PERT\PERT.mdb"


The .targetpath only inserts the last path in the "" eg


"C:\Program Files\PERT\PERT.mdb"

I have tried alot of variations. is there some way i can include Inverted commas, inside Inverted commas.

I have also tried

dim tes as string
tes= "/Runtime"
shortcut.targetpath= tes & "C:\Program Files\PERT\PERT.mdb"

or

shortcut.targetpath = "C:\Program Files\Common Files\Microsoft Shared\Access Runtime\Office10\MSACCESS.EXE" & tes

I hope this makes sence

Can someone help?

Once again thanks
 
Build the string using chr(34) instead of the " mark.

To make this string
"C:\Program Files\Common Files\Microsoft Shared\Access Runtime\Office10\MSACCESS.EXE" /Runtime "C:\Program Files\PERT\PERT.mdb"
use:
myStr = chr(34) & C:\Program Files\Common Files\Microsoft Shared\Access Runtime\Office10\MSACCESS.EXE & chr(34) & /Runtime & chr(34) & C:\Program Files\PERT\PERT.mdb & chr(34)
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
I havent tried it yet but I took one look at your solution and just knew it was the answer. Thanks to everyone for your help. And special thanks to those who can think outside the box.

Jason Spence
 
Here it is

Create a form with a yes and no buttons
make reference to 'Windows Script Host Object Model'Its near the end

paste the following code
-------------------------------------------------------

' yes click
Private Sub Command1_Click()
CreateMyShortcut "C:\Program Files\PERT\", "PERT.lnk"

End
End Sub

' no click
Private Sub Command2_Click()
End
End Sub

---------------------------------------------------------


Create a new module and paste the following

---------------------------------------------------------

Option Explicit

Public Sub CreateMyShortcut(strTarget As String, strShortCutName As String, Optional strStartIn As String = "", Optional strArguments As String = "")
Dim wsh As Object
Dim sf As Object
Dim Shortcut As Object

Set wsh = CreateObject("wscript.shell")
Set sf = wsh.SpecialFolders

' Creates shortcut on desktop
Set Shortcut = wsh.CreateShortcut(sf("AllUsersDesktop") & "\" & strShortCutName)
Shortcut.TargetPath = Chr(34) & "C:\Program Files\Common Files\Microsoft Shared\Access Runtime\Office10\MSACCESS.EXE" & Chr(34)
Shortcut.IconLocation = "C:\Program Files\PERT\PERT.ico"
Shortcut.WorkingDirectory = "C:\Program Files\PERT"
Shortcut.Description = "DEVELOPED BY iASSIST SOFTWARE DEVELOPERS"
Shortcut.Arguments = "/Runtime " & Chr(34) & "C:\Program Files\PERT\PERT.mdb" & Chr(34)
Shortcut.Save

If MsgBox("Do you want PERT to startup automatically when you start your computer", vbYesNo, "Postie Shortcut") = vbYes Then
' Creates shortcut in statrup
Set Shortcut = wsh.CreateShortcut(sf("AllUsersStartup") & "\" & strShortCutName)
Shortcut.TargetPath = Chr(34) & "C:\Program Files\Common Files\Microsoft Shared\Access Runtime\Office10\MSACCESS.EXE" & Chr(34)
Shortcut.IconLocation = "C:\Program Files\PERT\PERT.ico"
Shortcut.WorkingDirectory = "C:\Program Files\PERT"
Shortcut.Description = "DEVELOPED BY iASSIST SOFTWARE DEVELOPERS"
Shortcut.Arguments = "/Runtime " & Chr(34) & "C:\Program Files\PERT\PERT.mdb" & Chr(34)
Shortcut.Save
Else

End If

End Sub


This runs an access database as a runtime application

Note we have distributed our database as a runtime application. the purpose of creating a shortcut with a runtime targetpath is to maintain the runtime version even if they have Access. Not perfect but efficent
 
THANK YOU FOR INCLUDING THE CODE!

Creating a Shortcut on the Desktop was just what I was looking for in the forumn.

Thanks,

Jennifer
 
kaiana

A Star-worthy effort that looks like a candidate for an FAQ. I suggest you look at presenting it as one.
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
kaiana,

Thank you, Thank you , Thank you!!!!!!!

I couldn't even find anything on MSDN (Until I found this and knew more specific properties to search for.)

Janel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top