我也是第一次用图床,怕说不明白,就随便传了个地方,command该为wscript C:\create.vbs %2
[Visual Basic] 纯文本查看 复制代码 If Not WScript.Arguments.Named.Exists("elevate") Then
CreateObject("WScript.Shell").CurrentDirectory = WScript.Arguments(0)
'以管理员身份执行
'CreateObject("Shell.Application").ShellExecute WScript.FullName , """" & WScript.ScriptFullName & """ /elevate", "", "runas", 1
CreateObject("Shell.Application").ShellExecute WScript.FullName , """" & WScript.ScriptFullName & """ /elevate", "", "open", 1
main
End If
function main()
name = "新建文本文件":
'如果你希望新建文件的时候询问文件名的话 取消下一行注释
'name = InputBox("请输入的名称","新建文本文件")
Set fso = CreateObject("Scripting.FileSystemObject")
Dim ext:ext = "txt"
Dim re:Set re = New RegExp
re.Pattern = "(\d+)"
re.Global = True
Set folder = fso.GetFolder(".")
max = 0
For Each file In folder.Files
basename = fso.GetBaseName(file)
If fso.GetExtensionName(file) = ext And InStr(basename,name) > 0 Then
Set Matches = re.Execute(basename)
For Each match In matches
id = match.submatches.item(0)
If Len(id) > 0 Then
id = CInt(id)
If id > max Then
max = id
End If
End If
Next
End If
Next
max = max + 1
If fso.FileExists(name & "." & ext) Then
fso.OpenTextFile name & max & "." & ext,1,True
Else
fso.OpenTextFile name & "." & ext,1,True
End If
Set fso = Nothing
end function |