Vbs With File Attributes

最近没有在写vbs的代码,小试牛刀

 

Option Explicit

Dim args, arg

Set args = WScript.Arguments

For Each arg In args

ChangeFileAttributes(arg)
Next

Sub ChangeFileAttributes(file)

Dim hfile, finalResult
Dim fso
Set fso = WScript.CreateObject("Scripting.Filesystemobject")

Set hfile = fso.GetFile(file)

finalResult = 0

If vbYes = MsgBox("需要添加只读属性吗?",vbYesNo+vbInformation,"Prompt") Then

finalResult = finalResult + 1

End If

If vbYes = MsgBox("需要添加隐藏属性吗?",vbYesNo+vbInformation,"Prompt") Then

finalResult = finalResult + 2

End If

If vbYes = MsgBox("需要添加系统属性吗?",vbYesNo+vbInformation,"Prompt") Then

finalResult = finalResult + 4

End If

hfile.attributes = finalResult


End Sub

 

posted @ 2013-10-17 13:02  SemiCoder  阅读(205)  评论(0)    收藏  举报