Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 794
  • Last Modified:

Hide Shortcut Target

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
eklin
Asked:
eklin
  • 8
  • 5
  • 2
  • +1
1 Solution
 
COACHMAN99Commented:
do you want to hide the 'Target' in properties, or just whats displayed on the desktop?
0
 
eklinAuthor Commented:
Thanks!  I would like to hide the following when user right clicks shortcut and select property: "Target" and "Start In"
0
 
COACHMAN99Commented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
eklinAuthor Commented:
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
 
SheilsCommented:
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
 
eklinAuthor Commented:
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
 
PatHartmanCommented:
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
 
SheilsCommented:
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
 
eklinAuthor Commented:
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
 
eklinAuthor Commented:
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
 
SheilsCommented:
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
 
eklinAuthor Commented:
it didn't work. still same error but I get the idea if I just can make it work
0
 
SheilsCommented:
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
 
eklinAuthor Commented:
thanks! i'll try tomorrow when i'm back at work
0
 
eklinAuthor Commented:
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
 
SheilsCommented:
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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 8
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now