Skip to content

Instantly share code, notes, and snippets.

@aimerneige
Created August 29, 2022 18:33
Show Gist options
  • Select an option

  • Save aimerneige/cb738f6da37db86c247db7fda12deb15 to your computer and use it in GitHub Desktop.

Select an option

Save aimerneige/cb738f6da37db86c247db7fda12deb15 to your computer and use it in GitHub Desktop.
ramdisk
if (Get-ScheduledTask -TaskName "RamDisk" -ErrorAction SilentlyContinue) {
Write-Host "Ramdisk Task schduler already configured." -ForegroundColor Green
} else {
Write-Host "Configuring task scheduler to start Ramdisk in the background..." -ForegroundColor Green
Set-Content -Path "$env:APPDATA\ramdisk.cmd" -Value "`"C:\Program Files\OSFMount\osfmount.com`" -a -t vm -o format:ntfs:`"RAM Volume`" -o physical -o gpt -s 4G"
$taskAction = New-ScheduledTaskAction -Execute "$env:APPDATA\ramdisk.cmd"
$trigger = New-ScheduledTaskTrigger -AtLogOn
$principal = New-ScheduledTaskPrincipal -RunLevel Highest -UserId (Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -expand UserName)
$settings = New-ScheduledTaskSettingsSet –AllowStartIfOnBatteries –DontStopIfGoingOnBatteries -Hidden -ExecutionTimeLimit (New-TimeSpan -Minutes 5) -RestartCount 3
Register-ScheduledTask -Action $taskAction -Trigger $trigger -TaskName "RamDisk" -Description "Start ramdisk in the background." -Settings $settings -Principal $principal
}
@aimerneige
Copy link
Author

aimerneige commented Aug 29, 2022

This powershell script helps you to create a 4G ramdisk every time you start your computer.

Note

@Anduin2017
Copy link

Cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment