Solved

Hide Shortcut Target

Posted on 2014-04-08
16
660 Views
Last Modified: 2014-04-10
Is it possible to hide the text string in the MS Access database shortcut from users viewing it?  I would like to prevent savvy users from going to the folder directly to access the database, since I store the backend data file in the same folder and that file is not password protected.  Thanks
0
Comment
Question by:eklin
  • 8
  • 5
  • 2
  • +1
16 Comments
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 39986713
do you want to hide the 'Target' in properties, or just whats displayed on the desktop?
0
 

Author Comment

by:eklin
ID: 39986742
Thanks!  I would like to hide the following when user right clicks shortcut and select property: "Target" and "Start In"
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 39986758
I do not know if this is possible. the target is the parameter used to open the file.
An alternative is to relocate the BE to somewhere else, and relink the FE to the new location.
0
 

Author Comment

by:eklin
ID: 39986801
I was hoping I could create a shortcut that is "executable" only, where users can't tamper with it?  We have had some strange issues in UAT with both files being located in different directories as we are using a network shared drive.
0
 
LVL 16

Expert Comment

by:Sheils
ID: 39986841
You can use a batch file to open the FE. To do that create a text file in notepad and save it with the extension .bat eg starter.bat

In the file write the following:

start "" "your file path"

Once done you may want to change the icon of the batch file so that it looks friendly.
0
 

Author Comment

by:eklin
ID: 39986936
i like this last idea best so far but it would still not prevent someone savvy from finding out the true path by right clicking and editing the batch file
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 39987043
We have had some strange issues in UAT with both files being located in different directories as we are using a network shared drive.

In a properly set up multi-user environment, the FE and BE are ALWAYS in separate directories.  Each user has his OWN copy of the FE located on his local drive.  All the separate FE's are connected to the same BE on a server.

A very simple way to distribute the FE's is by using a batch file.  There are several more sophisticated methods that do other things such as updating the registry to define trusted folders and making sure the correct version of Access is opening the app.

md c:\ClientMgt
del c:\ClientMgt\AOAClientManagement.accdr
copy \\newfiscal\Afox\AFox\AccessApplications\ClientMgt\AOAClientManagement.accdr c:\ClientMgt
c:\ClientMgt\AOAClientManagement.accdr

The first line of the batch file creates a local directory.  If the directory already exists, no error is raised.
The second line deletes the existing copy of the FE.  Again, if the file isn't there, no error is raised.
The third line copies the FE from a common folder on the server.
The fourth changes the current directory to the local folder
The fifth line starts the Access database.

The batch file and the FE live on a server in a different directory from the BE.  I create a shortcut to run the batch file and that is what I send to the users so essentially, they do their own install.  The first time they run the app, they will get security warnings and they need to trust the database.  Access then adds a trusted folder to the registry so they won't be bothered again.

When you link the FE to the BE, you need to use UNC naming conventions to avoid issues of drives being mapped differently.  So rather than searching for a path and file, just paste in the link.

\\servername\folder1\folder2\yourdatabase.accdb

Using this technique, you don't even need to map a drive to the BE location and that makes it one step harder for the "technical enough to cause damage" crowd.
0
 
LVL 16

Expert Comment

by:Sheils
ID: 39987059
The alternative is to create a second db which opens the target db.

Create a form (form1) in the second db and add the following code in the on open even to open the target db.

Option Compare Database

Option Explicit

Public Declare Function ShellExecuteA Lib "shell32.dll" _
(ByVal hWnd As Long, ByVal strOperation As String, _
ByVal strFile As String, ByVal strParameters As String, _
ByVal strDirectory As String, ByVal nShowCmd As Long) As Long
 
Private Declare Function GetDesktopWindow Lib "user32" () As Long


 
Public Function OpenFile()
 
    Dim lngreturn As Long
    lngreturn = ShellExecuteA(GetDesktopWindow(), "OPEN", "your file path", "", "", vbNormalFocus)
 
    If Not ((lngreturn < 0) Or (lngreturn > 32)) Then
      
        MsgBox "Sorry, There was a problem opening the selected file", vbExclamation
 
    End If
    
    DoCmd.Quit
 
