Command line parameter (winzip) without surrounding quotes

I'm trying to pass a command line parameter to unzip a file.  I create a string variable that the command line doesn't understand because it is enclosed in quotation marks.  Either I need to remove the starting/ending quotes or there's a better way to do this altogether.

More info on the string variable.........
variable composed of:
1. the location of winzip.exe (this must be enclosed in quotes)
2. the filename and the destination folder (these should not be quoted)

The string ends up looking like this in the immediate window:
""C:\Program Files\WinZip\wzunzip" oasis.zip c:\temp\"

It should look like this (ie without the starting and ending quote):
"C:\Program Files\WinZip\wzunzip" oasis.zip c:\temp\
jbpowellAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DexstarCommented:
jbpowell,

> Either I need to remove the starting/ending quotes or there's a better way to
> do this altogether.

You should remove the quotes like this:
Say your string variable is "strEXE".  Before you execute the command line, do this:
    strEXE = Mid( strExe, 2, Len(strEXE)-2 )

That should remove the first and last characters from the string.  In this case, the quotes that are giving your grief.

Hope that helps,
Dex*
0
Mike EghtebasDatabase and Application DeveloperCommented:
Shell ("C:\Program Files\WinZip.exe c:\temp\oasis.zip")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike EghtebasDatabase and Application DeveloperCommented:
BTW, you need to check name and paths for accuracy in my last post to make sure they are what you have.

Mike
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

pilbyCommented:
where do the quotes come from in the original string in the first place?

try assigning your string like this:

str = """C:\Program Files\Winzip\wzunzip"" oasis.zip c:\temp"

the first and last quotes should identify the string to be passed, the double quotes ("") represent a single set of quotation marks within a string.  in the end, your string should be the way you want it.

OR if you need to assign the location of winzip and the rest separately, try:

winzipStr = "C:\Program Files\WinZip\wzunzip"   (will be assigned w/o quotes)
filenameDestStr = "oasis.zip c:\temp\"                (again, no quotes in resulting string)
str = """" & winzipStr & """"                               (putting quotes around it)
str = str & filenameDestStr                                (adds on the filename and destination w/o quotes)

the end result should be the same (assuming winzipStr and filenameDestStr don't contain any quotes)

weston
0
pilbyCommented:
what command are you using on the string?  a Shell command should do the trick (although you'll probably need: Shell ("C:\Program Files\WinZip.exe oasis.zip c:\temp\") , not the exactly what eghtebas gave you) and you won't have to worry about quotes inside strings.
0
pilbyCommented:
sorry,
Shell("C:\Program Files\WinZip\wzunzip oasis.zip c:\temp\")
0
Mike EghtebasDatabase and Application DeveloperCommented:
My post, Shell ("C:\Program Files\WinZip.exe c:\temp\oasis.zip") , will open the zipped file.  It requiers mannual extraction.
0
inoxCommented:

try
  Shell ("""C:\Program Files\WinZip\wzunzip"" oasis.zip c:\temp\")
0
jbpowellAuthor Commented:
Thank you eightbas, I did not test your solution, what I ended up doing was to copy the wzzip.exe and wzunzip.exe files to this folder: C:\Program Files\Common Files\Autodesk Shared

That allows me to execute winzip with the code below using the following cmdline$ string parameter.

cmdline$ = "wzunzip -o c:\temp\oasis.zip c:\temp"


'***********************************************************************************************
' Module: ShellCmd
'
' This module provides the functionality necessary to synchronously execute a shell command.
'
' NOTE: We need to wait for the unzip to finish before we continue processing.  This is a more
' efficient method then polling the task Id which would be required if we used the VB shell command.
'
' See http://support.microsoft.com/support/kb/articles/Q129/7/96.ASP for more information on
' this code.
'***********************************************************************************************
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long

Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&


Private Type STARTUPINFO
      cb As Long
      lpReserved As String
      lpDesktop As String
      lpTitle As String
      dwX As Long
      dwY As Long
      dwXSize As Long
      dwYSize As Long
      dwXCountChars As Long
      dwYCountChars As Long
      dwFillAttribute As Long
      dwFlags As Long
      wShowWindow As Integer
      cbReserved2 As Integer
      lpReserved2 As Long
      hStdInput As Long
      hStdOutput As Long
      hStdError As Long
   End Type

   Private Type PROCESS_INFORMATION
      hProcess As Long
      hThread As Long
      dwProcessID As Long
      dwThreadID As Long
   End Type
   
Public Function ExecCmd(cmdline$)
'***********************************************************************************************
' Function:     ExecCmd
' Parameters:   cmdline$ - string containing the full command line to be executed,
'                           including parameters
'
' Returns: 0 iff successful (long)
'
' This function will execute a shell command in a new window.  The window will receive focus.
' This function only returns when the command has terminated (and the commands
' window is closed).
'***********************************************************************************************
On Error GoTo ErrorHandler
      Dim proc As PROCESS_INFORMATION
      Dim start As STARTUPINFO
      Dim ret&

      ' Initialize the STARTUPINFO structure:
      start.cb = Len(start)

      ' Start the shelled application:
      ret& = CreateProcessA(vbNullString, cmdline$, 0&, 0&, 1&, _
         NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc)

      ' Wait for the shelled application to finish:
         ret& = WaitForSingleObject(proc.hProcess, INFINITE)
         Call GetExitCodeProcess(proc.hProcess, ret&)
         Call CloseHandle(proc.hThread)
         Call CloseHandle(proc.hProcess)
         ExecCmd = ret&
         
    Exit Function
ErrorHandler:
    MsgBox "Error: " & Err.Description
End Function
0
Mike EghtebasDatabase and Application DeveloperCommented:
Thanky you.

Mike
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.