Advertisement
ivandrofly

Windows Batch Scripting - Restore Hidden Files

Jan 26th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 9.67 KB | None | 0 0
  1. :: Hidden Files Restores v1.5.1
  2. :: THIS SCRIPTS WERE WRITTEN BY IVANDRO ISMAEL GOMES JAO
  3. @Echo off && Cls
  4.     setlocal enabledelayedexpansion
  5. :Menu
  6.     Title Hidden Files ^& Folder Restorer (v1.5.1) by: Ivandro Ismael
  7.     color a && Cls
  8.     Echo.
  9.     Echo.
  10.     Echo               ======================================================
  11.     Echo                     Enter the driver letter you want restore
  12.     Echo                Note: Make sure your don't entered the system driver
  13.     Echo                       Which is the mostly the (C:) letter
  14.     Echo              ========================================================
  15.     Echo                                                    By: Ivandro Ismael
  16.     Echo.
  17.    
  18.     Rem THIS WILL RESTORE ALL THE DATA STORED IN FOLLOWING VARIABLES
  19.     Set "dvr="
  20.     Set "sure="
  21.     Set /p dvr="Type Driver's Letter: "
  22.        
  23.         If /i "!dvr!" == "c" (
  24.             Echo.
  25.             Echo Your entered the system's driver are your sure about it
  26.             Echo If you don't know too much about it please to select is
  27.             Echo because it will restore you system files that can make your
  28.             Echo computer to lose system file...
  29.            
  30.                 Set /p sure="Type (y/n): "
  31.                     If /i "!sure!" == "n" (
  32.                         Echo.
  33.                         Cls
  34.                         Goto :Menu
  35.                     ) Else If /i "!sure!" == "y" (
  36.                         Echo.
  37.                         Echo You said yes
  38.                         Timeout /t 5
  39.                     ) Else If /i "!sure!" == "" (
  40.                         Echo.
  41.                         Echo Nothing entered a value to variable
  42.                         Pause >nul
  43.                         Cls && Goto :Menu
  44.                     ) Else (
  45.                         Echo.
  46.                         Echo The value you have entered isn't valid one^^!
  47.                         Echo please enter the valid option and press enter.
  48.                         Pause >nul
  49.                         Cls && Goto :Menu
  50.                     )
  51.         ) Else If /i "!dvr!" == "d" (
  52.             Echo.
  53.             Echo Your entered the driver D: are you sure about it
  54.             Echo because it's your backup driver?
  55.             Set /p sure="type (y/n): "
  56.                 If /i "!sure!" == "y" (
  57.                     Echo.
  58.                     Echo You just entered yes as your response...
  59.                     Timeout /t 5
  60.                 ) Else If /i "!sure!" == "n" (
  61.                     Echo.
  62.                     Echo Your entered the value NO
  63.                     Pause >nul
  64.                     Cls && Goto :Menu
  65.                 ) Else If /i "!!" == "" (
  66.                     Echo.
  67.                     Echo Nothing entered to the variable
  68.                     Echo Give a value to varible and press enter
  69.                     Pause >nul
  70.                     Cls && Goto :Menu
  71.                 ) Else (
  72.                     Echo.
  73.                     Echo The value you just entered ins't valid one
  74.                     Echo Re-Run the Scripts and enter the vaild option...
  75.                     Pause >nul
  76.                     Cls  && Goto :Menu
  77.                 )
  78.         ) Else If /i "!dvr!" == "" (
  79.             Echo.
  80.             Echo Nothing entered in variable
  81.             Echo Enter a valid driver letter which is already assigned
  82.             Echo in your system... If you don't know how to execute it
  83.             Echo please contact the scripts developer For help
  84.             Echo ==========================================
  85.             Echo Email: ivandrofly@gmail.com
  86.             Echo ==========================================
  87.             Pause >nul && Cls && Goto :Menu
  88.         )      
  89.     Echo.
  90.    
  91.     :: THIS LINE OF THE CODE WILL CHECK If THE DRIVER YOUR ENTERED IS ASSIGNED IN YOUR COMPUTER
  92.     Pushd "!dvr!:\" >nul 2>&1
  93.         If %ERRORLEVEL% neq 0 (
  94.             Set /a _count+=1
  95.             Echo.
  96.             Echo The driver your just entered isn't assigned ^| Valid
  97.             Echo make sure you entered the valid drive letter and try again
  98.             Echo The Counter is now !_count!
  99.            
  100.            
  101.             If !_count! equ 3 (
  102.                 Cls && Echo.
  103.                 Echo The scripts in now going to exit....
  104.                 Echo For more help try contant the script administrator
  105.                 Echo ==============================================
  106.                 Echo ^< Email: ivandrofly@gmail.com ^>
  107.                 Echo ^< Email #2: ivandrofly@outlook.com ^>
  108.                 Echo ^< Twitter: @ivandrofly ^>
  109.                 Echo ^< Facebook: http://www.facebook.com/ivandrofly ^>
  110.                 Echo ==============================================
  111.                 Timeout /t 5 /nobreak >nul && exit
  112.             )
  113.            
  114.             Pause >nul && Cls && Goto :Menu
  115.         )
  116.        
  117.     Echo ==========================================
  118.     :Me_Options
  119.     Echo.
  120.     Echo ===========================================================================
  121.     Echo           Chose the type of restore you want:
  122.     Echo     1- System Files : This will restore the system files and hidden files
  123.     Echo     2- Hidden Files : This will restore only the hidden file there is...
  124.     Echo ===========================================================================
  125.     Echo.
  126.     Echo.
  127.     Rem THIS WILL RESET THE VALUE OF TYPE TO NUL EVERYTIME YOU ENTERED THE INVALID VALUE IT WILL BE RESETED
  128.     Set "type="
  129.     Set /p type="Type what kinda restore do you want: "
  130.         If /i "!type!" == "" (Echo Nothing entered in variable. && Pause >nul && Cls && Goto :Me_Options)
  131.         If /i "!type!" == "2" (Cls && Goto :Hidden_Files_Restorer)
  132.         If /i "!type!" == "1" (Cls && Goto :System_Files_Restorer) Else (
  133.             Echo The value you entered isn't the valid one.
  134.             Pause >nul && Cls && Goto :Me_Options
  135.         )
  136.        
  137. :Hidden_Files_Restorer
  138.     title Hidden Files Restorer
  139.     Echo.
  140.     Echo.
  141.     Rem This line will restore the following variables below
  142.     Set /a "skip=0"
  143.     Set /a "rest=0"
  144.     del /q *.lnk >nul
  145.     Rem "DELIMS= " NOT ADDED ^(Not Needed^)
  146.     Rem I'LL ADD RECYCLE BIN SKIP
  147.     Echo ==========================================
  148.     For /f "tokens=*" %%G in ('dir /a /o /s /b') Do (
  149.         Rem %%~NXG mean name extension and argument
  150.         If /i "%%~nxG" == "autorun.inf" (
  151.             Echo -----------------------------------
  152.             Echo Skipped File --^> %%~sG
  153.             Echo -----------------------------------
  154.             Set /a skip += 1
  155.         ) Else If /i "%%~nxG" == "driver.ico" (
  156.             Echo -----------------------------------
  157.             Echo Skipped File --^> %%~sG
  158.             Echo -----------------------------------
  159.             Set /a skip += 1
  160.         ) Else (
  161.             Rem THE /D SWITCH IS ONLY VALID WITH THE /S SWITCH.
  162.             Rem THIS LINE WILL ONLY RESTORE FILES WHICH ARE ATTRIBUTED HIDDEN ^!= SYSTEM
  163.             For /f "usebackq" %%I in (`attrib -h -r "%%G"`) Do (
  164.                 REM NOTE THAT THIS LINE WILL ONLY BE RAN WHEN  THE SCRIPT FIND A SYSTEM FILE   
  165.                 REM NOTE THAT THERE ARE A LITTLE BUGS IN HERE THE SCRIPTS HAVE SOME PROBLEMS WHILE RUNNING
  166.                 If /i "%%~I" == "Not" (
  167.                     Echo.
  168.                     Echo You are trying to restore the system files
  169.                     Echo to restore the system files enter the system option...
  170.                     timeout /t 5 /nobreak >nul
  171.                     REM Goto :Menu
  172.                     REM Timeout /nobreak /t 5 1>nul
  173.                 )  
  174.             )
  175.             Echo Processed --^> %%~sG
  176.             Set /a rest += 1
  177.         )
  178.     )
  179.     Popd
  180.     Echo ==========================================
  181.     Echo.
  182.     Echo.
  183.     Echo                             Command Completed Successfully
  184.     Echo.
  185.     Echo                                         Statistic
  186.     Echo                          ======================================
  187.     Echo                            Total Skipped Files   ---^> [!skip!]
  188.     Echo                            Total Restored Files  ---^> [!rest!]
  189.     Echo                          ======================================
  190.     Echo Note: The skipped files are the "autorun.inf" and the "driver.ico"
  191.     Pause >nul && Cls && Goto :submenu
  192.    
  193.    
  194. :System_Files_Restorer
  195.     title System Files ^& Hidden Files Restorer
  196.     Echo.
  197.     Echo.
  198.     Rem This line will restore the following variables below
  199.     Set /a "skip=0"
  200.     Set /a "rest=0"
  201.     Rem "DELIMS= " NOT ADDED ^(Not Needed^)
  202.     Rem I'LL ADD RECYCLE BIN SKIP
  203.     del *.lnk >nul
  204.     For /f "tokens=*" %%G in ('dir /a /o /s /b') do (
  205.         If /i "%%~nxG" == "autorun.inf" (
  206.             Echo Skipped  --^> %%~sG
  207.             Set /a skip += 1
  208.             REM ACTUALLY I STOP USING THE ICON NAME AS DRIVER.ICO
  209.         ) Else If /i "%%~nxG" == "Driver.ico" (
  210.             Echo Skipped --^> %%~sG
  211.             Set /a skip += 1
  212.         ) Else (
  213.         Rem The /D switch is only valid with the /S switch.
  214.         Rem I add to restore only file without system attribute
  215.             Attrib -h -s -r "%%G" >nul
  216.             Echo Processed --^> %%~sG
  217.             Set  /a rest += 1
  218.         )
  219.     )
  220.     Popd
  221.     Echo ==========================================
  222.     Echo.
  223.     Echo.
  224.     Echo                             Command Completed Successfully
  225.     Echo.
  226.     Echo                                         Statistic
  227.     Echo                          ======================================
  228.     Echo                            Total Skipped Files   ---^> [!skip!]
  229.     Echo                            Total Files Precessed  ---^> [!rest!]
  230.     Echo                          ======================================
  231.     Echo                                              by: Ivandro Ismael
  232.     Pause >nul && Cls && Goto :submenu
  233.        
  234. :submenu
  235.     Echo.
  236.     Echo.
  237.     Rem THIS LINE WILL RESTORE THE VARIABLE 'X' TO IS DEFAULT VALUE
  238.     Set "x="
  239.     Echo Do You Want RE-RUN The Scripts?
  240.     Set /p "x=Type (y/n): "
  241.    
  242.         If /i "!x:~0,1!" == "y" (
  243.             Cls && Set /a g=0 && Goto :Menu
  244.         ) Else If /i "!x:~0,1!" == "n" (
  245.             Echo.
  246.             Echo.
  247.             Echo Thank you For ussing the Scripts^^!^^!
  248.             Timeout /nobreak /t 3 >nul
  249.             exit /b
  250.             REM THIS IS HOW TO COMPARE THE EMPTY VARIABLE With SUBSTRING
  251.         ) Else If /i "!x:~0,1!" == "~0,1" (
  252.             Set /a g+=1
  253.             Echo.
  254.             Echo.
  255.             Echo Nothing Entered Try Again^^!^^!^^!
  256.             Echo make sure you entere a option and try again
  257.             Echo If you keep getting this same eror the scripts is going to
  258.             Echo quit automaticly....
  259.            
  260.             If !g! equ 3 (
  261.                 Echo.
  262.                 Echo.
  263.                 Echo All Attemps are finished now the scripts is going to
  264.                 Echo quite automaticly... thanks For running the script^^!
  265.                 Rem THE Exit /b :WILL ONLY STOP RUNNING THE BATCH SCRIPT, If the scripts were called be MSDos it
  266.                 Rem WILL KEEP RUNNING...
  267.                 Timeout /t 5 /nobrak 1>nul && Cls && exit /b
  268.             )
  269.             REM THIS LINE WILL PREVENT THE TIMER TO BE SHOWN
  270.             Timeout /nobreak /t 3 >nul
  271.             Cls && Goto :submenu
  272.         ) Else (
  273.             Echo.
  274.             Echo.
  275.             Echo The value you just entered isn't defined^^!^^!
  276.             Echo Make sure you entered the valid value and try again
  277.             echo If you keep getting this messeage then contact you adim
  278.             echo ========================================
  279.             echo Email: ivandrofly@hotmail.com
  280.             echo Or you can follow me on Twitter by @ivandrofly
  281.             echo ========================================
  282.             Echo ---^> [!x!]
  283.             Pause >nul && Cls && Goto :submenu
  284.         )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement