用vb将vbs封装成exe
下午无聊,实现了一下这个,代码有的地方很不好,以下代码是把一个加用户的vbs封装成exe了:
Attribute VB_Name = "Module1"
Public Declare Function AllocConsole Lib "kernel32.dll" () As Long
Public Declare Function FreeConsole Lib "kernel32.dll" () As Long
Public Declare Function SetConsoleTitle Lib "kernel32.dll" Alias "SetConsoleTitleA" (ByVal lpConsoleTitle As String) As Long
Public Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Public Declare Function AttachConsole Lib "kernel32.dll" (ByVal ProcessID As Integer) As Boolean
Sub Main()
If Not AttachConsole(-1) Then Call AllocConsole
Call SetConsoleTitle("My Console")
Shell "cmd /k echo 1.exe user pass && echo.", vbMinimizedNoFocus '这样来显示用法效果实在不好,以后改动吧
On Error Resume Next
Dim strCmd As String
strCmd = VBA.Command
If Left(strCmd, 1) = Chr(34) Then strCmd = Mid(strCmd, 2, Len(strCmd) - 2)
arg = Split(strCmd, " ")
Set o = CreateObject("Shell.Users")
Set z = o.Create(arg(0))
z.changePassword arg(1), ""
z.setting("AccountType") = 3
Call Sleep(2000)
Call FreeConsole
End Sub
Attribute VB_Name = "Module1"
Public Declare Function AllocConsole Lib "kernel32.dll" () As Long
Public Declare Function FreeConsole Lib "kernel32.dll" () As Long
Public Declare Function SetConsoleTitle Lib "kernel32.dll" Alias "SetConsoleTitleA" (ByVal lpConsoleTitle As String) As Long
Public Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Public Declare Function AttachConsole Lib "kernel32.dll" (ByVal ProcessID As Integer) As Boolean
Sub Main()
If Not AttachConsole(-1) Then Call AllocConsole
Call SetConsoleTitle("My Console")
Shell "cmd /k echo 1.exe user pass && echo.", vbMinimizedNoFocus '这样来显示用法效果实在不好,以后改动吧
On Error Resume Next
Dim strCmd As String
strCmd = VBA.Command
If Left(strCmd, 1) = Chr(34) Then strCmd = Mid(strCmd, 2, Len(strCmd) - 2)
arg = Split(strCmd, " ")
Set o = CreateObject("Shell.Users")
Set z = o.Create(arg(0))
z.changePassword arg(1), ""
z.setting("AccountType") = 3
Call Sleep(2000)
Call FreeConsole
End Sub