
윈 도 우 DISM_Onekey_BR_Maker.ahk
2020.12.24 08:14
마눌사장님의 컴철수 명령이 떨어져.....
소스 공개로 일단락 짓겠습니다(v 9.2)
오토핫키 잘 다루시는 분들이 완전체로 만들어주세요.
(제 컴에선 몇번을 제거 설치해도 잘됩니다)
1. 구글드라이브에 공유한 원본파일에
2. DISM_Onekey_BR배포용9.zip에 들어있는 배치파일 2개 교체
3. 아래 소스로 만든 파일을 실행파일로 교체하셔야 합니다.
저도 보완하여 공유하도록 하겠습니다.
그리고 오토핫키 설치하시면 얻는 것이 많을겁니다. 컴파일 않아도 되고...
DISM_Onekey_BR_Maker.ahk(UTF8로 저장하시고 실행하시면 백신 걱정없습니다.)
;-------------------------------------------------------------------------------------------------------------------------
#SingleInstance Force
#NoTrayIcon
SetWorkingDir %A_ScriptDir%
if not A_IsAdmin
{
Run *RunAs "%A_ScriptFullPath%"
ExitApp
}
UorB = % IsUEFIorBIOS()
FileDelete,%A_Temp%\DrvList.txt
DriveGet, DriveList, list
StringTrimLeft, DriveList, DriveList, 1
DriveGet, cdVar, List, CDROM
DriveList := trim(DriveList,cdVar)
Loop, Parse, DriveList
{
DriveGet, lbl, Label, %A_LoopField%:
DriveGet, fsys, FS, %A_LoopField%:
DriveGet, typ, Type, %A_LoopField%:
Sps := ""
DriveGet, Cap, Capacity, %A_LoopField%:
DriveSpaceFree, Free_Space, %A_LoopField%:
Sps =% Cap/1000
If (Free_Space > 1000)
{
Free_S =% Free_Space/1000
Unit = GB
StringTrimRight, Sps, Sps, 7
StringTrimRight, Free_S, Free_S, 7
}
Else
{
Unit = MB
}
FileAppend, %A_LoopField%: %Sps%%Unit%. .(%Free_S%%Unit%여유). .%typ% [%fsys%]. .%lbl%|, %A_Temp%\DrvList.txt
}
FileReadLine, DrvVar, %A_Temp%\DrvList.txt, 1
StringTrimRight, DrvVar, DrvVar, 1
For Prt in (ComObjGet("winmgmts:").ExecQuery("Select * FROM Win32_LogicalDiskToPartition"),DP:=[])
DP.Insert(RegExReplace(Prt.Antecedent " " Prt.Dependent,"^.*?""|"".*"))
For Prp in (ComObjGet("winmgmts:").ExecQuery("Select * FROM Win32_LogicalDisk"),DINF:=[],i:=1)
(f:=Prp.FileSystem) ? DINF.Insert(DP[i++] " " Prp.Name):
For i in (DINF,Disp:="")
Disp.=DINF[i] "`r`n"
DetectHiddenWindows On
Run %ComSpec%,, Hide, pid
WinWait ahk_pid %pid%
DllCall("AttachConsole", "UInt", pid)
shell := ComObjCreate("WScript.Shell")
cmd := shell.Exec("cmd.exe /q /c diskpart")
cmd.StdIn.WriteLine("list disk`nexit")
result := isGpt(cmd.StdOut.ReadAll())
DllCall("FreeConsole")
Process Close, %pid%
HH := WMI_HDD_HEALTH()
HT := WMI_HDD_TEMP()
Gui, Add, GroupBox, x30 y5 w310 h206 ,
Gui, Add, GroupBox, x160 y13 w160 h188 ,
Gui, Add, GroupBox, x110 y333 w248 h30 ,
Gui, Add, Text, x111 y344 w246 vCopiedStatus,
Gui, Add, Text, x42 y24 w112 h20 , ▶〔 디스크 타입 〕:
Gui, Add, Text, x168 y24 w150 h175 , %result%`n%Disp%
Gui, Add, Text, x42 y64 w110 h20 , ▼〔 디스크 건강 〕
Gui, Add, Text, x42 y94 w110 h70 , ` ☞ %HH% `n`n ☞ %HT% °C
Gui, Add, Text, x40 y168 w112 h20 , ` ♣ %UorB% ♣
Gui, Add, Text, x16 y224 w335 h20 , 1.〔 설치 〕✔〔 PE 〕를 넣을 드라이브 선택 ✔
Gui, Add, DDL, gDirSelectBt vDirDrv Choose1 x19 y250 w346, %DrvVar%
Gui, Add, Button, x42 y280 w96 h20 gPChange, ▶ 파티션 수정
Gui, Add, Button, x170 y280 w100 h20 gOpenfolder, ✔드라이브 확인
Gui, Add, Text, x282 y284 w27 h20 , ☜
Gui, Add, Button, x307 y280 w50 h20 gDirCopyBt, 넣 기
Gui, Add, Text, x80 y314 w280 h20 , * 바탕화면 우메뉴에 등록까지 진행됩니다. ↑↑↑
Gui, Add, Text, x16 y374 w286 h20 , 2. 우메뉴에서〔원키_백업〕만 제거 . . . . . . . . ☞
Gui, Add, Button, x307 y370 w50 h20 gAfterBackupBt, 제 거
Gui, Add, Text, x16 y404 w284 h60 , 3.〔DISM_원키〕레지확인 . . . . . . . . . . . . . . ☞
Gui, Add, Button, x307 y400 w50 h20 gDetectDismBt, 확 인
Gui, Add, Text, x16 y434 w284 h60 , 4.〔DISM_원키〕제거. . . . . . . . . . . . . . . . . . ☞
Gui, Add, Button, x307 y430 w50 h20 gRemoveDismBt, 제 거
Gui, Add, Text, x16 y464 w284 h60 , 5. 백업 중〔비정상 종료〕했다면. . . . . . . . . . ☞
Gui, Add, Button, x307 y460 w50 h20 gCareBt, 치 유
Gui, Show, x450 y224 h512 w386, ` 〔 DISM_원키_복원 〕_ Maker
return
GuiClose:
FileDelete,dir.ini
ExitApp
PChange:
gui,submit,nohide
runwait Partitionwizard10.2.2.exe
WinWaitclose, MiniTool Partition Wizard Technician 10.2.2
reload
return
DirSelectBT:
gui,submit,nohide
StringLeft,DirSelect,DirDrv,1
IniWrite, %DirSelect%:, dir.ini, dir, dir
PDir = %DirSelect%:
Return
Openfolder:
gui,submit,nohide
IfExist, dir.ini
{
iniread, dir, dir.ini, dir, dir
IfExist, %dir%\Dism_Backup
run, %dir%\Dism_Backup
else
{
run, %dir%
}
return
}
GuiControl,, CopiedStatus, 먼저〔드라이브〕를 선택하세요. . . .
Sleep, 800
GuiControl,, CopiedStatus,
Sleep, 500
return
DirCopyBt:
gui,submit,nohide
IfNotExist, dir.ini
{
GuiControl,, CopiedStatus, 먼저〔드라이브〕를 선택하세요. . . .
Sleep, 1800
GuiControl,, CopiedStatus,
Sleep, 500
return
}
FileCreateDir, %PDir%\DISM_Backup
runwait nircmd shellcopy "DISM_PE\*.*" "%PDir%\DISM_Backup" yestoall noerrorui
Sleep, 500
GuiControl,, CopiedStatus, 〔필수파일〕복사 완료. . . .
Sleep, 800
GuiControl,, CopiedStatus,
Sleep, 500
FileAppend, , %A_WinDir%\Chk_C.wim
GuiControl,, CopiedStatus, 〔C:\ 체크파일〕 생성 완료. . . .
Sleep, 800
GuiControl,, CopiedStatus,
Sleep, 500
fileread, text_list, %PDir%\DISM_Backup\_.bat
RegExMatch(text_list, ".+?\v", oVar)
text_list := RegExReplace(text_list, ".+?\v", "", "", 1)
Sleep, 300
filedelete, %PDir%\DISM_Backup\_.bat
fileappend,
(
set b="_.bat"&set wim=%PDir%\DISM_Backup\boot.wim&set pdrv=%PDir%
), %PDir%\DISM_Backup\_.bat
fileappend, %text_list%, %PDir%\DISM_Backup\_.bat
Sleep, 500
RunWait, nircmd elevatecmd exec hide %PDir%\DISM_Backup\_.bat
Sleep, 1500
GuiControl,, CopiedStatus, 〔PE 부팅 등록〕완료. . . .
Sleep, 800
GuiControl,, CopiedStatus,
Sleep, 500
FileRead, DDD, %PDir%\DISM_Backup\guid.txt
{
if ErrorLevel = 1
{
GuiControl,, CopiedStatus, 〔우메뉴에 등록〕실패. . . .
Sleep, 1800
GuiControl,, CopiedStatus, 〔DISM 원키 BR〕설치 미완료. . . .
Sleep, 3000
GuiControl,, CopiedStatus,
Sleep, 500
return
}
RegWrite, REG_SZ, HKCR,DesktopBackground\shell\DISM_원키복원, Icon, shell32.dll,146
RegWrite, REG_SZ, HKCR,DesktopBackground\shell\DISM_원키복원, Position, Bottom
RegWrite, REG_SZ, HKCR,DesktopBackground\shell\DISM_원키복원, SubCommands,
RegWrite, REG_SZ, HKCR,DesktopBackground\shell\DISM_원키복원\shell\런원스_PE, Icon, shell32.dll,146
RegWrite, REG_SZ, HKCR,DesktopBackground\shell\DISM_원키복원\shell\런원스_PE\command, , mshta vbscript:Execute("With CreateObject(""WScript.Shell""):.Run ""nircmd execmd del """"%PDir%\DISM_Backup\Onekey_*.cmd"""""", 0, True:.Run ""bcdedit /bootsequence %DDD%"", 0, True:.Run ""nircmd wait 500"", 0, True:.Run ""shutdown.exe -r -t 0"", 0, True:End With:close")
RegWrite, REG_SZ, HKCR,DesktopBackground\shell\DISM_원키복원\shell\원키_백업, Icon, shell32.dll,146
RegWrite, REG_SZ, HKCR,DesktopBackground\shell\DISM_원키복원\shell\원키_백업\command, , mshta vbscript:Execute("With CreateObject(""WScript.Shell""):.Run ""nircmd execmd del """"%PDir%\DISM_Backup\Onekey_*.cmd"""""", 0, True:.Run ""nircmd shellcopy """"%PDir%\DISM_Backup\_Backup.cmd"""" """"%PDir%\DISM_Backup\Onekey_Backup.cmd"""" yestoall noerrorui"", 0, True:.Run ""bcdedit /bootsequence %DDD%"", 0, True:.Run ""nircmd wait 500"", 0, True:.Run ""shutdown.exe -r -t 0"", 0, True:End With:close")
RegWrite, REG_SZ, HKCR,DesktopBackground\shell\DISM_원키복원\shell\원키_복원, Icon, shell32.dll,146
RegWrite, REG_SZ, HKCR,DesktopBackground\shell\DISM_원키복원\shell\원키_복원\command, , mshta vbscript:Execute("With CreateObject(""WScript.Shell""):.Run ""nircmd execmd del """"%PDir%\DISM_Backup\Onekey_*.cmd"""""", 0, True:.Run ""nircmd shellcopy """"%PDir%\DISM_Backup\_Restore.cmd"""" """"%PDir%\DISM_Backup\Onekey_Restore.cmd"""" yestoall noerrorui"", 0, True:.Run ""bcdedit /bootsequence %DDD%"", 0, True:.Run ""nircmd wait 500"", 0, True:.Run ""shutdown.exe -r -t 0"", 0, True:End With:close")
GuiControl,, CopiedStatus, 〔우메뉴에 등록〕완료. . . .
Sleep, 800
GuiControl,, CopiedStatus, 〔DISM 원키복원〕설치 완료. . . .
Sleep, 3000
GuiControl,, CopiedStatus,
Sleep, 500
return
}
AfterBackupBt:
gui,submit,nohide
count=0
Loop, HKCR, DesktopBackground\shell\DISM_원키복원\shell\원키_백업, 1
count:=A_INDEX
if count=0
{
GuiControl,, CopiedStatus, 〔원키_백업〕레지 존재 안함. . . .
Sleep, 3000
GuiControl,, CopiedStatus,
Sleep, 500
}
else
{
RegDelete, HKCR,DesktopBackground\shell\DISM_원키복원\shell\원키_백업
GuiControl,, CopiedStatus, 우메뉴에서 〔원키_백업〕제거 완료. . . .
Sleep, 3000
GuiControl,, CopiedStatus,
Sleep, 500
}
return
DetectDismBt:
gui,submit,nohide
count=0
Loop, HKCR, DesktopBackground\shell\DISM_원키복원, 1
count:=A_INDEX
if count=0
{
GuiControl,, CopiedStatus, 〔DISM_원키복원〕레지 존재 안함. . . .
Sleep, 3000
GuiControl,, CopiedStatus,
Sleep, 500
}
else
{
Loop, HKCR, DesktopBackground\shell\DISM_원키복원\shell\원키_백업\command, 1, 1
{
if a_LoopRegType = key
value =
else
{
RegRead, value
if ErrorLevel <> 0
value = *error*
}
MsgBox, %a_LoopRegName% = %value% (%a_LoopRegType%)
}
GuiControl,, CopiedStatus, 〔DISM_원키백업〕레지 확인 . . . .
Sleep, 3000
GuiControl,, CopiedStatus,
Sleep, 500
}
return
RemoveDismBt:
gui,submit,nohide
DriveGet, DrivegList, list
Loop, Parse, DrivegList
{
IfExist, %A_LoopField%:\Dism_Backup
pedrv =%A_LoopField%:
}
IfExist, %pedrv%\DISM_Backup\guid.txt
{
msgbox, 4, 〔_DISM_원키_제거_〕, ` 〔DISM_원키〕를 제거합니다.!`n `n레지와 DISM_Backup폴더가 제거됩니다.`n `nBCD에서도 제거됩니다`n `n〔아니오〕 누르면 제거되지 않습니다.
IfMsgBox Yes
{
RegDelete, HKCR,DesktopBackground\shell\DISM_원키복원
GuiControl,, CopiedStatus, 〔DISM_원키복원〕레지 제거 완료. . . .
Sleep, 800
FileRead, OOD, %pedrv%\DISM_Backup\guid.txt
Runwait, %comspec% /c "bcdedit /delete "%OOD%" /f", , hide
GuiControl,, CopiedStatus, 〔PE〕BCD에서 제거 완료. . . .
Sleep, 800
FileRemoveDir, %pedrv%\DISM_Backup, 1
GuiControl,, CopiedStatus, 〔DISM_Backup〕폴더 삭제. . . .
Sleep, 800
GuiControl,, CopiedStatus, 〔DISM_원키복원〕제거 완료. . . .
Sleep, 3000
GuiControl,, CopiedStatus,
Sleep, 500
return
}
}
GuiControl,, CopiedStatus, 〔DISM_원키〕존재 안함. . . .
Sleep, 3000
GuiControl,, CopiedStatus,
Sleep, 500
return
CareBt:
gui,submit,nohide
DriveGet, DrivecList, list
Loop, Parse, DrivecList
{
IfExist, %A_LoopField%:\Dism_Backup
Cpedrv =%A_LoopField%:
}
IfExist, %Cpedrv%\DISM_Backup\windows*.wim
{
FileDelete,%Cpedrv%\DISM_Backup\windows*.wim
FileDelete,%Cpedrv%\DISM_Backup\Onkey_*.cmd
GuiControl,, CopiedStatus, 〔백업이미지〕삭제 완료. . . .
Sleep, 3000
GuiControl,, CopiedStatus,
Sleep, 500
return
}
GuiControl,, CopiedStatus, 〔백업이미지〕존재 안함. . . .
Sleep, 3000
GuiControl,, CopiedStatus,
Sleep, 500
return
WMI_HDD_HEALTH()
{
for objItem in ComObjGet("winmgmts:\\.\root\WMI").ExecQuery("SELECT * FROM MSStorageDriver_FailurePredictStatus")
return, % (objItem.PredictFailure = "0") ? "양호 ^^" : (objItem.PredictFailure = "1") ? "Critical" : "불량 ㅠㅠ"
}
WMI_HDD_TEMP()
{
for objItem in ComObjGet("winmgmts:\\.\root\WMI").ExecQuery("SELECT * FROM MSStorageDriver_ATAPISmartData")
{
loop, 361
{
i := A_Index - 1
if (objItem.VendorSpecific[i] = "194")
{
j := i + 5
return, % objItem.VendorSpecific[j]
}
}
}
}
IsUEFIorBIOS()
{
static DUMMY_GUID := "{00000000-0000-0000-0000-000000000000}"
static ERROR_INVALID_FUNCTION := 0x1
DllCall("GetFirmwareEnvironmentVariable", "str", "", "str", DUMMY_GUID, "ptr", 0, "uint", 0, "uint")
return (A_LastError = ERROR_INVALID_FUNCTION) ? "Legacy BIOS" : "UEFI Mode"
}
isGpt(string)
{
Loop, Parse, string, `n
{
if (A_index > 9)
{
Disk := SubStr(A_LoopField, 3, 6)
if (flag != "")
if (!InStr(Disk, "디스크"))
break
RegExReplace(A_LoopField, "\*","fgh",count)
if (count = 0)
flag := "MBR No-Dyn"
else if (count = 1)
flag := StrLen(RegExReplace(A_LoopField, "(.*)\*")) = 1 ? "Gpt No-Dyn" : "MBR Dyn"
else if (count = 2)
flag := "Gpt Dyn"
result .= Disk ", " flag "`n"
}
}
return result
}
댓글 [18]
-
engineer 2020.12.24 08:34
-
오늘을사는자 2020.12.24 08:46
수고 많으십니다. 보통 이렇게 공개적으로 소스 전체를 배포하는 경우는 예전에도 없었던 것 같습니다.
윈포 회원님들의 발전을 위해 통 크게 배포해 주시니 감사의 말씀을 드립니다.
청락님의 윈포 소스를 이용 하실 분들은 이름을 고쳐서 자기 것 인양 타사이트에 배포하는 행위 만큼은 자중해 주시기 바라며
매번 윈포를 위해 노력해 주시는 많은 분들에게도 고마움을 매번 느낍니다. 좋은 연말 되시기 바랍니다.
-
샤 2020.12.24 09:12
수고하셨습니다.
-
까칠한곰탱이 2020.12.24 09:17
수고하셨습니다~~~ ^^
-
zero70 2020.12.24 10:05
수고 하셨습니다. ^^
-
cungice 2020.12.24 10:27
고생 많으셨습니다.감사합니다.
-
조임삼33 2020.12.24 10:38
수고하셨습니다. 감사합니다.
-
pp빵빵 2020.12.24 11:30
수고하셨습니다
-
Whyrano... 2020.12.24 11:48
고생하셨습니다...
응원합니다...
-
재먼당 2020.12.24 11:52
수고 하셨습니다.^U^
-
고프로 2020.12.24 12:11
고생 많으셨습니다.감사합니다.
-
FriendY 2020.12.24 12:29
식당일하시랴, 프로그램 연구하시랴 수고 많으셨습니다. ~
마음만이라도 행복 가득한 크리스마스, 연말 보내시기 바랍니다. ^^
-
b_l_a_n_k 2020.12.24 14:40
즐거운 크리스마스 되세요.
-
고감맨 2020.12.24 16:47
감사합니다.
Merry Christmas
-
라인 2020.12.24 18:10
많은 수고에 진심으로 감사 드립니다
닦아오는 연말 신년에도 좋은 일만 있으시길...
-
elios 2020.12.24 19:49
메리x마스 감사합니다
건강하세요
-
붉바리 2020.12.26 17:13
감사합니다.
-
슈머슈마 2020.12.29 22:49
감사드립니다. 복많이 받으세요
번호 | 제목 | 글쓴이 | 조회 | 추천 | 등록일 |
---|---|---|---|---|---|
[공지] | 강좌 작성간 참고해주세요 | gooddew | - | - | - |
3890 | 소프트웨어| snapshot snaPlug-in 도구 [8] | sunshine | 1206 | 19 | 12-25 |
3889 | 소프트웨어| Ventoy 대용량 usb/외장하드 부팅 문제 해결 [17] | suk | 1607 | 21 | 12-25 |
3888 | 기 타| [2020년 12월23일] 22가지-기간 한정 새로운 무료 udemy 과정 [1] | VₑₙᵤₛG | 1574 | 3 | 12-24 |
» | 윈 도 우| DISM_Onekey_BR_Maker.ahk [18] | 청락 | 1406 | 15 | 12-24 |
3886 | 윈 도 우| Hex 비교 및 수정 스크립트 V1.60 (bincmp) [3] | 히이이잌 | 505 | 8 | 12-24 |
3885 | 윈 도 우| PE 설치 스크립트 V7.30 [10] | 히이이잌 | 1214 | 17 | 12-22 |
3884 | 소프트웨어| snapshot 대화상자 지역화 배치파일2[수정3] [13] | sunshine | 663 | 17 | 12-22 |
3883 | 윈 도 우| PE 업데이트 스크립트 V1.22 [12] | 히이이잌 | 1082 | 23 | 12-20 |
3882 | 윈 도 우| PE 수정 스크립트 V3.85 [12] | 히이이잌 | 773 | 19 | 12-20 |
3881 | 윈 도 우| 윈도우10 ISO 파일 지원 [4] | 번개 | 1949 | 2 | 12-20 |
3880 | 소프트웨어| snapshot 대화상자 지역화 배치파일 [20] | sunshine | 782 | 19 | 12-19 |
3879 | 기 타| 2021년부터 바뀌는 전기 관련 시행규칙(전압, 전선 색) [8] | asklee | 2240 | 7 | 12-17 |
3878 | 윈 도 우| 명령어로 윈도우 모니터 '진짜로' 끄기 [11] | 만수무강 | 2018 | 11 | 12-17 |
3877 | 윈 도 우| winver.exe 없이 윈도우 버전보기 [6] | 네트워크빌 | 2098 | 12 | 12-13 |
3876 | 윈 도 우| PC모델명 인식 뒤 드라이버 자동설치 [15] | Greinke | 2842 | 14 | 12-10 |
3875 | 기 타| 유튜브 볼륨 컨트롤을 마우스로 편하게 (업데이트) [7] | 오호라7 | 1965 | 7 | 12-07 |
3874 | 기 타| 자신의 음악성향에 맞게 EQ(이퀼라이저) 설정하기 [10] | UCLA | 2906 | 17 | 12-02 |
3873 | 윈 도 우| 기본 앱 브라우저 자동으로변경 [3] | Greinke | 2039 | 4 | 12-02 |
3872 | 윈 도 우| 바탕화면에 여러 창으로 가득차 있을때 막 흔들어 주세요 !!! [19] | 하늘소 | 2500 | 9 | 12-01 |
3871 | 윈 도 우| 한글 윈도우에서의 Cortana의 흔적 [3] | 레덕후 | 1975 | 0 | 11-30 |
항상 감사드립니다. 수고하셨습니다.