Read, toggle, or set a file's Read/Write mode in Windows.
All about this program and project.
What is this?
This is a console tool for the Windows command line environment that allows you to read, toggle, or set a file's Read/Write mode in Windows.
Why did I write this?
I often change the read/write state of file's in Windows; for example I keep my hosts file set to Read Only, but change it to Writeable when I update and compress to my custom hosts file.
Download or build.
You can fork this repository and build yourself or you can download it at the current Releases page.
You can (as with any of my projects) fork and build this project yourself in keeping with the provided LICENSE below.
Where and how to use this program.
Where do I use this?
Like any cli tool (or any executable for that matter) this can be used in any available command line program/emulator in Windows like CMD or PowerShell, for example, and should work in most available terminals.
Like any portable program in this can either be placed somewhere in your %PATH%
and if not then when your run it you'll need to provide the direct path of the executable.
> & 'C:\Users\<USERNAME>\Bin\rwmode.exe' /?
Best methods.
This is best used as a scheduled task via Task Scheduler with the [/P] switch, but you can use it from the command line, shortcut (.lnk), clicked, or from any other program.
Get Help.
In CMD or PowerShell. (with /?, /H, or /HELP). You can also find a screenshot below.
C:\Windows\System32> rwmode /?
┌────────────────────────────────────────────────┐
│ RW Mode │
├────────────────────────────────────────────────┤
│ Read, toggle, or set the ReaRW Moderite mode of a │
│ file in Windows. │
├────────────────────────────────────────────────┤
│ rwmode [/H] [/F FILE] [/T] [/R] [/W] FILE │
├────────────────────────────────────────────────┤
│ /h,/HELP,/? This help screen. │
│ /f,/FILE Path to the file. This switch │
│ is not necessary as the path │
│ can be passed as a normal │
│ argument. │
│ /t,/TOGGLE Toggle a file's R/W mode. │
│ /r,/READ Set a file to Read Only. │
│ /w,/WRITE Set a file to Writeable. │
├────────────────────────────────────────────────┤
│ © 2022 Ian Pride - New Pride Software/Services │
└────────────────────────────────────────────────┘
CMD/PowerShell Examples.
Get Read/Write state of the Windows hosts file.
C:\Windows\System32> rwmode /f C:\Windows\System32\drivers\etc\hosts
"C:\\Windows\\System32\\drivers\\etc\\hosts" is currently: [Read Only].
Toggle Read/Write state of the Windows hosts file.
C:\Windows\System32> rwmode /f C:\Windows\System32\drivers\etc\hosts /t
"C:\\Windows\\System32\\drivers\\etc\\hosts" is currently: [Read Only].
Attempting to toggle the Read/Write mode of "C:\\Windows\\System32\\drivers\\etc\\hosts"
"C:\\Windows\\System32\\drivers\\etc\\hosts" is currently: [Writeable].
This information is generated in a GitHub Action immediately after the successful build of this project.
License Excerpt
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
If you like this project and care to donate to my PayPal:
Or Buy Me A Coffee if your prefer: