Enable the read-only attribute of a file (VBScript)
This code can be found in
Chapter 8 of Windows XP Cookbook
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the VBScript code from this site.
' From the book "Windows XP Cookbook"
' ISBN: 0596007256
' ------ SCRIPT CONFIGURATION ------
strFile = "<FilePath>" ' e.g. d:\mysecretscript.vbs
boolReadOnly = True ' True = read-only, False = not read-only
' ------ END CONFIGURATION ---------
set objFSO = CreateObject("Scripting.FileSystemObject")
' Change this to GetFolder to hide/unhide a folder
set objFile = objFSO.GetFile(strFile)
if boolReadOnly = True then
if objFile.Attributes AND 1 then
WScript.Echo "File already read-only"
else
objFile.Attributes = objFile.Attributes + 1
WScript.Echo "File is now read-only"
end if
else
if objFile.Attributes AND 1 then
objFile.Attributes = objFile.Attributes - 1
WScript.Echo "File is not read-only"
else
WScript.Echo "File is already not read-only"
end if
end if
|
This code has been viewed 4175 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|