Dirk Diggler Posted July 7, 2006 Share Posted July 7, 2006 i wrote it for myself. if it will be useful for somebody.... at least, now vbs can be incapsulated in exe error handling not so good, but i'm too lazy to fix it. Global $filename Global $vbs Global $vbshandle Global $au3handle Global $au3filename Global $Line Global $error $func = 'Func RunVBS( $vbs) ' & @CRLF _ & ' Local $batname= "temp"& @MIN & @SEC & ".bat" ' & @CRLF _ & ' Local $vbsname= "temp"& @MIN & @SEC & ".vbs" ' & @CRLF _ & ' FileDelete(@TempDir & "\" & $vbsname) ' & @CRLF _ & ' FileWrite(@TempDir & "\" & $vbsname , $vbs) ' & @CRLF _ & ' FileWrite(@TempDir & "\" & $batname, $vbsname) ' & @CRLF _ & ' sleep(1000) ' & @CRLF _ & ' RunWait( @ComSpec &' & " ' /c" & ' "' & "'& @TempDir & '\' & $batname &" & "'" & '"' & "'" & ',@TempDir,@SW_HIDE) ' & @CRLF _ & ' FileDelete(@TempDir & "\" & $vbsname ) ' & @CRLF _ & ' FileDelete(@TempDir & "\" & $batname) ' & @CRLF _ & ' EndFunc' If $cmdline[0]=0 Then $filename = FileOpenDialog("Choose vbs", @HomeDrive,"VBScript (*.vbs)", 1) if @error = 1 Then MsgBox(0,"Error","Wrong filename or file error") Exit EndIf Else $filename = $cmdline[1] EndIf $vbshandle =FileOpen($filename,0) If $vbshandle = -1 Then MsgBox(0,"Error","vbs file read error") Exit EndIf if $cmdline[0]>1 Then $au3filename = $cmdline[2] Else $au3filename = FileSaveDialog("Enter au3 filename", @HomeDrive,"AutoIt3 (*.au3)",0, "vbs.au3") if @error = 1 Then MsgBox(0,"Error","Wrong filename or file error") Exit EndIf EndIf $au3handle =FileOpen($au3filename,2) If $au3handle = -1 Then MsgBox(0,"Error","Au3 file write error") Exit EndIf $Line = " $vbsscript = '" & FileReadLine($vbshandle) FileWrite($au3handle, $Line) SetError(0) While $error <> -1 $Line = FileReadLine($vbshandle) $error = @error if ($error <> -1) And StringStripWS($Line,8) <> "" Then FileWrite($au3handle, "' & @CRLF _ " & @CRLF) EndIf if StringStripWS($Line,8) <> "" Then $Line = "& '" & $Line Else ContinueLoop EndIf FileWrite($au3handle, $Line) WEnd FileWrite($au3handle,"'") FileWrite($au3handle,@CRLF & @CRLF) FileWrite($au3handle,"RunVBS($vbsscript)") FileWrite($au3handle,@CRLF & @CRLF) FileWrite($au3handle,$func) FileClose($vbshandle) FileClose($au3handle) Link to comment Share on other sites More sharing options...
Skruge Posted July 7, 2006 Share Posted July 7, 2006 Welcome to the forums!This should go into Scripts/Scraps instead of Support unless you have a specific question to ask.btw- Since you're embedding the file, why not just use FileInstall?Also, take a look here for a basic converter: http://www.autoitscript.com/forum/index.php?showtopic=12143 [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
Dirk Diggler Posted July 8, 2006 Author Share Posted July 8, 2006 (edited) because sometimes i need to replace substring in script. it is easier to work with string variable than with file And that compiler doesn't work properly. it maked non-workable au3-script from very simple vbs. Edited July 8, 2006 by Dirk Diggler Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now