I'm currently trying to write something that *tests* to see if a zip file is password protected. Let me be clear at this point that I'm not attempting to bypass anything, I'm testing that the user has password protected the file before it is sent via email.
Everything I try at the moment throws up a prompt asking for the password which not only pauses code execution, but isn't going to be acceptable as the code is fired every time an email is sent...
I've tried using the Shell App/Namespace method with same results, trying not to rely on using a 7-zip approach because not all users will have it installed.
Here's what I've got so far:
- Private Function SecureZipFile(zipFile As String) As Boolean
- Dim x As String * 2
- '// Check if system is 32bit or 64bit and assign to x
- x = IIf(Len(Environ("ProgramW6432")) > 0, "64", "32")
- '// If WinZip(xx).exe can be found in program files then test with WinZip
- If Not CreateObject("WScript.Shell").Exec("CMD /C DIR ""%PROGRAMFILES%\*WinZip" & x & ".exe"" /B /S /A:-D").StdOut.ReadAll = vbNullString Then
- WZloc = Environ("PROGRAMFILES") & "\WinZip\WinZip" & x
- strCheck = CreateObject("WScript.Shell").Exec("CMD /C """ & WZloc & """ -min -e """ & zipFile & _
- """ & %USERPROFILE%\Desktop\Temp").StdOut.ReadAll
- '// Rest of code when issue resolved.
- End If
- End Function
If anyone has any suggestions or pointers it would be greatly appreciated
Any questions let me know.