eklin
asked on
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
do you want to hide the 'Target' in properties, or just whats displayed on the desktop?
ASKER
Thanks! I would like to hide the following when user right clicks shortcut and select property: "Target" and "Start In"
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.
An alternative is to relocate the BE to somewhere else, and relink the FE to the new location.
ASKER
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.
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.
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.
ASKER
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
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\AOAClientMana
copy \\newfiscal\Afox\AFox\Acce
c:\ClientMgt\AOAClientMana
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\folde
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.
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.
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.
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
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.
ASKER
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".
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".
ASKER
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.
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.
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
ASKER
it didn't work. still same error but I get the idea if I just can make it work
Try creating a module and adding the following code
then in the form on open event add the following code
OpenFile("Your File Path")
docmd.Quit
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
then in the form on open event add the following code
OpenFile("Your File Path")
docmd.Quit
ASKER
thanks! i'll try tomorrow when i'm back at work
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.