hidefile.wsf

来自「Apress - Managing Enterprise Systems Wit」· WSF 代码 · 共 39 行

WSF
39
字号
<job>
<runtime>
<description>
The hidefile.wsf filename script sets the hidden attribute
for a specified file
</description>
<named 
      name="FileName"
      helpstring="Name of file to hide."
      type="string"
      required="True"
/>
<example>
This is an example of how to use this script:
 Hidefile.wsf Filename:data.doc
</example>
</runtime>
<script language="VBScript">
If Not WScript.Arguments.Named.Exists("FileName") Then
  WScript.Arguments.ShowUsage
  WScript.Quit
 End If

Set objFileSystem = CreateObject("Scripting.FileSystemObject")
 On Error Resume Next
 'get the file specified in command line 

 strFile = WScript.Arguments.Named("FileName")
 Set objFile = objFileSystem.GetFile(strFile)
 'check if error occured - file not found
 If Err Then 
     WScript.Echo "File:'" & strFile & "' not found"
 Else
     objFile.Attributes = 2
 End If
 
</script>
</job>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?