In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to achieve the Bat conversion bit VBS file VBS script", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to achieve the Bat conversion bit VBS file VBS script" this article.
The following code has been slightly modified, the original structure is that the script is executed synchronously with the released bat and the bat is deleted after the bat execution is completed, which is meant to leave no temporary files behind. Later, I think that the versatility is not good, for example, if the bat file for release execution is a monitoring type of resident process, then VBS will wait endlessly and cannot exit, so it will be executed asynchronously instead, and the script will exit by itself after calling bat. Taking into account the restoration of the integrity of the original file at the end of the addition of self-deletion also gives up the idea. The package has not been updated yet.
The code is as follows:
'bat2vbs.vbs by baomaboy Dim WshSHell,FSO On Error Resume Next Set WshSHell = WScript.CreateObject ("WScript.Shell") Set FSO = CreateObject ("Scripting.FileSystemObject") Set WinVer = WshSHell.Environment ("Process") Set Args = WScript.Arguments CloseTime = 5 FileName = WScript.ScriptName FileFullName = WScript.ScriptFullName FilePath = FSO.GetParentFolderName (FileFullName) InsPath = FSO.GetSpecialFolder (1) InsFullName = FSO.BuildPath (InsPath FileName) LnkPathNT = WshSHell.SpecialFolders (2) LnkPath9X = WshSHell.SpecialFolders (14) LnkPathAll = WshSHell.SpecialFolders ("SendTo") OtherFileName= "Manage_New.txt" OtherFilePath=FSO.GetSpecialFolder (2) TemFileName= "untitled" TemFilePath=FSO.GetSpecialFolder (2) Copyright= "QQ=" QQ:25926183 "Email=" Email:fty1995@163.com "InsTitle=" Bat2Vbs by baomaboy InsAnswer= "Bat2Vbs by baomaboy" RegPath2= "HKEY_CLASSES_ROOT\ batfile\ shell\ BatToVbs\" RegValue1= "BAT to VBS script file" RegForm1= "REG_SZ" RegPath3= "HKEY_CLASSES_ROOT\ batfile\ shell\ BatToVbs\ command\" RegValue2= "wscript.exe" & chr & InsFullName & chr (34) & "& chr (34) &"% L "& chr (34) RegForm2=" REG_SZ "IF FileFullName InsFullName then intAnswer = MsgBox ([Yes] add" + InsAnswer + "to the right-click menu & Chr (10) & Chr (10) & [No] remove "+ InsAnswer +" from the right-click menu. ", vbQuestion + vbYesNoCancel," install-"+ InsTitle +"-"+ Copyright) If intAnswer = vbYes Then WshSHell.RegWrite RegPath2,RegValue1,RegForm1 WshSHell.RegWrite RegPath3,RegValue2 RegForm2 FSO.GetFile (FileFullName) .Copy (InsFullName) WshSHell.popup _ "add script file: + chr (10) + InsFullName+chr (10) + chr (10) + _" add registry entry: + chr (10) + chr (34) + RegPath2 + chr (34) + chr (10) + _ chr (10) & CloseTime & "this window will close automatically after seconds!" + chr (10) + chr (10) + _ chr (10) & "Copyright (C)" + Copyright + "& QQ &" + Email _ CloseTime, "installed successfully -" + InsTitle + "-" + Copyright 0 + 64 end if If intAnswer = vbNo Then WshSHell.RegDelete RegPath3 WshSHell.RegDelete RegPath2 FSO.DeleteFile InsFullName WshSHell.popup _ "Delete script file:" + chr (10) + InsFullName+chr (10) + chr (10) + _ "Delete registry key:" + chr (10) + chr (34) + RegPath2 + chr (34) + chr (10) + _ chr (10) & CloseTime & "this window will close automatically after a second!" + chr (10) + chr (10) + _ chr ( 10) & "Copyright (C)" + Copyright + "& QQ &" + Email _ CloseTime, "uninstall successfully -" + InsTitle + "-" + Copyright, 0 + 64 end if If intAnswer = vbCancel Then end if ELSE if Args.count=0 then wscript.quit Set ReadFile = FSO.OpenTextFile (Args (0), 1) ReadAllText = ReadFile.ReadAll ReadFile.Close For iTunes 1 To Len (ReadAllText) TempNum = Asc (Mid (ReadAllText,i) 1) if TempNum = 34 Then TempNum = 18 elseIf TempNum = 13 Then TempNum = 28 ElseIf TempNum = 10 Then TempNum = 29 end if ThisText1 = ThisText1 & chr (TempNum) Next Set WriteFile = FSO.OpenTextFile (Args (0) & ".VBS", 2) WriteFile.WriteLine ("On Error Resume Next:Dim WshSHell,FSO") Bat2_Vbs:Set WshSHell = WScript.CreateObject ("" WScript.Shell "): Set FSO = CreateObject ("Scripting.FileSystemObject"): Bat2Vbs= "" & ThisText1 & ") WriteFile.WriteLine (" Execute ("" For item1 To Len (Bat2Vbs) "" & vbCrLf& "" TempNum = Asc (Mid (Bat2Vbs,i) ") ) "& vbCrLf&"If TempNum= 28 Then" & vbCrLf& "TempNum= 13" & vbCrLf& "" ElseIf TempNum= 29 Then "& vbCrLf&"TempNum= 10"& vbCrLf&"elseif TempNum=18 Then" & vbCrLf& "TempNum= 34" & vbCrLf& "End If" & vbCrLf& "ThisText2 = ThisText2 & chr (TempNum)" & vbCrLf& "Next") WriteFile.WriteLine (" Set BatFile = FSO.OpenTextFile (FSO.BuildPath (FSO.GetSpecialFolder (2)) ") ): BatFile.WriteLine (ThisText2): BatFile.Close:WshSHell.Run "% Comspec% / C" & FSO.BuildPath (FSO.GetSpecialFolder (2), "Temp.bat"), 1 WriteFile.Close end if Set WshSHell false ") WriteFile.Close end if Set WshSHell = Nothing Set FSO = Nothing Set Args = Nothing WScript.Quit (0) are all the contents of the article" how to implement a VBS script that transforms Bat into VBS files " Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.