Showing posts with label Z2_DOS. Show all posts
Showing posts with label Z2_DOS. Show all posts

Saturday, February 7, 2015

Save, Restore, Repair MBR using MBRwizard CLI

  • Download MBRwizard CLI from : Click Here
  • For MBRWizard examples : Click Here
  • Save below script as 1mbrwiz.cmd and Execute  It:

REM------------- BEGIN 1mbrwiz.cmd codes -----------------------

@echo off

rem 1mbrwiz.cmd
rem To backup the MBR using %MBRWIZFILE%

setlocal
%~d0
cd "%~dp0"
set OPTION=mbr
set MBRWIZFILE=mbrwiz64.exe
if not exist %MBRWIZFILE% goto _ERROR1

:MENU
title MBRWizard Menu
set _choice=
cls
echo.
echo *********************************************
echo Please select which MBRWizard options to run
echo *********************************************
echo.
echo 1 List MBR entries
echo 2 Hides the Partition number
echo 3 Unhides the Partition number
echo 4 Activates the Partition
echo 5 De-activates the Partition number
echo 6 Deletes the partition
echo 7 Wipes the MBR or wipes the first 63 sectors of disk
echo 8 Saves the MBR to filename
echo 9 Reads and restores the Disk MBR from filename
echo 10 Shows contents of an existing MBR backup file
echo 11 Sort MBR Entries by disk location
echo 12 Repair MBR for Win7 OS for input disk
echo 13 Writes detailed disk and partition information

echo.
echo Press [ENTER] to exit
echo.
echo.
set /p _choice="Enter choice number: "
echo.
if "%_choice%" == "" goto EXIT
cls
if "%_choice%" == "1" goto ListMBR
if "%_choice%" == "2" goto HidePartition
if "%_choice%" == "3" goto UnhidePartition
if "%_choice%" == "4" goto ActivatePartition
if "%_choice%" == "5" goto InactivatePartition
if "%_choice%" == "6" goto DeletePartition
if "%_choice%" == "7" goto WipeMBR
if "%_choice%" == "8" goto SaveMBR
if "%_choice%" == "9" goto RestoreMBR
if "%_choice%" == "10" goto ShowMBR
if "%_choice%" == "11" goto SortMBR
if "%_choice%" == "12" goto RepairMBR
if "%_choice%" == "13" goto Writesini


:Writesini
title MBRWizard -     Writes detailed disk and partition information to filename in a .ini format.
set DriveNumber=
set Filename=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
set Filename=hd%DriveNumber%.ini
echo.
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /Writeini /filename=%Filename%
echo.
%MBRWIZFILE% /disk=%DriveNumber% /Writeini /filename=%Filename%
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:RepairMBR
title MBRWizard - Repair MBR for Win7 OS for input disk
echo.
set DriveNumber=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
echo.
if "%DriveNumber%" == "" goto EXIT
echo.
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /repair=win7
echo.
%MBRWIZFILE% /disk=%DriveNumber% /repair=win7
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:ListMBR
title MBRWizard - List MBR entries
echo.
echo Running: %MBRWIZFILE% /list
echo.
%MBRWIZFILE% /list
echo.
goto EXIT

:HidePartition
title MBRWizard - Hides the Partition number
set DriveNumber=
set PartitionNumber=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter the partition ID to hide ("0" for 1st,
echo "1" for 2nd, ... or "*" for all).
echo.
echo Press [ENTER] to abort.
echo.
set /p PartitionNumber="Enter partition number to hide: "
if "%PartitionNumber%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /hide /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /hide /list
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:UnhidePartition
title MBRWizard - Unhides the Partition number
set DriveNumber=
set PartitionNumber=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter the partition ID to unhide ("0" for 1st,
echo "1" for 2nd, ...; "*" for all).
echo.
echo Press [ENTER] to abort.
echo.
set /p PartitionNumber="Enter partition number: "
if "%PartitionNumber%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /unhide  /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /unhide /list
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:ActivatePartition
title MBRWizard - Activates the Partition
set DriveNumber=
set PartitionNumber=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo If you do not know which HDD to choose, please enter
echo 'bm' to call the bootmenu.
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
if "%DriveNumber%" == "bm" goto BOOTMENU
echo.
echo Please enter the partition ID to activate ("0" for 1st, "1" for 2nd, ...).
echo.
echo Press [ENTER] to abort.
echo.
set /p PartitionNumber="Enter partition number: "
if "%PartitionNumber%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /active /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /active /list
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:InactivatePartition
title MBRWizard - De-activates the partition number
set DriveNumber=
set PartitionNumber=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter the partition ID to deactivate ("0" for 1st,
echo "1" for 2nd, ...; "*" for all).
echo.
echo Press [ENTER] to abort.
echo.
set /p PartitionNumber="Enter partition number: "
if "%PartitionNumber%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /inactive /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /inactive /list
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:DeletePartition
title MBRWizard - Deletes the partition
set DriveNumber=
set PartitionNumber=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter the partition ID to delete ("0" for 1st, "1" for 2nd, ...).
echo.
echo Press [ENTER] to abort.
echo.
set /p PartitionNumber="Enter partition number: "
if "%PartitionNumber%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /del /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /part=%PartitionNumber% /del /list
goto EXIT

