Use Windows VBS scripts to create your own file type!

zhaozj2021-02-16  117

Create a script ending at the end of VBS. Copy the following.

Then run the script, the firewall may prompt (because the write registry is involved) does not use.

Enter the name of the type of the file you want to create, run, after a while, right click, and there is this type back in the new creation.

FileType = ".vbs" This is the buffet name of the file.

'1-1.VBS' this is the file extension the new command 'should generate: filetype = ".vbs"' connect to WScript.Shell for registry access: set WSHShell = CreateObject ( "WScript.Shell") 'read in the Name of the vbs-section: prg = readreg ("HKCR /" & fileType & "/") 'Read in the official name for vbs-files: prgname = readreg ("HKCR /" & PRG & "/")' Ask for a new nameask = title = "New menu entry" prgname = InputBox (ask, title, prgname) 'save the new program description "What should be the name for new VBScript scripts?": WSHShell.RegWrite "HKCR /" & prg & "/", prgname 'Add a new menu entry ask for an empty new file: wshshell.regwrite "HKCR /" & fileType & "" "Reads a registry key" "" r b, complain and stop: function ReadReg (key) on error resume nextReadReg = WSHShell.RegRead (key) if err.Number> 0 then 'key could not be read: complain error =! "error: Registry-Key" "" & key _ & "" "Could Not Be Found!" MsgBox Error, VbcriticalWScript.quites IFEND Function

转载请注明原文地址:https://www.9cbs.com/read-13415.html

New Post(0)