Hallo,
ich komm nicht dahinter wie ich das machen soll.
Ich habe das Programm SetPageFileGUI genommen und angepasst um die Auslagerungsdatei von Windows schneller ändern zu können.
Hierbei müssen allerdings zwei Voraussetzungen erfüllt sein bevor es funktionieren kann.
Zum einen muss ein Laufwerk ausgewählt sein.
Zweitens muss der Maximalwert größer oder gleich dem Minimalwert sein.
Kann mir jemand helfen?
Spoiler anzeigen
Code
#include <GuiConstants.au3>
#NoTrayIcon
HotKeySet("{ESC}","gotoExit")
AutoItSetOption("RunErrorsFatal",0)
Opt("GuiOnEventMode",1)
Opt("GUICoordMode",1)
Global $FS=9 ;;Font size 9
Global $B=800 ;;Bold Text
;;Get System memory info
Global $memget=MemGetStats()
;;Get System RAM & round it down to more human friendly format
Global $SysRam=Round($memget[1]/1024)
Global $Pagefile=Round($memget[3]/1024-$SysRam)
;;Get fixed drives
Global $drives=DriveGetDrive("FIXED")
If IsAdmin() = 0 Then
MsgBox(0, "Keine Administrator-Rechte", "Melden Sie sich als Administrator an")
;Exit
EndIf
If IsAdmin() = 1 Then
EndIf
$title="Ändere Arbeitsspeicher"
$GUIHandle=WinGetHandle("Ändere Arbeitsspeicher")
;;set the GUI-height depending on the fixed-drives found
$height=($drives[0]*20)+240
if $height<210 then $height=210
;;check for the longest drive-name and the biggest drive-space to set the GUI-width
dim $name[$drives[0]+1]
dim $space[$drives[0]+1]
$maxname=0
$maxspace=0
for $i=1 to $drives[0]
$name[$i]=StringLen(DriveGetLabel($drives[$i]))
if $name[$i]>=$maxname then
$maxname=$name[$i]
endif
$space[$i]=StringLen(Round(DriveSpaceFree($drives[$i])))
if $space[$i]>=$maxspace then
$maxspace=$space[$i]
endif
next
$width=($maxname+$maxspace)*8+150
if $width<210 then $width=210
GuiCreate($title,$width,$height,0,0,$WS_CAPTION) ;;create window, you can change the 0, 0 part to orientate the window on screen
;;I set it to be top left, so those who may not start with 1024x768 will see it without hiding the XPE progress which setting
;;center will do
GUISetFont($FS,400) ;;Set general window font
$progressbar1=GuiCtrlCreateProgress(10,30,$width-20,20,$PBS_SMOOTH)
$Label_1=GuiCtrlCreateLabel("Status:",10,10,40,15)
$Label_2=GuiCtrlCreateLabel("fertig",50,10,140,15)
$Label_3=GuiCtrlCreateLabel("Laufwerke auswählen:",10,60,150,15)
$Label_4=GuiCtrlCreateLabel("freier Platz",$width-88,60,75,15,0x2)
$Label_5=GuiCtrlCreateLabel("Minimale Größe:",10,$height-100,100,15)
$Label_6=GuiCtrlCreateLabel("MB",$width-30,$height-100,15,15)
$Label_7=GuiCtrlCreateLabel("Maximale Größe:",10,$height-70,100,15)
$Label_8=GuiCtrlCreateLabel("MB",$width-30,$height-70,15,15)
$Combo_6=GuiCtrlCreateCombo("",$width-95,$height-100,60,20)
GUICtrlSetData($Combo_6,"512|768|1024|2048|3072","1024") ;;Pagefile sizes - feel free to add/remove your own values
;; The ,"512" part sets the default value displayed, feel free to change this too
GUICtrlSetFont($Combo_6,$FS,$B)
$Combo_7=GuiCtrlCreateCombo("",$width-95,$height-70,60,20)
GUICtrlSetData($Combo_7,"512|768|1024|2048|3072","1024") ;;Pagefile sizes - feel free to add/remove your own values
;; The ,"512" part sets the default value displayed, feel free to change this too
GUICtrlSetFont($Combo_7,$FS,$B)
GuiSetState()
$s=0
;; Just a simple progress bar control to show scanning of fixed drives
$msg=GUIGetMsg()
For $i=$s To 100 step 1
$s = 0
GUICtrlSetData($progressbar1,$i) ;;update the progress bar
GUICtrlSetData ($Label_2,"Suche Laufwerke") ;;Show message in status area while scanning
Next
;;check that at least one fixed drive is found, if not (that would be weird), display message in status area and then exit
For $i=1 to $drives[0]
If $i=0 Then
GUICtrlSetData($Label_2,"keine Laufwerke gefunden")
Sleep(2000)
MsgBox(16,"Keine Laufwerke gefunden!","Es kann kein Pagefile erstellt werden." & @CR & "Die Anwendung wird jetzt beendet.",20000)
Exit
Else
If $i=NOT 0 Then
GUICtrlSetData($Label_2,"Laufwerke gefunden") ;;report drives found
EndIf
EndIf
Next
;;this took me ages to figure out, checkboxes and arrays are not fun
;;the long $chkboxes[$i]= line had me pulling my hair out for a good hour getting
;;the syntax right, but well worth it in the end!
dim $chkboxes[$drives[0]+ 1]
$chkboxes[0]=$drives[0]
$Ypos=80
for $i=1 to $drives[0]
$chkboxes[$i]=GUICtrlCreateRadio(StringUpper($drives[$i] & " (" & DriveGetLabel($drives[$i]) & ")"),10,$Ypos,($maxname+5)*8,20)
GuiCtrlSetState(-1,$GUI_UNCHECKED)
$Ypos=$Ypos+20
next
$Ypos=80
for $i=1 to $drives[0]
$FreeMem=GuiCtrlCreateLabel(Round(DriveSpaceFree($drives[$i])) & " MB",$width-88,$Ypos,75,15,0x2)
GuiCtrlSetFont($FreeMem,$FS,$B)
$Ypos=$Ypos+20
next
$Aktuell = RegRead("HKLM\SYSTEM\ControlSet001\Control\Session Manager\Memory Management", "PagingFiles")
$Auslagerung_1=GuiCtrlCreateLabel("Aktuell:",10,$height-145,85,15)
$Auslagerung_2=GuiCtrlCreateLabel($Aktuell & " MB",$width-162,$height-145,150,15,0x2)
GUICtrlSetFont($Auslagerung_2,$FS,$B)
$SysRam_1=GuiCtrlCreateLabel("System-RAM:",10,$height-125,85,15)
$SysRam_2=GuiCtrlCreateLabel($SysRam & " MB",$width-88,$height-125,75,15,0x2)
GUICtrlSetFont($SysRam_2,$FS,$B)
$Button_GO=GuiCtrlCreateButton("OK",10,$height-35,80,25)
GUICtrlSetOnEvent(-1,"Pruefen")
$Button_EXIT=GuiCtrlCreateButton("Abbrechen",$width-90,$height-35,80,25)
GUICtrlSetOnEvent(-1,"gotoExit")
While 1
$msg=GUIGetMsg()
WEnd
Exit
Func Pruefen()
If GUICtrlRead($chkboxes) = $GUI_UNCHECKED Then
MsgBox(16, "Fehler", "Bitte Laufwerk auswählen")
If GUICtrlRead($Combo_6) > GUICtrlRead($Combo_7) Then
MsgBox(16, "Fehler", "Maximal-Wert kleiner als Minimal-Wert")
Else
EndIf
EndIf
EndFunc
;;finally the main function!
;check which checkbox(es) are checked and set a pagefile on it/them
Func SetPage()
For $i=1 to $chkboxes[0]
If GUICtrlRead($chkboxes[$i])=$GUI_CHECKED Then
GUICtrlSetData($Label_2,"Erstelle Pagefile auf " & StringUpper($drives[$i]))
RegWrite("HKLM\SYSTEM\ControlSet001\Control\Session Manager\Memory Management", "PagingFiles", "REG_MULTI_SZ", $drives[$i] & "\pagefile.sys" & " " & GUICtrlRead($Combo_6) & " " & GUICtrlRead($Combo_7))
RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management", "PagingFiles", "REG_MULTI_SZ", $drives[$i] & "\pagefile.sys" & " " & GUICtrlRead($Combo_6) & " " & GUICtrlRead($Combo_7))
EndIf
Next
Exit
EndFunc
Func gotoExit()
Exit
EndFunc
Alles anzeigen