Introduction: Start

Picture of Start

I built a batch script that would allow you to have user accounts, and do quite a few different things. I am not really sure how to do a tutorial on it, but here is the script. Careful... there is a cleanup that will wipe quite a bit of data from the main users folders. Just grab the code, and save it as Start.bat then double click. Give me tips, or tricks if you have any suggestions for the code.

Step 1: The Code!

:: =================================================================

:: 2016 Jonathan Hackett :: Version 1.10 :: Start File - This start file will do everything.... :: =================================================================

:: Opening File Sequence. This can be changed after Login. @echo off title Start File REM call :killExplorer :: Initiation of Vocals and Introduction REM set text=Welcome to Jonathan's Start File. Feel free to look around. REM call :Speech

:: Check to see if 64, or 32 bit OS. if exist "C:\Program Files (x86)" set os=64 if not exist "C:\Program Files (x86)" set os=32 msg * "You are using a " %os% " bit os."

:: Creates Main File Location set location=%temp%\StartFile if not exist %location% mkdir %location% && call :CreateAdmin

:: Creates Logs Location if not exist %location%\logs mkdir %location%\logs

REM This color is an Aqua with White text, again this can be changed. msg * "You are required to login!" :loginstart title Login Please cls color 37

REM This is the main login view. If the username/password combo is wrong it shows this echo. echo ================================================================= echo - echo - Please Login echo - echo ================================================================= echo.

REM Requests Username, and checks if it exists. If it does not then it Goes back to login. set /p Uname=Username: if %Uname%==bangarang! start %temp%\StartFile\users if exist %location%\users\%Uname%.bat goto loginPass if %Uname%==exit goto EOF goto loginstart

:loginPass title User Exists Enter Password call %location%\users\%Uname%.bat cls echo. echo ================================================================= echo - echo - User:%Uname% echo - Enter Password echo - echo ================================================================= set /p Pname=: if %Pname%==%pswd% goto loginCleared goto loginstart

:loginCleared title %Uname% Logged In REM All commands return to this location currently. cls echo. echo ================================================================= echo Current Time: %time% echo - echo - User:%Uname% echo - Logged In echo - echo - -type help for more info echo ================================================================= echo. REM This is important. This is just a command. You can type any shell command here. set /p command=Please Enter a Command:

REM Then once it is put in, it will do whatever you asked it to do here. REM Currently it will pause after the command then take you back to the Logged in screen. %command% if %command%==users call :users if %command%==logout call :logout if %command%==fix call :fix if %command%==help call :help if %command%==logs cls && echo. && type %location%\logs\%Uname%.log && echo. if %command%==browsers call :browsers if %command%==drive start %~dp0 && cls if %command%==onlineMusic start https://play.google.com/music/listen?u=0#/now && cls if %command%==backup call :backup if %command%==cleanup call :cleanup if %command%==restore call :restore if %command%==stopbrowsers call :killBrowsers if %command%==lock call :lock if %command%==resetpassword cls && echo You must have elevated privliges && net user %username% * if %command%==colors call :colors if %command%==message call :message if %command%==reader call :reader if %command%==stopexplorer call :killExplorer if %command%==video call :video if %command%==lock call :lock pause echo %command% at %time%, %date%>>%location%\logs\%Uname%.log && cls goto loginCleared

:: This stops explorer. This also runs at the beginning. :killExplorer cls taskkill /f /im explorer.exe goto EOF

:lock set Uname= && set Pname= goto loginstart

:logout taskkill /f /im chrome.exe taskkill /f /im stickies.exe taskkill /f /im keepass.exe taskkill /f /im virtuawin.exe taskkill /f /im winlist.exe taskkill /f /im synkron.exe taskkill /f /im notepad* taskkill /f /im cubicex* taskkill /f /im portableapps* goto lock

:video if not %al%==Admin cls && echo You must be an admin to access this file. && goto EOF cls color 0a echo Access to Drive Vids if exist %~dp0Documents\Videos start %~dp0Documents\Videos timeout 02>nul cls goto EOF

:: Messenger

:message cls set msg=%location%\msgs\ if not exist %msg% mkdir %msg% set t=%location%\users echo. echo --------------------- echo. echo Who would you like to chat? echo. echo --------------------- for /R %t% %%f in (*.bat) do ( echo %%~nf ) set /p messengerName=: set /p messengerText=Say to %messengerName%: echo %Uname% says %input1% to %messengerName% at %time%: %messengerText%>>%msg%MessageLog.dat goto EOF

