@echo off
:: Define variables set "destinationPath=%USERPROFILE%\SCVersion10"
del "%userprofile%\scversion10\*.laccdb" > NUL del "%userprofile%\scversion10\*.accde" > NUL del "%userprofile%\scversion10\*.rar" > NUL
:: Delete existing registry keys (if they exist) reg delete "HKCU\Software\Microsoft\Office\16.0\Access\Security\Trusted Locations\Location2" /f >nul 2>&1 reg delete "HKCU\Software\Microsoft\Office\16.0\Access\Security\Trusted Locations\Location3" /f >nul 2>&1 reg delete "HKCU\Software\Microsoft\Office\16.0\Access\Security\Trusted Locations\Location4" /f >nul 2>&1
:: Create the registry keys with new values reg add "HKCU\Software\Microsoft\Office\16.0\Access\Security\Trusted Locations\Location2" /v "Path" /t REG_SZ /d "C:\Program Files\Microsoft Office\root\Office16\ACCWIZ\" /f >nul 2>&1 reg add "HKCU\Software\Microsoft\Office\16.0\Access\Security\Trusted Locations\Location2" /v "Description" /t REG_SZ /d "Access default location: Wizard Databases" /f >nul 2>&1 reg add "HKCU\Software\Microsoft\Office\16.0\Access\Security\Trusted Locations\Location3" /v "AllowSubfolders" /t REG_DWORD /d 0x00000001 /f >nul 2>&1 reg add "HKCU\Software\Microsoft\Office\16.0\Access\Security\Trusted Locations\Location3" /v "Path" /t REG_SZ /d "%sourceUNC%" /f >nul 2>&1 reg add "HKCU\Software\Microsoft\Office\16.0\Access\Security\Trusted Locations\Location4" /v "AllowSubfolders" /t REG_DWORD /d 0x00000001 /f >nul 2>&1 reg add "HKCU\Software\Microsoft\Office\16.0\Access\Security\Trusted Locations\Location4" /v "Path" /t REG_SZ /d "%destinationPath%" /f >nul 2>&1
:: Create destination directory if it doesn't exist (suppressing prompts) mkdir "%destinationPath%" >nul 2>&1
:: Copy EngageBMS.accde from network drive to local destination xcopy "C:\Users\Public\SCVersion10\EngageBMS.accde" "%destinationPath%\" /Y >nul 2>&1
:: Start Access for EngageBMS.accde start "" "C:\Program Files\Microsoft Office\root\Office16\Msaccess.exe" /nostartup "%destinationPath%\EngageBMS.accde" >nul 2>&1
@echo off TIMEOUT /T 5 /NOBREAK
@echo off start Outlook.exe /recycle |