Below are some useful scripts I’ve made thru out the years to simplify daily tasks. Maybe they will be useful for you all, by all means use them. The codes isn’t copyrighted.

======================================================================

======================================================================

Correcting a Corrupt Roaming Profile

This script will force ownership of a users roam profile to gain access to it.

 

@echo off
color 0A
title Corrupt Roaming Profile Change.

:start
echo Welcome, %USERNAME%
echo What would you like to do?
echo.
echo 1. Click here for a quetionable photo!
echo 2. Take Ownership of User’s Roaming Profile
echo.
echo 0. Quit
echo.

set /p choice=”Enter your choice: ”
if “%choice%”==”1” goto honeypot
if “%choice%”==”2” goto ownership-change
echo.
if “%choice%”==”0″ exit
echo Invalid choice: %choice%
echo.
pause
cls
goto start

:honeypot
cls
echo just kidding, you clicked on this option shame on you!!!
echo.
goto cancel-special

:ownership-change
echo.
set /p profile=”Enter user profile: ”
IF EXIST “d:\profiles\%profile%.DOMAIN.V2” psexec -s “icacls” “d:\profiles\%profile%.DOMAIN.V2″ /grant administrators:F /t
echo roaming profile forced ownership change in progress…
echo.

:cancel-special
set /p cancel=”Type cancel to stop action: ”
if not “%cancel%”==”cancel” exit
cls
echo Action is cancelled.
echo.

pause
exit

 

 

================================================================

================================================================

Print Spooler Reset Script

 

@echo off
color 0A
title Fix Printer Spooler.

:start
echo Welcome, %USERNAME%
echo.
echo What would you like to do?
echo.
echo 1. Stop Print Spooler
echo.
echo. Please select both option 3 and option 4 before starting the printer spooler
echo.
echo 2. Delete .shd files in PRINTERS folder
echo 3. Delete .spl files in PRINTERS folder
echo.
echo 4. Start Print Spooler
echo.
echo 0. Quit
echo.

set /p choice=”Enter your choice: ”
if “%choice%”==”1” net stop spooler
if “%choice%”==”2” del %systemroot%\System32\spool\printers\*.shd /q
if “%choice%”==”3” del %systemroot%\System32\spool\printers\*.spl /q
if “%choice%”==”4” net start spooler
if “%choice%”==”0” exit
echo Invalid choice: %choice%
echo.
pause
cls
goto start

exit

 

 

=======================================================

=======================================================

Close that program Script

 

*very useful for pesky programs that won’t close on remote servers; NOTE: pskill will be need on client that needs the program killed*

 

@echo off
color 0A
title close that porgram.

:start
echo Welcome, %USERNAME%
echo What would you like to do?
echo.
echo 1. Close the program in question
echo.
echo 2. Click here for a interesting finding!
echo.
echo 0. Quit
echo.

set /p choice=”Enter your choice: ”
if “%choice%”==”1” goto program-kill
if “%choice%”==”2” goto honeypot
echo.
if “%choice%”==”0″ exit
echo Invalid choice: %choice%
echo.
pause
cls
goto start

:honeypot
cls
echo just kidding, you clicked on this option shame on you!!!
echo.
goto cancel-special

:program-kill
echo.
set /p computer=”Enter computer name:”
set /p program=”Enter program name (before .exe): ”
IF EXIST pskill “\\%computer% %program%.exe”  /grant administrators:F /t
echo pesky program is closing……
echo.

:cancel-special
set /p cancel=”Type cancel to stop action: ”
if not “%cancel%”==”cancel” exit
cls
echo Action is cancelled.
echo.

pause
exit

 

 

==================================================================================

==================================================================================

Conditional Shutdown Script

 

@echo off
color 0A
title Conditional Shutdown.

:start
echo Welcome, %USERNAME%
echo What would you like to do?
echo.
echo 1. Shutdown in specified time
echo 2. Shutdown at a specified time
echo 3. Shutdown now
echo 4. Restart now
echo 5. Log off now
echo.
echo 0. Quit
echo.

set /p choice=”Enter your choice: ”
if “%choice%”==”1” goto shutdown
if “%choice%”==”2” goto shutdown-timed
if “%choice%”==”3” shutdown.exe -s -f
if “%choice%”==”4” shutdown.exe -r -f
if “%choice%”==”5” shutdown.exe -l -f
if “%choice%”==”0″ exit
echo Invalid choice: %choice%
echo.
pause
cls
goto start

:shutdown
cls
set /p min=”Minutes until shutdown: ”
set /a sec=60*%min%
shutdown.exe -s -f -t %sec%
echo Shutdown initiated at %time%
echo.
goto cancel

:shutdown-timed
echo.
echo the time format is HH:MM:SS (24 hour time)
echo example: 14:30:00 for 2:30 PM
echo.
set /p tmg=enter the time that you wish the computer to shutdown on:
schtasks.exe /create /sc ONCE /tn shutdown /st %tmg% /tr “shutdown.exe -s -t 00″
echo shutdown initiated at %tmg%
echo.

:cancel
set /p cancel=”Type cancel to stop shutdown: ”
if not “%cancel%”==”cancel” exit
shutdown.exe -a
cls
schtasks.exe /end /tn shutdown
cls
schtasks.exe /delete /tn shutdown
cls
echo Shutdown is cancelled.
echo.
pause
exit

 

==================================================================================

==================================================================================

Moving local profile on a desktop PC to a Centralized server such as a File Server

 

@echo off
color 0A
title Moving Local Profile folder to Centralized Profile Folder on Core Server.

:start
echo Welcome, %USERNAME%
echo What would you like to do?
echo.
echo 1. Moving Local Profile folder to Centralized Profile Folder on Core Server
echo.
echo 0. Quit
echo.

set /p choice=”Enter your choice: ”
if “%choice%”==”1” goto Move-user-profiles
echo.
if “%choice%”==”0″ exit
echo Invalid choice: %choice%
echo.
pause
cls
goto start

:Move-user-profiles
echo.
set /p username=”Enter user profile: ”
move “\\[Local client name]\users\%username%\desktop” *.* “\\[Remote Server name: ie File Server]\users\%username%\desktop”
move “\\[Local client name]\users\%username%\favorites” *.* “\\[Remote Server name: ie File Server]\users\%username%\favorites”
echo moving files from local profile folder to FS1 profile server, stand-by…
echo.
goto cancel-special

:cancel-special
set /p cancel=”Type cancel to stop action: ”
if not “%cancel%”==”cancel” exit
cls
echo Action is cancelled.
echo.

pause
exit