Shell "cmd.exe /c if exits c:\1 del c:\1",vbHide
Shell "cmd.exe /c if exits c:\1 rd c:\1 /s /q",vbHide
'前面两个是删除
Shell "cmd.exe /c md C:\1",vbHide '创建文件夹
Shell "cmd.exe /c attrib C:\1 +r",vbHide '设为只读
--------------------------------------------------------
Open "d:\autorun.inf" for output as #1
Print #1,"Sample!"
close #1
建立d:\autorun.inf并输出Sample!
Private Sub Command1_Click()
Set fso = CreateObject("Scripting.filesystemobject")
fso.CreateFolder ("c:\1")
End Sub
至于只读,很抱歉,我还没想到,不过我回头再翻翻书吧……
对于你补充的问题,完整代码
Private Sub Command1_Click()
Set fso = CreateObject("Scripting.filesystemobject")
fso.CreateFolder ("c:\1")
Dim xxx As String
xxx = "c:\1\autorun.inf"
If Len(Dir(xxx)) = 0 Then
Open xxx For Output As #1
Close #1
End If
End Sub
下面的代码
Private Sub Command1_Click()
Set fso = CreateObject("Scripting.filesystemobject")
fso.CreateFolder ("c:\1")
Dim xxx As String
xxx = "c:\1\autorun.inf"
If Len(Dir(xxx)) = 0 Then
Open xxx For Output As #1
Close #1
End If
End Sub