:WipeMBR
title MBRWizard - Wipes the MBR or wipes the first 63 sectors of disk
set DriveNumber=
set OPTION=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter "1" for wipes the MBR, "2" for wipes of first 63 sectors of disk.
echo.
echo Press [ENTER] to abort.
echo.
set /p OPTION="Enter option: "
if "%OPTION%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /wipe=%OPTION% /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /wipe=%OPTION% /list
goto EXIT

:SaveMBR
title MBRWizard - Save the MBR to filename
set DriveNumber=
set Filename=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter filename to save (eg: hd0.mbr)
echo.
echo Press [ENTER] to abort.
echo.
set /p Filename="Enter filename: "
if "%Filename%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /save=MBR /filename=%Filename%
echo.
%MBRWIZFILE% /disk=%DriveNumber% /save=MBR /filename=%Filename%
echo.
goto EXIT

:RestoreMBR
title MBRWizard - Reads and restores the Disk MBR from filename
set DriveNumber=
set Filename=
echo.
echo Please enter the HDD to use ("0" for 1st, "1" for 2nd, ...)
echo.
echo Press [ENTER] to abort.
echo.
set /p DriveNumber="Enter drive number: "
if "%DriveNumber%" == "" goto EXIT
echo.
echo Please enter filename to restore (eg: hd0.mbr)
echo.
echo Press [ENTER] to abort.
echo.
set /p Filename="Enter filename: "
if "%Filename%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE% /disk=%DriveNumber% /restore=MBR /filename=%Filename% /list
echo.
%MBRWIZFILE% /disk=%DriveNumber% /restore=MBR /filename=%Filename% /list
echo.
goto EXIT

:ShowMBR
title MBRWizard - Shows contents of an existing MBR backup file
set Filename=
echo.
echo Please enter filename to display (eg: hd0.mbr)
echo.
echo Press [ENTER] to abort.
echo.
set /p Filename="Enter filename: "
if "%Filename%" == "" goto EXIT
echo.
cls
echo Running: %MBRWIZFILE%  /show=file /filename=%Filename%
echo.
%MBRWIZFILE% /show=file /filename=%Filename%
goto EXIT

:SortMBR
title MBRWizard - Sort MBR Entries by disk location
echo.
echo Running: %MBRWIZFILE% /issorted /list
echo.
%MBRWIZFILE% /issorted /list
if "%errorlevel%" == "1" goto NotSort
echo The partition entries in the MBR are already sorted.
goto EXIT

:NotSort
set INPUT=
echo The partition entries in the MBR are not sorted.
echo Do you want MBRWizard to sort the partition entries ?
echo.
echo Press [ENTER] to abort.
echo.
set /p INPUT="Enter [y]es or [n]o: "
echo.
if /I "%INPUT%" == "" goto EXIT
if /I "%INPUT%" == "n" goto EXIT
cls
echo Running: %MBRWIZFILE% /sort /list
echo.
%MBRWIZFILE% /sort /list
if "%errorlevel%" == "0" goto SUCCESS
goto EXIT

:SUCCESS
echo.
echo Operation completed successfully.
echo.
goto EXIT

:EXIT
set _exit=
echo.
echo Do you want to exit MBRWiz ?
echo.
set /p _exit="Enter [y]es or [n]o: "
if /I "%_exit%" == "" goto EXIT
if /I "%_exit%" == "n" goto MENU
if /I "%_exit%" == "y" goto END


:BOOTMENU
cls
echo Running: %MBRWIZFILE% /bootmenu
echo.
%MBRWIZFILE% /bootmenu
echo.
if "%errorlevel%" == "0" goto SUCCESS
echo.
goto EXIT

:_ERROR1
echo.
echo ERROR: %MBRWIZFILE% file not found
echo Kindly check if you have downloaded the MBRWiz from
echo http://www.mbrwizard.com
goto END

:END
endlocal

REM ------------- END 1mbrwiz.cmd codes --------------------------

Tuesday, October 8, 2013

