Search code examples
cygwinwmic

Cygwin + WMIC Pagefile Setup


I've been trying to modify the pagefile size on a drive using CYGWIN as the majority or our servers only have access to cygwin and not straight CMD.

Here's an overview of my trials, note that the last command is successful but I cannot run it as it requires to first type 'cmd' then the command interactively and cannot be done via script (as far as I could get):

Administrator@dock ~
$ wmic pagefileset where name='d:\\pagefile.sys' set InitialSize=10000,MaximumSize=20000
ERROR:
Description = Invalid query

Administrator@dock ~
$ cmd /c "wmic pagefileset where name='d:\\pagefile.sys' set InitialSize=10000,MaximumSize=20000"
ERROR:
Description = Invalid query

Administrator@dock ~
$ powershell -c "wmic pagefileset where name='d:\\pagefile.sys' set InitialSize=10000,MaximumSize=20000"
Invalid format.
Hint: <assignlist> = <propertyname>=<propertyvalue> [, <assignlist>].

Administrator@dock ~
$ cmd
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\cygwin\home\Administrator>wmic pagefileset where name='d:\\pagefile.sys' set                                               InitialSize=10000,MaximumSize=20000
wmic pagefileset where name='d:\\pagefile.sys' set InitialSize=10000,MaximumSize                                                 =20000

Updating property(s) of '\\DOCK\ROOT\CIMV2:Win32_PageFileSetting.Name="D:\\pagef                                               ile.sys"'
Property(s) update successful.

Any suggestions on how I could run this command via CYGWIN and not get an 'Invalid Query'?


Solution

  • This was resolved by creating a .bat file and calling it from the .sh file which allowed for Pagefile updating.