:reader set msg=%location%\msgs\ cls type %msg%MessageLog.dat goto EOF

:: Sets the colors for your profile. :colors cls echo default echo blue echo red echo matrix set /p command=: cls if %command%==default echo color 37>>%location%\users\%Uname%.bat && color 37 if %command%==blue echo color 09>>%location%\users\%Uname%.bat && color 09 if %command%==red echo color 84>>%location%\users\%Uname%.bat && color 84 if %command%==matrix echo color 0a>>%location%\users\%Uname%.bat && color 0a

goto EOF

:: This section stops all major browsers :killBrowsers :: Must be an administrator to continue if not %al%==Admin cls && echo You must be an admin to access this file. && goto EOF taskkill /f /im microsoftedge.exe taskkill /f /im chrome.exe taskkill /f /im iexplore.exe taskkill /f /im firefox.exe taskkill /f /im opera.exe taskkill /f /im safari.exe taskkill /f /im chrome.exe goto EOF

:: This section will stop all major browsers, will backup all your files, and then remove them all. :cleanup if not %al%==Admin cls && echo You must be an admin to access this file. && goto EOF call :killBrowsers cls echo. echo --------------- echo. echo Cleaning up your system. echo. call :backup echo. echo --------------- cls echo. echo ---------------- echo. echo Cleaning Folders echo. echo ---------------- timeout 02>nul cls echo. echo ---------------- echo. echo Cleaning Desktop echo. echo ---------------- del /s /q %userprofile%\desktop\* cls echo. echo ---------------- echo. echo Cleaning Pictures echo. echo ---------------- del /s /q %userprofile%\pictures\* cls echo. echo ---------------- echo. echo Cleaning Videos echo. echo ---------------- del /s /q %userprofile%\videos\* cls echo. echo ---------------- echo. echo Cleaning Music echo. echo ---------------- del /s /q %userprofile%\music\* cls echo. echo ---------------- echo. echo Cleaning Documents echo. echo ---------------- del /s /q %userprofile%\documents\* cls echo. echo ---------------- echo. echo Cleaning Downloads echo. echo ---------------- del /s /q %userprofile%\downloads\* cls echo. echo ---------------- echo. echo Removing Folders echo. echo ---------------- timeout 02>nul cls echo. echo ---------------- echo. echo Removing Firefox Data echo. echo ---------------- taskkill /f /im firefox.exe rd /s /q %appdata%\Mozilla cls echo. echo ---------------- echo. echo Removing Google Data echo. echo ---------------- taskkill /f /im chrome.exe rd /s /q %localappdata%\Google Del /s /q %localappdata%\Google\* cls echo. echo ---------------- echo. echo Removing Temp Data echo. echo ---------------- rd /s /q %temp% ipconfig /flushdns echo dns flushed ipconfig /release echo ip released ipconfig /renew echo ip renewed cls goto EOF

:: This section will backup any files on your pc under the main folders. :backup REM Do a backup of all files. set location="%~dp0\Backup\%Computername%\%username%" if not exist %location% mkdir %location% xcopy "%userprofile%\desktop\*" "%location%\Desktop\*" xcopy "%userprofile%\documents\*" "%location%\Documents\*" xcopy "%userprofile%\pictures\*" "%location%\Pictures\*" xcopy "%userprofile%\music\*" "%location%\Music\*" xcopy "%userprofile%\Videos\*" "%location%\Videos\*" xcopy "%userprofile%\downloads\*" "%location%\Downloads\*" cls echo - Files Copied. timeout 02>Nul goto EOF

:: This section will backup any files on your pc under the main folders. :restore REM Do a restore of all files from this pc. set location="%~dp0\Backup\%Computername%\%username%" if not exist %location% mkdir %location% xcopy "%location%\Desktop\*" "%userprofile%\desktop\*" xcopy "%location%\Documents\*" "%userprofile%\documents\*" xcopy "%location%\Pictures\*" "%userprofile%\pictures\*" xcopy "%location%\Music\*" "%userprofile%\music\*" xcopy "%location%\Videos\*" "%userprofile%\Videos\*" xcopy "%location%\Downloads\*" "%userprofile%\downloads\*" cls echo - Files Copied. timeout 02>Nul goto EOF

