Results 1 to 5 of 5

Thread: Batch Script for New Versions and Shortcuts

  1. #1
    Board Regular
    Join Date
    Oct 2008
    Location
    New York, NY
    Posts
    104
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Batch Script for New Versions and Shortcuts

    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

  2. #2
    Board Regular
    Join Date
    May 2013
    Posts
    644
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Batch Script for New Versions and Shortcuts

    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 by welshgasman; Sep 15th, 2019 at 04:20 PM.
    Office 2007
    Access novice. Sometimes trying to give something back

  3. #3
    Board Regular Jaafar Tribak's Avatar
    Join Date
    Dec 2002
    Location
    Larache--Morocco
    Posts
    7,346
    Post Thanks / Like
    Mentioned
    39 Post(s)
    Tagged
    3 Thread(s)

    Default Re: Batch Script for New Versions and Shortcuts

    See if you can adapt this to you specific requirements
    Office/Excel 2010 64Bits -- Win10 64Bits

    Common sense is not so common.


    http://photo-larache.blogspot.com/

  4. #4
    Board Regular
    Join Date
    Oct 2008
    Location
    New York, NY
    Posts
    104
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Batch Script for New Versions and Shortcuts

    Thanks for the tips guys -- when I have a version working, I'll post it on here for future reference.

  5. #5
    Board Regular
    Join Date
    Oct 2008
    Location
    New York, NY
    Posts
    104
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Batch Script for New Versions and Shortcuts

    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 by CPGDeveloper; Oct 7th, 2019 at 10:12 AM.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •