I had a request from my wife (who also works in IT) to work on a script to check to see if I can find a way to see if OneDrive for Business is installed on a users profile. So this batch script was born.
This script works when the user clicks on the batch script. The script will search for if the executable is on a users local AppData folder and if it is not there, it will install it from the Program Files directory so the executable gets stored in the AppData folder. It’s a fairly simple script and has been tested in Windows 7, Windows 8.1 and I’m sure it should work under Windows 10 as well. Please feel free to use the script if you want!
Here is the code as shown below:
REM -------------------------------------- REM OneDriveChecker.bat REM Version 1.2 REM REM Created by: Infinite Technica REM www.infinitetechnica.com REM REM Licensed under Creative Commons Zero REM https://creativecommons.org/publicdomain/zero/1.0/ REM -------------------------------------- echo off cls REM Program Variables SET uPROF="%userprofile%\AppData\Local\Microsoft\OneDrive\OneDrive.exe" SET cARCH="" :CheckOS REM Checks which architecture is installed IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64bit) ELSE (GOTO 32bit) :64bit REM 64bit architecture is installed SET cARCH="%PROGRAMFILES(X86)%\Microsoft OneDrive\OneDriveSetup.exe" GOTO CheckOneDrive :32bit REM 32bit architecture is installed SET cARCH="%PROGRAMFILES%\Microsoft OneDrive\OneDriveSetup.exe" GOTO CheckOneDrive :CheckOneDrive REM Checks if the AppData Executable is installed IF EXIST %uPROF% (GOTO RUNEXEC) ELSE (GOTO RUNINSTALL) :RUNEXEC REM Runs the OneDrive Executable from users AppData folder start "" %uPROF% exit :RUNINSTALL REM Installs OneDrive and runs the OneDrive Executable from users AppData folder REM If the installer does not exist, a message will be displayed and user will need to press Enter to exit out of program. IF EXIST %cARCH% ( %cARCH% start "" %uPROF% ) ELSE ( cls echo:"OneDrive Setup executable is not installed. Please Contact your IT Administrator." pause ) exit
With my code, I try to license it as Creative Commons Zero because code can be written several different ways. Feel free to modify it however you want!