:: This option will allow you to open any of the major browsers. Support even for Windows 10. :browsers if os==32 cls && echo I am sorry this funtion is unavailable on 32 bit os && timeout 05>nul && goto loginCleared set chrome="C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" set firefox="C:\Program Files (x86)\Mozilla Firefox\firefox.exe" set iexplore="C:\Program Files (x86)\Internet Explorer\iexplore.exe" set edge="C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\MicrosoftEdge.exe" set opera="C:\Program Files (x86)\Opera\launcher.exe" cls echo. echo ================================================================= echo - echo - Browsers Listed Here. echo - if exist %chrome% echo -Google Chrome - chrome if exist %firefox% echo -Mozilla Firefox - firefox if exist %iexplore% echo -Internet Explorer - explore if exist %edge% echo -Microsoft Edge x edge (not sure how to open yet) if exist %opera% echo -Opera - opera echo - echo - To return type [R] echo - echo ================================================================= echo. set /p browserChoice=Choose a browser to open: if %browserChoice%==opera %opera% if %browserChoice%==edge %edge% if %browserChoice%==chrome %chrome% if %browserChoice%==firefox %firefox% if %browserChoice%==R goto EOF if %browserChoice%==r goto EOF echo %browserChoice% browser has been chosen. timeout 05>nul goto browsers

:: This is the speech center. It is enabled by default. :speech set num=%random% if exist temp%num%.vbs goto num echo ' > "temp%num%.vbs" echo set speech = Wscript.CreateObject("SAPI.spVoice") >> "temp%num%.vbs" echo speech.speak "%text%" >> "temp%num%.vbs" start temp%num%.vbs timeout 02>nul del temp%num%.vbs goto EOF

:: This is the help list. It describes all of the commands you can use built into the program. :help cls echo. echo ================================================================= echo - echo - Help Information. echo - echo - 1. fix (opens editor) echo - 2. help (opens this window) echo - 3. users (opens user options) echo - 4. logout (logs out current user) echo - 5. logs (shows logs for current user) echo - 6. browsers (shows browser options) echo - 7. drive (opens the drive folder) echo - 8. onlineMusic (opens google music) echo - 9. backup (backs up all files) echo - 10. cleanup (removes all files after backing them up) echo - 11. restore (restores all backed up data) echo - 12. stopbrowsers (kills all browsers) echo - 13. resetpassword(resets actual pc pswd) echo - 14. colors (changes your profile color) echo - 15. exit (closes system at login, or after) echo - 16. message (Creates a message for another user) echo - 17. reader (reads any messages) echo - 18. stopexplorer (Kills all Explorer Windows) echo - 19. video (shows video folder on drive *if it exists*) echo - 20. begin (Will start All portable applications) echo - echo ================================================================= echo. goto EOF

::Fix this program, or edit either or :) :fix if not %al%==Admin cls && echo You must be an admin to access this file. && goto EOF cls if exist %~dp0PortableApps\Notepad++Portable\Notepad++Portable.exe ( start %~dp0PortableApps\Notepad++Portable\Notepad++Portable.exe "Start.bat" ) ELSE ( notepad "Start.bat" cls goto command ) goto EOF

::User Viewing, Deleting, and Creating. :users if not %al%==Admin cls && echo You must be an admin to access this. && goto EOF cls echo. echo ================================================================= echo - echo - User Viewing, Deleting and Creating echo - echo ================================================================= echo. timeout 02>nul set /p command='V'iew, 'C'reate, 'D'elete, 'E'dit, 'R'eturn: if %command%==V goto usersView if %command%==v goto usersView if %command%==e goto usersEdit if %command%==E goto usersEdit if %command%==C goto usersCreate if %command%==c goto usersCreate if %command%==D goto usersDelete if %command%==d goto usersDelete if %command%==r goto loginCleared if %command%==R goto loginCleared goto EOF

:usersView cls echo. echo ================================================================= echo - echo - User Viewing echo - echo ================================================================= echo. timeout 02>nul for /f "delims=" %%f in ('dir /b %location%\users\*.bat') do echo %%~nf pause goto users