End Function

Open in new window


save the second db as executable (mde or .accde) so that noone including you will be able to open its vba window.

Only show the shortcut to the second db which will in turn open your target db.
0
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!

 

Author Comment

by:eklin
ID: 39987077
Pat,

I agree with you 100% but it's one of those exception cases.  Originally we were shooting to have them in separate folders, even drives.  However, we got some issues during UAT which didn't happen if they were in the same folder.  Our developer pointed to IT/Infrastructure as the cause.  Since we were under budget and focusing on the functionality, we decided to place them in the same folder as a "workaround".
0
 

Author Comment

by:eklin
ID: 39987114
sb9,

I opened the "on load" event to copy paste the code and try to paste between these lines:

Private Sub Form_Load()

End Sub

It didn't work and I got an error:

"The expression On Load you entered as the event property setting produced the following errror: only comments may appear after End Sub, End Function, End Property.
0
 
LVL 16

Expert Comment

by:Sheils
ID: 39987130
Change to this

Option Compare Database

Option Explicit

Public Declare Function ShellExecuteA Lib "shell32.dll" _
(ByVal hWnd As Long, ByVal strOperation As String, _
ByVal strFile As String, ByVal strParameters As String, _
ByVal strDirectory As String, ByVal nShowCmd As Long) As Long
 
Private Declare Function GetDesktopWindow Lib "user32" () As Long


Private Sub Form_Load()
 
    Dim lngreturn As Long
    lngreturn = ShellExecuteA(GetDesktopWindow(), "OPEN", "your file path", "", "", vbNormalFocus)
 
    If Not ((lngreturn < 0) Or (lngreturn > 32)) Then
      
        MsgBox "Sorry, There was a problem opening the selected file", vbExclamation
 
    End If
    
    DoCmd.Quit
 
End Sub

Open in new window

0
 

Author Comment

by:eklin
ID: 39987154
it didn't work. still same error but I get the idea if I just can make it work
0
 
LVL 16

Expert Comment

by:Sheils
ID: 39987184
Try creating a module and adding the following code

Option Compare Database

Option Explicit

Public Declare Function ShellExecuteA Lib "shell32.dll" _
(ByVal hWnd As Long, ByVal strOperation As String, _
ByVal strFile As String, ByVal strParameters As String, _
ByVal strDirectory As String, ByVal nShowCmd As Long) As Long
 
Private Declare Function GetDesktopWindow Lib "user32" () As Long


 
Public Function OpenFile(strFilePath as string)
 
    Dim lngreturn As Long
    lngreturn = ShellExecuteA(GetDesktopWindow(), "OPEN",strFilePath , "", "", vbNormalFocus)
 
    If Not ((lngreturn < 0) Or (lngreturn > 32)) Then
      
        MsgBox "Sorry, There was a problem opening the selected file", vbExclamation
 
    End If
 
End Function

Open in new window


then in the form on open event add the following code
OpenFile("Your File Path")
docmd.Quit
0
 

Author Comment

by:eklin
ID: 39987493
thanks! i'll try tomorrow when i'm back at work
0
 

Author Comment

by:eklin
ID: 39990081
sb9 - it works if I open the database and double click on the form.  If I set the form to open automatically when the database opens, the database hangs there and exists with error without opening the second database.  I'm trying to make it work.
0
 
LVL 16

Accepted Solution

by:
Sheils earned 300 total points
ID: 39990218
Looks like running the quit command straight away is causing the problem. In the attached I have set the form's time interval to 3 seconds and then run the code on timer. It works fine.

Press the shift key as you open the db and then change the file path to your target file  in the OnTimer event.

You can reduce the time interval a bit to find at what point you start getting error. You may also change the properties of the db so that it only shows the form
Database2.accdb
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

757 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

17 Experts available now in Live!

Get 1:1 Help Now