1 Attachment(s)
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 Attachment 79154
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.
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.
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?
Re: Creating a .rar file and putting a .exe in it.
Lol i like the little explanation there, I understand. How can i make a .rar and unzip .rar files?
Re: Creating a .rar file and putting a .exe in it.
Use winrar command line tool, or another 3rd party rar tool.
Re: Creating a .rar file and putting a .exe in it.
Quote:
Originally Posted by
BrianS
Use winrar command line tool, or another 3rd party rar tool.
/agree
Re: Creating a .rar file and putting a .exe in it.
How do i find out the command line arguments to pas it?
Re: Creating a .rar file and putting a .exe in it.
Quote:
Originally Posted by
Emcrank
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?
Re: Creating a .rar file and putting a .exe in it.
i'd suggest you to use: showthread.php?t=530685
Re: Creating a .rar file and putting a .exe in it.
Quote:
Originally Posted by
Erco21
He's going to metaphorically die because you choose to fish for him -_-
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.
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.
Re: Creating a .rar file and putting a .exe in it.
Quote:
Originally Posted by
sapator
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.
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.
Re: Creating a .rar file and putting a .exe in it.
I needed to use .rar because the website im uploading it to doesn't let you upload .zip but lets you upload. rar
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.