![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Adding a new PageFile on another drive than the system drive Hi, I have an issue in a script that i'm writing. Long story short my script will need to write a new pagefile on the E:\ drive at some point, but I can,t seem to get it through to the E:\ drive. I can only write to the C:\ drive pagefile settings so far. Here's a part of my code that works fine to have the C:\ drive pagefile modified : $ComputerName = get-content env:COMPUTERNAME $colItems = Get-WMIObject -Class "Win32_PageFileSetting" -namespace "root\cimv2" -computername $ComputerName ForEach ($objItem in $colItems) { $objItem.InitialSize = "5120" $objItem.MaximumSize = "5120" $objItem.Put() } I know that I can modify an existing pagefile on e:\ drive if it's already there within the $colitems variable, but I need to create a new one as it doesn't exist yet. Can someone help me out? Thanks! |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Adding a new PageFile on another drive than the system drive "qu0vad1s" wrote: Quote: > Hi, > > I have an issue in a script that i'm writing. Long story short my script > will need to write a new pagefile on the E:\ drive at some point, but I can,t > seem to get it through to the E:\ drive. I can only write to the C:\ drive > pagefile settings so far. > > Here's a part of my code that works fine to have the C:\ drive pagefile > modified : > > $ComputerName = get-content env:COMPUTERNAME > $colItems = Get-WMIObject -Class "Win32_PageFileSetting" -namespace > "root\cimv2" -computername $ComputerName > ForEach ($objItem in $colItems) { > $objItem.InitialSize = "5120" > $objItem.MaximumSize = "5120" > $objItem.Put() > } > > I know that I can modify an existing pagefile on e:\ drive if it's already > there within the $colitems variable, but I need to create a new one as it > doesn't exist yet. > > Can someone help me out? > Thanks! ($objItem.name) to "E:\Pagefile.sys" but it gives me the following error : Exception calling "Put" with "0" argument(s): "Exception calling "Put" with "0" argument(s): "Access denied "" Full modified code : $ComputerName = get-content env:COMPUTERNAME $colItems = Get-WMIObject -Class "Win32_PageFileSetting" -namespace "root\cimv2" -computername $ComputerName ForEach ($objItem in $colItems) { $objItem.InitialSize = "500" $objItem.MaximumSize = "600" $objItem.Name = "e:\pagefile.sys" $objItem.Put() } |
My System Specs![]() |
| | #3 (permalink) |
| | RE: Adding a new PageFile on another drive than the system drive "qu0vad1s" wrote: Quote: > > > "qu0vad1s" wrote: > Quote: > > Hi, > > > > I have an issue in a script that i'm writing. Long story short my script > > will need to write a new pagefile on the E:\ drive at some point, but I can,t > > seem to get it through to the E:\ drive. I can only write to the C:\ drive > > pagefile settings so far. > > > > Here's a part of my code that works fine to have the C:\ drive pagefile > > modified : > > > > $ComputerName = get-content env:COMPUTERNAME > > $colItems = Get-WMIObject -Class "Win32_PageFileSetting" -namespace > > "root\cimv2" -computername $ComputerName > > ForEach ($objItem in $colItems) { > > $objItem.InitialSize = "5120" > > $objItem.MaximumSize = "5120" > > $objItem.Put() > > } > > > > I know that I can modify an existing pagefile on e:\ drive if it's already > > there within the $colitems variable, but I need to create a new one as it > > doesn't exist yet. > > > > Can someone help me out? > > Thanks! > I forgot to mention that I've tried to modify it by setting the Name object > ($objItem.name) to "E:\Pagefile.sys" but it gives me the following error : > > Exception calling "Put" with "0" argument(s): "Exception calling "Put" with > "0" argument(s): "Access denied "" > > Full modified code : > > $ComputerName = get-content env:COMPUTERNAME > $colItems = Get-WMIObject -Class "Win32_PageFileSetting" -namespace > "root\cimv2" -computername $ComputerName > ForEach ($objItem in $colItems) { > $objItem.InitialSize = "500" > $objItem.MaximumSize = "600" > $objItem.Name = "e:\pagefile.sys" > $objItem.Put() > } > Code : $RegKey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" $KeyName = "PagingFiles" $CMin = "500" $CMax = "1000" $EMin = "600" $EMax = "1000" $Value = "C:\Pagefile.sys $Cmin $CMax","e:\pagefile.sys $EMin $EMax" set-ItemProperty -path $RegKey -name $keyName -value $Value |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Adding IDE Drive to New System with ATA / SATA Architecture | Vista hardware & devices | |||
| Drive partition and relocating pagefile | General Discussion | |||
| 232G Drive Full With Pagefile!!!! | Vista performance & maintenance | |||
| USB drive as pagefile drive | Vista performance & maintenance | |||
| Can I use a USB Drive as my pagefile? | Vista performance & maintenance | |||