This Windows batch script helps system administrators automatically and safely update application files on user workstations by copying them from a network location using RoboCopy. It's designed for situations where:
- You manage multiple workstations that need regular application updates
- Another team builds and deploys updated application files to a network folder
- You don't know exactly when those files are updated
- You need to safely copy those updates to user workstations using RoboCopy
- You want to avoid copying the same files repeatedly
Initial Use - Manual Execution: The script is initially designed to be run manually by system administrators. You can double-click the batch file or run it from a command prompt to check for and apply updates as needed.
Ultimate Goal - Automatic Login Execution: The long-term purpose is to have this script run automatically whenever a user logs into their Windows workstation. This means:
- The script gets deployed to user workstations
- It's configured to execute during the login process
- Users automatically receive application updates without manual intervention
- The workstation application stays current with the latest deployed version
The Scenario: You're responsible for keeping application files up-to-date on user workstations. Another development team periodically updates the application and places the new files in a shared network folder. Your job is to copy these updated files to user workstations.
The Challenge:
- You don't know when the network folder gets updated
- You don't want to copy files that haven't changed
- You need to track what was copied and when
- Manual checking is time-consuming and error-prone
The Solution: This Windows batch script automatically uses RoboCopy to check if files have been updated and only copies what's new or changed, keeping a record of what it did.
- Checks the Network Folder - Uses RoboCopy to examine the source UNC path for application files
- Compares with Last Run - RoboCopy intelligently identifies what has changed since the last run
- Identifies Changes - Finds files that are new, modified, or updated using RoboCopy's built-in comparison
- Performs Safe Copy - Uses RoboCopy's robust copying features to transfer only changed files
- Updates Records - RoboCopy maintains detailed logs of what was copied and when
- Logs Everything - Creates comprehensive log files for your review and troubleshooting
The script is designed to be completely user-friendly for non-technical end users:
- Clean, professional messages - No technical jargon or scary batch file terms
- Branded application name - All messages reference the specific application being updated
- Clear progress updates - Simple messages like "Checking for updates..." and "Success! Application updated"
- Friendly completion messages - "Great news! Your application is already up to date"
- RoboCopy commands or technical parameters
- File paths or UNC network locations
- Batch file references or exit codes
- Complex error messages (redirected to "contact your administrator")
This folder contains:
- UpdateApp.bat - The main batch script that performs the updates
- README.md - This documentation file
- logs/ - Directory created automatically to store update logs
The batch file is named UpdateApp.bat as a generic starting point, but you should rename it to match your specific application:
- For Accounting Software:
UpdateAccounting.bat - For Payroll System:
UpdatePayroll.bat - For Customer Database:
UpdateCustomerDB.bat - For Point of Sale:
UpdatePOS.bat
You can use this script for multiple different applications by:
- Making copies of the batch file for each application
- Renaming each copy to match the specific application
- Configuring each copy with different paths and APP_NAME settings
- Deploying each script to the appropriate users/systems
- Clear identification - Users know exactly what's being updated
- Professional appearance - Matches your organization's naming conventions
- Easy management - Administrators can quickly identify which script does what
- Reduced confusion - No generic "UpdateApp" running on user systems
Before using this script, you'll need to know:
- Application Name - A friendly name for the application (for user messages)
- Source UNC Path - The fully qualified UNC path to the network folder containing the deployed application
- Destination Local Path - The fully qualified local Windows path on the workstation where the application should be copied
- RoboCopy Path - The fully qualified path to the RoboCopy executable
- Permissions - Access rights to both source and destination folders
The script uses four clearly defined variables at the top of the batch file that you can easily modify:
- APP_NAME - The friendly name for the application (e.g.,
Accounting Software) - NETWORK_SOURCE_PATH - The fully qualified UNC path (e.g.,
\\server\share\application) - LOCAL_DEST_PATH - The fully qualified local path (e.g.,
C:\Applications\MyApp) - ROBOCOPY_EXE - The fully qualified path to RoboCopy (e.g.,
C:\Windows\System32\robocopy.exe)
- Simple to customize - Just update the four variables at the top of the batch file
- User-friendly branding - The APP_NAME appears in all user messages
- Environment-specific - Each workstation can have its own copy with different paths
- No script editing required - All customization happens in the variable definitions
- Make sure you have access to both source and destination folders
- Test that you can manually copy files between these locations
- Identify the exact paths you'll be using
- Rename the batch file to match your application (e.g.,
UpdatePayroll.bat) - Open the renamed file in a text editor (like Notepad)
- Find the four variables at the top of the file and configure them:
- Set
APP_NAMEto a friendly name for your application (e.g., "Payroll System") - Set
NETWORK_SOURCE_PATHto your UNC path (where files come from) - Set
LOCAL_DEST_PATHto your local path (where files go to) - Set
ROBOCOPY_EXEto your RoboCopy executable path
- Set
- Save the batch file
- Double-click your renamed batch file to run it manually
- Review the console output to see what it plans to do
- Check the log files in the
logs/directory for detailed results
Once you've tested the script and confirmed it works correctly:
For Manual Use:
- Keep running the script manually as needed
- Double-click the batch file or run from command prompt
For Automatic Login Execution:
- Test thoroughly first - Ensure the script works perfectly in manual mode
- Choose deployment method:
- Add to Windows Startup folder for current user
- Use Group Policy to run at login (for domain environments)
- Add to Windows Registry Run keys
- Use Task Scheduler with "At logon" trigger
- Deploy to user workstations - Copy the configured script to target machines
- Monitor initial deployments - Check log files after users log in
- Verify automatic updates - Confirm the application stays current
RoboCopy and the script maintain several types of information:
- File Comparison - RoboCopy compares file sizes, dates, and attributes to detect changes
- Last Run Time - When the script last checked for updates
- Copy History - Detailed RoboCopy logs showing what files were copied and when
- Error Log - Any problems encountered during the RoboCopy operation
- RoboCopy Reliability - Uses Windows' most robust file copying utility
- Dry Run Mode - RoboCopy can show what would happen without actually copying (
/Lflag) - Verification - RoboCopy has built-in verification to confirm files copied correctly
- Detailed Logging - Comprehensive logs help track all changes and troubleshoot issues
- Restart Capability - RoboCopy can resume interrupted transfers
The script creates comprehensive logging in the logs/ directory:
- Timestamped Logs - Detailed log for each run (e.g.,
UpdateApp_2024-01-15_14-30-25.log) - Summary Log - Quick reference of all runs (
UpdateApp_Summary.log)
- Configuration settings and paths used
- Pre-update verification results
- Complete RoboCopy output with file-by-file details
- Exit codes and their interpretations
- Error messages and troubleshooting information
- Start and end times for each operation
- Troubleshooting - Detailed technical information for administrators
- Audit Trail - Complete history of all update operations
- Verification - Confirm what files were actually copied
- Performance Tracking - Monitor how long updates take
- Test First - Always run with RoboCopy's
/Lflag (list only) before doing actual copies - Check Permissions - Ensure you have proper access to both UNC source and local destination
- Monitor Logs - Review RoboCopy log files regularly for any issues
- RoboCopy Path - Verify the RoboCopy executable path is correct for your Windows version
- Network Connectivity - Script requires reliable access to the UNC network source
- Windows Compatibility - This is a Windows batch file designed for Windows systems only
- Login Script Considerations - When running at login, ensure network connectivity is established before the script executes
- User Context - The script will run with the permissions of the logged-in user, so ensure they have appropriate access rights
- Workstation Deployment - This script is designed for deployment to individual user workstations, not servers
"Access Denied" Errors
- Check that you have read access to source folder
- Verify you have write access to destination folder
- Ensure network path is accessible
"No Files Found" Messages
- Verify the source path is correct
- Check that files exist in the source location
- Confirm network connectivity
"Files Not Copying" Problems
- Check available disk space on destination
- Verify file permissions
- Review error logs for specific issues
If you run into problems or have questions about this script:
Fred Lackey
📧 Email: Fred.Lackey@gmail.com
🌐 Website: @FredLackey.com
Please include:
- What you were trying to do - Your goal with the script
- What happened - The actual result or error message
- Your environment - Windows version, network setup details
- Configuration - Your source and destination paths (remove sensitive info)
- Log files - Any error messages from the script logs
- Check the troubleshooting section above
- Review the log files for error messages
- Try running in test mode to see what the script plans to do
- Verify your network connectivity and permissions
Remember: This script is designed to help make your job easier. Don't hesitate to reach out if you need help getting it set up or working properly!