Advertisement
SmartGenius

Virtual Drive v 3

Jul 6th, 2012
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.39 KB | None | 0 0
  1. @Echo Off
  2. @Title Virtual Drive v 3 Revolution - SmartGenius, Corp. 2012
  3. Setlocal Enabledelayedexpansion
  4.  
  5. :Init
  6. Call :GetSID
  7. Call :GetWorkPath
  8. Call :Config
  9.  
  10. :Main
  11. Cls
  12. Echo.
  13. Echo. 1. Open Drive
  14. Echo. 2. Close Drive
  15. Echo. 3. Create Drive
  16. Echo. 4. Delete Drive
  17. Echo. 5. Show Info
  18. Echo. 6. Get help
  19. Echo. 7. Exit
  20. Echo.
  21. Set /p "User= Choice an option from the list > "
  22. If Not Defined User Goto :Main
  23. If "1"=="%User%" (
  24. Call :Select
  25. Call :OpenDrive "!Opc!")
  26. If "2"=="%User%" (
  27. Call :Select
  28. Call :CloseDrive "!Opc!")
  29. If "3"=="%User%" (Call :CreateDrive)
  30. If "4"=="%User%" (
  31. Call :Select
  32. Call :DeleteDrive "!Opc!")
  33. If "5"=="%User%" (Goto :ShowOpc)
  34. If "6"=="%User%" (Goto :GetHelp)
  35. If "7"=="%User%" (Echo. Thanks for using this software&Pause&Exit)
  36. If "8"=="%User%" (Goto :QuitVD)
  37. Goto :Main
  38.  
  39. :ShowOpc
  40. Cls
  41. Echo.
  42. Echo. Virtual Drive v 3 Info
  43. Echo.
  44. Echo. User = %Username%
  45. Echo. SID = %SID%
  46. Echo. Path = %WorkPath%
  47. Echo. Version = %Version%
  48. Echo. Drives = %NumDrives%
  49. Echo.
  50. Pause
  51. Goto :Main
  52.  
  53. :GetHelp
  54. Cls
  55. Echo. Virtual Drive v 3 Revolution
  56. Echo.
  57. Echo. Simple Batch Soft to Manage Virtual Drives
  58. Echo.
  59. Echo. Open, Close, Create or Delete Virtual Drives
  60. Echo. with the option to use Password on New Drive
  61. Echo. created.
  62. Echo.
  63. Echo. For More Help, Go to the Forums
  64. Echo.
  65. Echo. http://www.redinfocol.org
  66. Echo. http://twitter.com/thesmartgenius
  67. Echo.
  68. Echo. SmartGenius, Corp. 2012
  69. Echo.
  70. Pause
  71. Goto :Main
  72.  
  73. ::::::::::::::::: Drive functions :::::::::::::::::::::::::::::::::::::::::::::::
  74.  
  75. :ListDrives
  76. Echo. Avaliable Drives
  77. For /l %%n in (1,1,%NumDrives%) do (
  78. Call :GetDriveProps "%%n"
  79. Echo. %%n - Drive #%%n [!Drive%%n_Alias!])
  80. Echo.
  81. Goto :Eof
  82.  
  83. :OpenDrive
  84. Call :GetDriveProps "%~1"
  85. If Not "Null"=="!Drive%~1_Key!" (
  86. Echo. The Drive "!Drive%~1_Alias!" is protected.
  87. Call :GetPass "!Drive%~1_Alias!" "%~1")
  88. Call :Unlock "%~1"
  89. Start "" !Drive%~1_Letter!
  90. Ping -n 2 localhost >nul
  91. Goto :Eof
  92.  
  93. :CloseDrive
  94. Echo. Closing "!Drive%~1_Alias!"
  95. For /f "tokens=1 delims=\" %%S in ('Subst^|Find "Drive%~1"') do (
  96. Subst /D %%S
  97. Cacls "%WorkPath%\VD\Drive%~1" /e /d Todos>nul 2>&1
  98. )
  99. Ping -n 2 localhost >nul
  100. Goto :Eof
  101.  
  102. :CreateDrive
  103. Cls
  104. Echo.
  105. Set /a "nDrive=%NumDrives%+1"
  106. Echo. Creating New Virtual Drive
  107. Set /p "nAlias= Enter an Alias for the Drive > "
  108. If Not Defined nAlias Set "nAlias=VD_%nDrive%"
  109. Set /p "nKey= Enter a Password Key for the Drive > "
  110. If Not Defined nKey Set "nKey=Null"
  111. If Not "Null"=="%nKey%" (Set "mKey=%nKey%"&Call :Key mKey) else (Set "mKey=Null")
  112. Echo. New Virtual Drive #%nDrive% will be created
  113. Echo. Drive #%nDrive% "Alias=%nAlias%" - "Password=%nKey%"
  114. Echo.
  115. MD "%WorkPath%\VD\Drive%nDrive%" >nul 2>&1
  116. For %%a in ("Alias=%nAlias%","Key=%mKey%") do (Echo.%%~a>>"%WorkPath%\VD\Drive%nDrive%\Properties.vdf")
  117. Attrib +h "%WorkPath%\VD\Drive%nDrive%\Properties.vdf">nul 2>&1
  118. Set /a "NumDrives=%NumDrives%+1"
  119. Reg Add "%R_Key%" /v NumDrives /d %NumDrives% /f >nul 2>&1
  120. Pause
  121. Goto :Eof
  122.  
  123. :DeleteDrive
  124. Cls
  125. Echo.
  126. Echo. You will delete Drive #~1 [!Drive%~1_Alias!]
  127. Echo. This will delete all files and folder in it
  128. Echo.
  129. Set /p "YNDel= Are you sure ? [Y] Yes - [N] No >
  130. If Not Defined YNDel Goto :Main
  131. If /i Not "Y"=="%YNDel%" (Goto :Main)
  132. Echo. Deleting Drive #%~1 [!Drive%~1_Alias!]
  133. Cacls "%WorkPath%\VD\Drive%~1" /e /p Todos:f>nul 2>&1
  134. RD /s /q "%WorkPath%\VD\Drive%~1">nul 2>&1
  135. Set /a "NumDrives=%NumDrives%-1"
  136. Reg Add "%R_Key%" /v NumDrives /d %NumDrives% /f >nul 2>&1
  137. Pause
  138. Goto :Main
  139.  
  140. :GetDriveProps
  141. Cacls "%WorkPath%\VD\Drive%~1" /e /p Todos:f>nul 2>&1
  142. For %%P in (Alias,Key) do (
  143. For /f "tokens=2 delims==" %%R in ('Type "%WorkPath%\VD\Drive%~1\Properties.vdf"^|Find "%%P"') do (
  144. Set "Drive%~1_%%P=%%R"
  145. ))
  146. Cacls "%WorkPath%\VD\Drive%~1" /e /d Todos>nul 2>&1
  147. Goto :Eof
  148.  
  149. :Unlock
  150. Echo. Unlocking Drive%~1
  151. Cacls "%WorkPath%\VD\Drive%~1" /e /p Todos:f>nul 2>&1
  152. For %%D in (Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G) do (If Not Exist "%%D:" (Set "FreeDrive=%%D:"))
  153. Subst "%FreeDrive%" "%WorkPath%\VD\Drive%~1"
  154. Set "Drive%~1_Letter=%FreeDrive%"
  155. Goto :Eof
  156. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  157.  
  158. :::::::::::::::::::: User interaction :::::::::::::::::::::::::::::::::::::::::::::::
  159. :GetPass
  160. Set "Pass="
  161. Set /p "Pass= Enter Password for "%~1" Drive > "
  162. If Not Defined Pass Goto :GetPass
  163. Call :Key Pass
  164. If Not "!Drive%~2_Key!"=="%Pass%" (
  165. Echo. Bad Password.
  166. Pause
  167. Goto :Main)
  168. Goto :Eof
  169.  
  170. :Select
  171. Cls
  172. Echo.
  173. Call :ListDrives
  174. Set /p "Opc= Choice an option from the list > "
  175. If Not Defined Opc Goto :Select
  176. Set /a "Max=%NumDrives%+1"
  177. If %Opc% GEQ %Max% Goto :Main
  178. Goto :Eof
  179. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  180. :::::::::::::::::::::::::Main Program Functions::::::::::::::::::
  181.  
  182. :GetSID
  183. For /f "tokens=*" %%s in ('Dir "%appdata%\Microsoft\Credentials" /b /a:d') do (Set "SID=%%s")
  184. If Not [""]==["%SID%"] (Set "SID=%SID%") else (
  185. For /f "tokens=5 delims=\" %%a in ('Reg Query "HKCU\Software\Microsoft\Protected Storage System Provider"') do (Set "SID=%%a")
  186. If Not [""]==["!SID!"] (Set "SID=!SID!") else (
  187. Set "SID=Null"))
  188. Goto :Eof
  189.  
  190. :GetWorkPath
  191. For %%W in (RECYCLER $Recycle.Bin) do (
  192. If Exist "%SystemDrive%\%%W\%SID%" (Set "WorkPath=%SystemDrive%\%%W\%SID%"))
  193. Goto :Eof
  194.  
  195. :Config
  196. Set "R_Key=HKCU\Software\SmartGenius\VirtualDrive"
  197. Reg Query "%R_Key%" /v Version >nul 2>&1
  198. If "%Errorlevel%"=="1" (Call :Install)
  199. Call :ReadReg
  200. Goto :Eof
  201.  
  202. :Install
  203. Echo. Instalando VirtualDrive v 3
  204. For %%a in (
  205. "/v Version /d 3"
  206. "/v NumDrives /d 1"
  207. ) do (Reg Add "%R_Key%" %%~a /f >nul 2>&1)
  208. MD "%WorkPath%\VD" >nul 2>&1
  209. MD "%WorkPath%\VD\Drive1" >nul 2>&1
  210. For %%a in ("Alias=Default","Key=Null") do (Echo.%%~a>>"%WorkPath%\VD\Drive1\Properties.vdf")
  211. Goto :Eof
  212.  
  213. :ReadReg
  214. For %%a in (Version,NumDrives) do (
  215. For /f "tokens=3" %%b in ('Reg Query "%R_Key%" /v %%a') do (Set "%%a=%%b"))
  216. For /l %%n in (1,1,%NumDrives%) do (Set "Path_Drive%%n=%WorkPath%\VD\Drive%%n")
  217. Goto :Eof
  218.  
  219. :QuitVD
  220. Cacls "%WorkPath%\VD" /T /e /p Todos:f>nul 2>&1
  221. RD /s /q "%WorkPath%\VD" >nul 2>&1
  222. Reg Delete "%R_Key%" /f
  223. Echo. Virtual Drive Deleted
  224. Pause
  225. Exit
  226.  
  227. :Key
  228. If not defined %1 Goto :Eof
  229. Set "cf="
  230. Set "d=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz =/\()[]{}_-.:,;* @#"
  231. :Key.b
  232. Set "c=!%1:~,1!"
  233. For /l %%l in (0 1 80) do if "!c!" equ "!d:~%%l,1!" (
  234. set /a "x=%%l^5"
  235. call set "cf=!cf!%%d:~!x!,1%%"
  236. )
  237. Set "%1=!%1:~1!"
  238. If defined %1 Goto :Key.b
  239. Set "%1=!cf!"
  240. Goto :Eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement