Batch Script for New Versions and Shortcuts

CPGDeveloper

Board Regular
Joined
Oct 8, 2008
Messages
190
I administer an MS Access DB with approximately 20 end users. Each user has a copy of the FE on their desktop. When I need to make changes, the Form_Load Event of the initial form identifies that a new version is available and runs a batch script to copy down the new version of the front end to the users' desktop (I found this batch script on this forum I believe). It works great.

I have a request to change the generic MS Access Logo of the Application that sits on the users' desktop. The only way I believe to do this (without altering the registry) is to simply have a shortcut on the users' desktop that points to their copy of the FE. I'm able to alter the batch script to put the application in a different folder, but am having issues creating the shortcut and using the specific image that I want. Any ideas of how I would go about doing that? Can I add to this current batch script -- or perhaps I need to create a separate one? Thanks in advance!

' sets the file name of the batch file to create
TestFile = CurrentProject.Path & "\UpdateDbFE.cmd"
' sets the restart file name
strRestart = """" & strKillFile & """"
' creates the batch file -- The 10 after the ping -n is the delay for it to copy needs to be this for large front ends
Open TestFile For Output As #1
Print #1 , "Echo Off"
Print #1 , "ECHO Deleting old file"
Print #1 , ""
Print #1 , "if exist """ & strBackUp & """ del """ & strBackUp & """"
Print #1 , ""
Print #1 , "ECHO Copying backup file"
Print #1 , "Echo Off"
Print #1 , "ping -n 14 127.0.0.1 > nul"
Print #1 , ""
Print #1 , ":Fileready1"
Print #1 , "Ren """ & strKillFile & """ """ & strTarget & """"
Print #1 , "ECHO Copying New file"
Print #1 , "Echo Off"
Print #1 , "Copy /Y """ & strReplFile & """ """ & strKillFile & """"
Print #1 , ""
Print #1 , ":checkfilecreation"
Print #1 , "REM Now that a .mov file has been added to the folder check to see if the file has "
Print #1 , "REM completed the conversion or copying to the folder before starting "
Print #1 , ""
Print #1 , "CLS"
Print #1 , ""
Print #1 , "for %%I in (""" & strKillFile & """) do ( (call ) >>%%I ) 2>nul && (cls && set b=%%I && @Echo !b! is completed and transfer is ready && GOTO :fileready"
Print #1 , ") || (cls && echo %%I is still being created"
Print #1 , ")"
Print #1 , ""
Print #1 , ":ContinueCheck"
Print #1 , "REM Go back to checkfilecreation module"
Print #1 , "GOTO :checkfilecreation"
Print #1 , ""
Print #1 , ""
Print #1 , "if exist """ & strBackUp & """ del """ & strBackUp & """"
Print #1 , ""
Print #1 , ":Fileready"
Print #1 , "Echo CLICK ANY KEY TO RESTART THE ACCESS PROGRAM"
Print #1 , "START /I " & """MSAccess.exe"" " & strRestart
Close #1
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
The way I did it, was the create the shortcut with the correct info in it, and place it with the master DB copy.
Then copy that to the user's desktop.

I do not have access to the computer that did that at the moment, but if you google 'copy shortcut' that should get you started.?
I always placed the FE DBs into a commonly named folder on each user PC. The batch file also created the folder if the first time used.

I would probably do it in the same file. Increase the version of the FE, and then they will get the updated shortcut with the fancy icon. :)

HTH
 
Last edited:
Upvote 0
Thanks for the advice guys -- I ended up using that template and created a batch script that puts the application in a separate folder on their c drive and puts a shortcut on their desktop. I'm posting it here if it's useful to anyone:

Public Sub ShortCut()

Dim objWshShell As Object
Dim objWshShortcut As Object
Dim strProgLocn As String
Dim strDBLocn As String
Dim strDBPath As String
Dim strDesktop As String
Dim strIconLoc As String
Dim strIconLocSo As String
Dim g_strFilePath As String
Dim p_strFilePath As String

strIconLocSo = " " 'This would be where the location of your shortcut image would be
strIconLoc = " " 'This would be the folder on the end user's c drive where you want the image to live
g_strFilePath = CurrentProject.Path

If Right(g_strFilePath, 7) = "Desktop" Then 'If their current version is on the desktop, define new location of where application should live
p_strFilePath = " " 'Location where you want the end users application to live
If FolderExists(p_strFilePath) = False Then
MkDir p_strFilePath
End If
Else
p_strFilePath = g_strFilePath
End If

If FileExists(strIconLoc) = False Then
Dim fso As Object
Set fso = VBA.CreateObject("Scripting.FileSystemObject")
Call fso.CopyFile(strIconLocSo, strIconLoc)
Set fso = Nothing
End If

Set objWshShell = CreateObject("WScript.Shell")

strDesktop = objWshShell.SpecialFolders("Desktop")
strProgLocn = SysCmd(acSysCmdAccessDir) & "msaccess.exe"
If Right(g_strFilePath, 7) = "Desktop" Then
strDBLocn = " " 'Full Path & Name of Where You want application to live on users c drive
Else
strDBLocn = CurrentDb.Name
End If
strDBPath = Left$(strDBLocn, Len(strDBLocn) - Len(Dir$(strDBLocn)))

If FileExists(strDesktop & "\my app.lnk") Then 'my app.lnk is name of short cut -- of course call it whatever you want
GoTo EndThis
End If

Set objWshShortcut = objWshShell.CreateShortcut(strDesktop & "\my app.lnk")

With objWshShortcut
.TargetPath = strProgLocn
.Arguments = Chr$(34) & strDBLocn & Chr$(34)
.WorkingDirectory = strDBPath
.WindowStyle = 4
.IconLocation = strIconLoc
.Save
End With

EndThis:
Set objWshShortcut = Nothing
Set objWshShell = Nothing

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top