Code: Select all
RunAs, %ComSpec% /c ""diskpart /s" "C:\path_to\folder name with spaces\commands.txt" > "C:\path_to\folder name with spaces\output.txt""
Code: Select all
list disk
exit
What am I doing wrong?
Code: Select all
RunAs, %ComSpec% /c ""diskpart /s" "C:\path_to\folder name with spaces\commands.txt" > "C:\path_to\folder name with spaces\output.txt""
Code: Select all
list disk
exit
Code: Select all
MsgBox, % getWmic("DiskDrive", "Name")
getWmic(section, property) {
For objItem in ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_" section)
wtext .= Trim(objItem[property]) "`n"
Return Trim(wtext, "`n")
}
Code: Select all
For objItem in ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_DiskDrive") {
wtext .= Trim(objItem["Name"]) "`n"
wtext .= Trim(objItem["Size"]) "`n"
wtext .= Trim(objItem["Status"]) "`n`n"
}
MsgBox, % Trim(wtext, "`n")
Code: Select all
fieldList = Name|Size (GB)|Status|Partitions|SerialNumber
Gui, Font, s10
Gui, Add, ListView, w600, %fieldList%
For oItem in ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_DiskDrive") {
; https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-diskdrive
field := []
For each, item in StrSplit(fieldList, "|") {
If (item = "Size (GB)")
val := Round(oItem["Size"] / 1024 ** 3)
Else val := oItem[item]
field.Push(val)
}
LV_Add("", field*)
}
LV_ModifyCol(1, 200)
LV_ModifyCol(2, "80 Center")
LV_ModifyCol(3, "50 Center")
LV_ModifyCol(4, "80 Center")
LV_ModifyCol(5, 200)
Gui, Show,, Drives
Code: Select all
If !A_IsAdmin && !((cLine := DllCall("GetCommandLine", "str")) ~= " /restart(?!\S)") {
params := RegExReplace(cLine, ".+\.exe.*? ")
Try Run *RunAs "%A_AhkPath%" /restart %params%
ExitApp
}
dir = %A_ScriptDir%
out = %dir%\output.txt
RunWait, %ComSpec% /c DISKPART /s "%dir%\commands.txt" > "%out%",, Hide
Run, %out%