File Search

@REM....&SETLOCAL ENABLEEXTENSIONS&SETLOCAL DISABLEDELAYEDEXPANSION
@REM....&set /p s=FileSearch, type '-' to refresh lookup list: ||GOTO:EOF
@REM....&if .%s% NEQ .- echo.&findstr %s% "%~f0"&PAUSE&GOTO:EOF
@REM....&findstr /b /c:"@REM....&" "%~f0">"%~f0.txt"
@REM....&dir /s/b c:\ 1>>"%~f0.txt"&move /Y "%~f0.txt" "%~f0"
@REM....&GOTO:EOF

Find and Replace

@echo off
REM -- Prepare the Command Processor --
SETLOCAL ENABLEEXTENSIONS
SETLOCAL DISABLEDELAYEDEXPANSION
::BatchSubstitude - parses a File line by line and replaces a substring"
::syntax: BatchSubstitude.bat OldStr NewStr File
::          OldStr [in] - string to be replaced
::          NewStr [in] - string to replace with
::          File   [in] - file to be parsed
if "%~1"=="" findstr "^::" "%~f0"&GOTO:EOF
for /f "tokens=1,* delims=]" %%A in ('"type %3|find /n /v """') do (
    set "line=%%B"
    if defined line (
        call set "line=echo.%%line:%~1=%~2%%"
        for /f "delims=" %%X in ('"echo."%%line%%""') do %%~X
    ) ELSE echo.
)

Sunday, September 8, 2013

Delete all SVN Folder

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""


Using Bat File

for /f "tokens=* delims=" %%i in ('dir /s /b /a:d *.svn') do (rd /s /q "%%i")

Tuesday, April 30, 2013

Recursively List File Name in DOS/Windows

for /r %i in (*) do @echo %~ni >> list.txt

If you end up wanting the extensions, change %~ni to %~nxi

To use in a batch file, change all the % to %%

Wednesday, January 30, 2013

Find and Replace using Bat file

@echo off
setlocal enabledelayedexpansion
set INTEXTFILE=license.opt
set OUTTEXTFILE=license.txt
set SEARCHTEXT=172.19.32.166
set REPLACETEXT=hello
set OUTPUTLINE=

for /f "tokens=1,* delims=¶" %%A in ( '"type %INTEXTFILE%"') do (
SET string=%%A
SET modified=!string:%SEARCHTEXT%=%REPLACETEXT%!

echo !modified! >> %OUTTEXTFILE%
)
del %INTEXTFILE%
rename %OUTTEXTFILE% %INTEXTFILE%

Finding Windows OS version using Batch file

Echo Please wait.... detecting Windows OS version...
ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto done

ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp

ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto done

ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto done

if not exist %SystemRoot%\system32\systeminfo.exe goto warnthenexit

systeminfo | find "OS Name" > %TEMP%\osname.txt
FOR /F "usebackq delims=: tokens=2" %%i IN (%TEMP%\osname.txt) DO set vers=%%i

echo %vers% | find "Windows 7" > nul
if %ERRORLEVEL% == 0 goto ver_7

echo %vers% | find "Windows Server 2008" > nul
if %ERRORLEVEL% == 0 goto done

echo %vers% | find "Windows Vista" > nul
if %ERRORLEVEL% == 0 goto ver_7

goto warnthenexit

Tuesday, August 30, 2011

Net Share

REM Interactive Net Share bat file
@echo Off
SET Choice=
SET /P Choice="Do you want to Share [C:\temp]? [Y,N] : "
IF /I '%Choice%'=='Y' GOTO Yes
IF /I '%Choice%'=='N' GOTO No
goto Label2
:Yes
Echo Creating share........
net share bipin="C:\temp"
goto end
:No
Echo Deleting share.......
net share bipin /delete
goto end
:end

- Creating network drives with a batch file
net use z: \\computername, ip-add\sharename /persistent:no /user:username password
or
net use z: \\laptop\network /persistent:no
- Hide your computer from the network
net config server /HIDDEN:YES
- How to know which folders are shared
At command prompt: Rundll32.exe ntlanui.dll,ShareManage
 - Hiding shared folders from the network
Add a dollar-sign ($) at the end of the share name

Folder Locker

- Save below line as bat file and run,
- Locker name folder is created,
- Put everthing, You want to hide,
- And again run the bat file.
- It will hide the locker folder and it will associate bat file as Control Panel.
- Again run bat file to unlock the folder.
- Change Password as you like.

cls
@ECHO OFF
title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock folder
set/p "pass=>"
if NOT %pass%==007 here goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Locker
echo Locker created successfully
goto End
:End