Board logo

标题: [转贴] 右键-新建-VBS文件 [打印本页]

作者: broly    时间: 2010-12-12 13:23     标题: 右键-新建-VBS文件

创建:
  1. filetype=".vbs"
  2. Set wshshell=CreateObject("wscript.shell")
  3. prg=readreg("HKCR\"&filetype&"\")
  4. prgname=readreg("HKCR\"&prg&"\")
  5. ask="新的vbs文件名"
  6. title="创建新的vbs脚本"
  7. prgname=InputBox(ask,title,prgname)
  8. wshshell.RegWrite "HKCR\"&prg&"\",prgname
  9. wshshell.RegWrite "HKCR\"&filetype&"\shellnew\nullfile",""
  10. Function readreg(key)
  11. On Error Resume Next
  12. readreg=wshshell.RegRead(key)
  13. If Err.Number>0 Then
  14. Error="error:注册表键值"""&key_&"""不能找到!"
  15. MsgBox Error,vbCritical
  16. WScript.Quit
  17. End If
  18. End Function
复制代码
删除:
  1. Set wshshell=CreateObject("wscript.shell")
  2. filetype=".vbs"
  3. wshshell.RegDelete "HKCR\"&filetype&"\shellnew\"
  4. MsgBox "command removed!"
复制代码
[ 本帖最后由 broly 于 2010-12-12 13:25 编辑 ]
作者: yhcbird    时间: 2011-1-3 16:23

建不起来啊!!!!!!
作者: broly    时间: 2011-1-3 22:01     标题: 回复 2楼 的帖子

你怎么建的?
后缀名字是VBS,不是BAT
作者: guaiwu    时间: 2011-1-4 09:24

拜托、、  我弄了也不行啊
作者: dahual    时间: 2011-2-7 15:58

分享快乐!修正了下,这下可以了。
  1. 'ReadRegVal
  2. Function ReadRegVal(Key)
  3. On Error Resume Next
  4. Set wshShell=CreateObject("WScript.Shell")
  5. ReadRegVal=wshShell.RegRead(Key)
  6. Set wshShell=Nothing
  7. If Err.Number<>0 Then
  8. MsgBox "描述:注册表键(值) """ & Key & """ 未找到!",vbCritical,"Error"
  9. WScript.Quit
  10. End If
  11. End Function
  12. 'AddShellNew
  13. Sub AddShellNew(ExtensionName)
  14. Set wshShell=CreateObject("WScript.Shell")
  15. Link=ReadRegVal("HKCR\"& ExtensionName & "\")
  16. Description=ReadRegVal("HKCR\" & Link &"\")
  17. NewDescription=InputBox("新建文件描述:","设置",Description)
  18. If NewDescription<>"" Then
  19. wshShell.RegWrite "HKCR\" & Link &"\",NewDescription
  20. End If
  21. wshShell.RegWrite "HKCR\" & ExtensionName & "\ShellNew\NullFile",""
  22. Set wshShell=Nothing
  23. End Sub
  24. 'RemoveShellNew
  25. Sub RemoveShellNew(ExtensionName)
  26. Set wshShell=CreateObject("WScript.Shell")
  27. wshShell.RegDelete "HKCR\" & ExtensionName & "\ShellNew\"
  28. Set wshShell=Nothing
  29. End Sub
  30. '''''''
  31. Call AddShellNew(".vbs")
  32. 'Call RemoveShellNew(".vbs")
复制代码

作者: huangbaoliang    时间: 2011-2-24 20:11

非常的不错的啊,支撑架
作者: zhangop9    时间: 2021-1-2 18:44

右键-新建-VBS文件
作者: segree    时间: 2022-6-7 15:59

牛批牛批,这个要得要得~~!!
作者: LJY4.0    时间: 2022-7-30 21:02

这个很好,感觉很好用




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2