Results 1 to 16 of 16

Thread: Creating a .rar file and putting a .exe in it.

  1. #1

    Thread Starter
    Fanatic Member Emcrank's Avatar
    Join Date
    Jan 2009
    Posts
    566

    Creating a .rar file and putting a .exe in it.

    Ok i have a code for making .zip files and putting stuff in them and it works fine. This one
    Code:
    Public Sub ZipFile(ByVal strFileToZip, ByVal strTargetZip)
            CreateEmptyZip(strTargetZip)
            Try
                CreateObject("Shell.Application").Namespace(strTargetZip).CopyHere(strFileToZip)
            Catch ex As Exception
    
            End Try
        End Sub
    
        Private Sub CreateEmptyZip(ByVal sPath As String)
            Dim strZIPHeader As String
            strZIPHeader = Chr(80) & Chr(75) & Chr(5) & Chr(6) & String.Format(18, 0)
            CreateObject("Scripting.FileSystemObject").CreateTextFile(sPath).Write(strZIPHeader)
        End Sub
    But now i need a code for a .rar file, I tried to use the same code but change the .zip to .rar like so
    Code:
    ZipFile(IO.Path.Combine(Application.StartupPath, "Tinternet.exe"), IO.Path.Combine(Application.StartupPath, "Test.rar"))
    but it gave this error Name:  Capture.JPG
Views: 1272
Size:  34.0 KB
    and in the details box it had this:
    Code:
    See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.
    
    ************** Exception Text **************
    System.Security.SecurityException: Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED)
       at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
       at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
       at Project_Packer.Form1.CreateEmptyZip(String sPath)
       at Project_Packer.Form1.ZipFile(Object strFileToZip, Object strTargetZip)
       at Project_Packer.Form1.Timer1_Tick(Object sender, EventArgs e)
       at System.Windows.Forms.Timer.OnTick(EventArgs e)
       at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    The Zone of the assembly that failed was:
    MyComputer
    
    
    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
        CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    ----------------------------------------
    Project Packer
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Users/Aaron%20T/Documents/Visual%20Studio%202008/Projects/Tinternet/Tinternet/bin/Debug/Project%20Packer.exe
    ----------------------------------------
    Microsoft.VisualBasic
        Assembly Version: 10.0.0.0
        Win32 Version: 10.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualBasic/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
    ----------------------------------------
    System
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Core
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System.Configuration
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    ----------------------------------------
    System.Xml
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    System.Runtime.Remoting
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
        CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Remoting/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
    ----------------------------------------
    
    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.
    
    For example:
    
    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>
    
    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.
    I Either need a new way to zip and unzip .rar files or a fix to this one. Thankyou for your time.

  2. #2
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455

    Re: Creating a .rar file and putting a .exe in it.

    Hello Emcrank,

    We had the same problem when we put applications on a server
    We solved with the help of caspol.exe, this tells the system that the application is safe.

    Goto dos
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>

    caspol -m -ag 1.2 -url <your executable> FullTrust

    Hopefully this will help

    Nice regards,
    Michelle.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Creating a .rar file and putting a .exe in it.

    Um, you don't zip and unzip RAR files. You zip and unzip ZIP files. RAR and ZIP are two completely different formats. You appear to be using the built in ZIP functionality of Windows, which knows nothing about the RAR format. Just because you put a ".rar" extensiuon on a file, that doesn't make it a RAR file. If you had a jar of salt and you put a label on it that said "Sugar", would you put it in your coffee?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

  5. #5
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564

    Re: Creating a .rar file and putting a .exe in it.

    Use winrar command line tool, or another 3rd party rar tool.

  6. #6
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Creating a .rar file and putting a .exe in it.

    Quote Originally Posted by BrianS View Post
    Use winrar command line tool, or another 3rd party rar tool.
    /agree
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  7. #7

  8. #8
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Creating a .rar file and putting a .exe in it.

    Quote Originally Posted by Emcrank View Post
    How do i find out the command line arguments to pas it?
    GOOGLE man, GOOGLE. You have to know this by now. How many times must we tell you this?
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  9. #9
    Addicted Member
    Join Date
    Apr 2009
    Location
    Croatia
    Posts
    201

    Re: Creating a .rar file and putting a .exe in it.

    i'd suggest you to use: showthread.php?t=530685

  10. #10
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Creating a .rar file and putting a .exe in it.

    Quote Originally Posted by Erco21 View Post
    i'd suggest you to use: showthread.php?t=530685
    He's going to metaphorically die because you choose to fish for him -_-
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Creating a .rar file and putting a .exe in it.

    It's not really practical to use WinRAR unless you are absolutely positive that every user will have it installed. Otherwise you should include all the functionality you need in your app. There are various .NET compression components around, including SharpZipLib and SevenZipSharp. I'm fairly sure either or both of those freebies support RAR.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  12. #12
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Creating a .rar file and putting a .exe in it.

    To tell you the truth winzip is rarely used these days.All i see is rar files (that will also read zip and the popular ISO xtensions).I wish Microsoft finally decide to include it in .net, would make life easier for many people.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  13. #13
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Creating a .rar file and putting a .exe in it.

    Quote Originally Posted by sapator View Post
    To tell you the truth winzip is rarely used these days.All i see is rar files (that will also read zip and the popular ISO xtensions).I wish Microsoft finally decide to include it in .net, would make life easier for many people.
    WinZip is an application, just like WinRAR. ZIP and RAR are file formats. RAR provides better compression than the original ZIP format but ZIP is still more widely used, mainly because it's more widely used. There are newer versions of the ZIP format that provide better compression so RAR has lost its lead there, although those newer ZIP formats are also not used by many who could, just like RAR, because you risk many people not being able to open them. I use WinZip, which supports all ZIP formats and RAR and more, on my desktop but I just use the Windows ZIP capabilities on my laptop.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  14. #14
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Creating a .rar file and putting a .exe in it.

    I think zip is older so we cannot compare in time depth but in year to year depth.I remember using Pkzip
    Anyway provided that zip is embedded on windows, rar does a great job for keeping up and for me it's better if we compare standard zip with standard rar.
    Also rar has dominated the internet file sharing.You should rarely see zip packed files.
    Anyway as i've said Microsoft should include one of the most used format in the world.
    P.S. I also use zip and rar but the ratio is 80% rar 18% zip and 2% ISO or 7-zip or something else.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  15. #15

  16. #16
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Creating a .rar file and putting a .exe in it.

    I'm not implying that the RAR format shouldn't be used. If you do use it though you will need third-party help because there's no RAR support in Windows or in .NET. Relying on WinRAR is only an option if you know for a fact that all users will have it installed, which may well be the case. Otherwise, you should use a library that includes RAR support, of which there are several free options available.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width