找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 29964|回复: 10

[转贴] 右键-新建-VBS文件

[复制链接]
发表于 2010-12-12 13:23:42 | 显示全部楼层 |阅读模式
创建:
  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 编辑 ]
发表于 2011-1-3 16:23:27 | 显示全部楼层
建不起来啊!!!!!!
 楼主| 发表于 2011-1-3 22:01:10 | 显示全部楼层

回复 2楼 的帖子

你怎么建的?
后缀名字是VBS,不是BAT
发表于 2011-1-4 09:24:33 | 显示全部楼层
拜托、、  我弄了也不行啊
发表于 2011-2-7 15:58:59 | 显示全部楼层
分享快乐!修正了下,这下可以了。
  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")
复制代码
发表于 2011-2-24 20:11:29 | 显示全部楼层
非常的不错的啊,支撑架
发表于 2021-1-2 18:44:10 | 显示全部楼层
右键-新建-VBS文件
发表于 2022-6-7 15:59:40 | 显示全部楼层
牛批牛批,这个要得要得~~!!
发表于 2022-7-30 21:02:55 | 显示全部楼层
这个很好,感觉很好用
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 01:45 , Processed in 0.018767 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表