You can convert the bat to the VBS script for a bit VBS file _vbs

Source: Internet
Author: User
Tags chr readfile
The following code is slightly modified, the original structure is the script and the release of the bat synchronized execution and wait for the bat after the completion of the bat deletion, is not left behind temporary files. Then think about the common bad, such as releasing the execution of the bat file is a resident process of the monitoring type that VBS will be endless waiting and can not quit, so or instead of asynchronous execution, the script calls the bat after its own exit. Consider the idea of adding a delete from the end of the original file to restore the integrity. The compression package has not been updated.
Copy Code code 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= "no title"
Temfilepath=fso. GetSpecialFolder (2)
copyright= "Exquisite Technology"
Qq= "qq:25926183"
Email= "Email:fty1995@163.com"
Institle= "Bat2vbs by Baomaboy"
Insanswer= "Bat2vbs by Baomaboy"
regpath1= "Hkey_classes_root\batfile\shell\battovbs\"
Regvalue1= "Bat-vbs script file"
Regform1= "REG_SZ"
Regpath2= "Hkey_classes_root\batfile\shell\battovbs\command\"
Regvalue2= "Wscript.exe" & Chr (34) & Insfullname & Chr (+) & "" & Chr (+) & "%l" & CHR
Regform2= "REG_SZ"
IF filefullname <> Insfullname Then
Intanswer = MsgBox ("" is "+ Insanswer +" "added to the right-click menu," &chr &chr (a) & "No" removes "+ Insanswer +" from the right-click menu. ", vbquestion + vbYesNoCancel," installation-"+ Institle +"-"+ Copyright)
If intanswer = vbyes Then
WshShell.RegWrite Regpath1,regvalue1,regform1
WshShell.RegWrite Regpath2,regvalue2,regform2
Fso. GetFile (Filefullname). Copy (Insfullname)
Wshshell.popup _
"Add script file:" +CHR (+INSFULLNAME+CHR) +CHR (10) + _
"Add registry key:" +CHR (+CHR) + RegPath1 +CHR (10) + _
CHR & Closetime & "Seconds later this window will automatically close!" +CHR +CHR (10) + _
CHR & "Copyright (C)" + Copyright + "" & QQ & "" + Email _
, Closetime, "installation success-" + Institle + "-" + Copyright, 0 + 64
End If
If intanswer = vbno Then
Wshshell.regdelete RegPath2
Wshshell.regdelete RegPath1
Fso. DeleteFile Insfullname
Wshshell.popup _
"Delete script file:" +CHR (+INSFULLNAME+CHR) +CHR (10) + _
"Delete registry key:" +CHR (+CHR) + RegPath1 +CHR (+CHR) (10) + _
CHR & Closetime & "Seconds later this window will automatically close!" +CHR +CHR (10) + _
CHR & "Copyright (C)" + Copyright + "" & QQ & "" + Email _
, Closetime, "Uninstall Success-" + 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 I=1 to Len (ReadAllText)
Tempnum = ASC (Mid (readalltext,i,1))
If Tempnum = Then
Tempnum = 18
ElseIf Tempnum = Then
Tempnum = 28
ElseIf Tempnum = Then
Tempnum = 29
End If
THISTEXT1 = ThisText1 & Chr (tempnum)
Next
Set WriteFile = FSO. OpenTextFile (Args (0) & ". VBS ", 2,true)
Writefile.writeline ("On Error Resume next:dim wshshell,fso,bat2vbs:set WshShell = WScript.CreateObject (" " Wscript.Shell ""): Set FSO = CreateObject ("" Scripting.FileSystemObject ""): Bat2vbs= "" "& ThisText1 &" "" ""
Writefile.writeline ("Execute" for I=1 to Len (bat2vbs) "&vbCrLf&" Tempnum = ASC (Mid (bat2vbs,i,1)) "" & vbcrlf& "" If tempnum = Then "" &vbCrLf& "" Tempnum = "" &vbCrLf& "" ElseIf tempnum = Then "" & vbcrlf& "" Tempnum = Ten "" &vbCrLf& "" ElseIf tempnum=18 Then "" &vbCrLf& "" Tempnum = "" &vbcrlf & "" End If "" &vbCrLf& "" ThisText2 = ThisText2 & Chr (tempnum) "" &vbCrLf& "" Next "") "
Writefile.writeline ("Set batfile = FSO.") OpenTextFile (FSO. BuildPath (FSO. GetSpecialFolder (2), "" Temp.bat ""), 2,true): Batfile.writeline (THISTEXT2): BatFile.Close:WshSHell.Run ""%comspec%/C "&fso." BuildPath (FSO. GetSpecialFolder (2), "" Temp.bat ""), 1,false ")
Writefile.close
End If
Set WshShell = Nothing
Set FSO = Nothing
Set Args = Nothing
Wscript.Quit (0)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.