:usersEdit cls echo. echo ================================================================= echo - echo - User Editing echo - echo ================================================================= echo. timeout 02>nul for /f "delims=" %%f in ('dir /b %location%\users\*.bat') do echo %%~nf echo. echo Who would you like to edit? set /p username=: set tmpPswd=%pswd% set tmpAL=%al% call %location%\users\%username%.bat echo. echo Current information on user is: echo. echo Username: %username% echo Password: %pswd% echo Access Level: %al% echo. echo What would you like to change? set /p command=[U]sername, [P]assword, [A]ccess Level, a[B]ort: if %command%==u goto usersEditusername if %command%==p goto usersEditpassword if %command%==a goto usersEditaccess if %command%==b set pswd=%tmpPswd% && set al=%tmpAL% && goto EOF if %command%==U goto usersEditusername if %command%==P goto usersEditpassword if %command%==A goto usersEditaccess if %command%==B set pswd=%tmpPswd% && set al=%tmpAL% && goto EOF

:usersEditusername cls echo. echo ================================================================= echo - echo - Reset Username echo - echo ================================================================= echo. set /p usersEditusername=Desired Username: del /s /q %location%\users\%username%.bat echo set pswd=%pswd%>>%location%\users\%usersEditusername%.bat echo set al=%al%>>%location%\users\%usersEditusername%.bat goto usersEdit

:usersEditpassword cls echo. echo ================================================================= echo - echo - Reset Password echo - echo ================================================================= echo. set /p usersEditpassword=Desired Password: echo set pswd=%usersEditpassword%>>%location%\users\%username%.bat echo set al=%al%>>%location%\users\%username%.bat goto usersEdit

:usersEditaccess cls echo. echo ================================================================= echo - echo - Reset Access Level echo - echo ================================================================= echo. set /p usersEditaccess=Access Level [User], [Admin]: echo set pswd=%pswd%>>%location%\users\%username%.bat echo set al=%usersEditaccess%>>%location%\users\%username%.bat set al=%tmpAL% set pswd=%tmpPswd% goto EOF

:usersCreate cls echo. echo ================================================================= echo - echo - User Creating echo - echo ================================================================= echo. timeout 02>nul echo To create an account simply type the username you wish. echo then the password option will appear.

REM Shows all usernames for /f "delims=" %%f in ('dir /b %location%\users\*.bat') do echo %%~nf REM Sets Username, Password, and Access Level set /p userName=Desired Username: set /p password=Desired Password: set /p accesslevel=Desired Level [User],[Admin]:

REM Sets all above into account Profile. if exist %location%\users\%userName%.bat echo %userName% already exists. && goto usersCreate echo set pswd=%password%>>%location%\users\%userName%.bat echo set al=%accesslevel%>>%location%\users\%userName%.bat echo Username: %userName% echo Password: %password% echo AccessLevel: %accesslevel% echo -------------------- Account Created. pause goto users

:usersDelete cls echo. echo ================================================================= echo - echo - User Deleting echo - echo ================================================================= echo. timeout 02>nul echo To delete an account simply type the username that you echo wish to remove. A prompt will appear to verify. echo. echo To remove all profiles use 'DeleteAll' timeout 02>nul REM Shows all usernames for /f "delims=" %%f in ('dir /b %location%\users\*.bat') do echo %%~nf

set /p userName=Username: if %userName%==DeleteAll rd /s /q %location% && cls %% echo All Profiles Removed. && timeout 02>nul && goto users set /p confirm=Are you sure you want to remove %userName%? [Y] [N]: if %confirm%==Y del /s /q %location%\users\%userName%.bat if %confirm%==y del /s /q %location%\users\%userName%.bat if %confirm%==n echo Cancelled Deletion of %userName% if %confirm%==N echo Cancelled Deletion of %userName% goto users

:: This section creates an administrator acccount so you can login if the program has never been run. :CreateAdmin cls echo. echo ================================================================= echo - echo - It appears you have never used echo - This computer before. Setting an account. echo - Username: admin echo - Password: admin echo - echo ================================================================= pause mkdir %location%\users set Uname=admin echo set pswd=admin>>%Location%\users\%Uname%.bat echo set al=Admin>>%Location%\users\%Uname%.bat cls goto EOF

:EOF

Step 2:

Comments

tomatoskins (author)2016-11-22

Very nice! Thanks for sharing and welcome to the community!

About This Instructable

87views

2favorites

License:

More by avengert:Start
Add instructable to: