troubleshooting Question

vb 6.0 shelling a command

Avatar of la_signorina_quy
la_signorina_quy asked on
Programming
3 Comments1 Solution568 ViewsLast Modified:
Hello, I'm able to execute the following command from the cmd line fine.  However, when I try to execute it from the Shell function in VB, my program stalls.  I assume it's due to the fact that my command string is too long.  I've tried to use the ShellExecute API to no avail.  Does the ShellExecute function have the same command string limitation as the Shell function?  Is there a workaround?

 I need to programmatically create a self-extracting zip file.

==============================================================
From the command prompt,
The following command creates a self-extracting zip file and assigns a batch file to run once unzipped
==============================================================

"C:\Program Files\WinZip Self-Extractor\WZIPSE32.EXE" "\\servername\proj_packages$\Download\FY 2005\ATLANTA DIVISION\FY 2005_ATLANTA DIVISION.zip" -y -le -overwrite -auto -c ".\move_FY 2005_ATLANTA DIVISION.bat"

===================================================
From VB using Shell
If I write out the value of strCmd below to a log, I get the command above,
which will run from the command prompt
Even if I add the "C:\Program Files\WinZip Self-Extractor" to the path so that I only
need to specify "wzipse32.exe", it does not help.
===================================================
    strWinZipLoc = Chr(34) & GetWinZipLoc("wzipse32.exe") & Chr(34)
    strCmd = strWinZipLoc _
            & " " & Chr(34) & strPackagingPath & "\" & strZipFile & Chr(34) _
            & " -y -le -overwrite -auto -c " & Chr(34) & ".\" & strBatchFile & Chr(34)
    Call ShellAndWait(strCmd)

===================================================
From VB using ShellExecute
Tried to run it 2 different ways, neither worked.
===================================================
Method 1:
    strWinZipLoc = Chr(34) & GetWinZipLoc("wzipse32.exe") & Chr(34)
    strCmd = strWinZipLoc _
            & " " & Chr(34) & strPackagingPath & "\" & strZipFile & Chr(34) _
            & " -y -le -overwrite -auto -c " & Chr(34) & ".\" & strBatchFile & Chr(34)
 ShellExecute 0&, vbNullString, strWinZipLoc, strCmd, vbNullString, vbHide

Method2:
    strWinZipLoc = Chr(34) & GetWinZipLoc("wzipse32.exe") & Chr(34)
    strCmd = strWinZipLoc _
            & " " & Chr(34) & strPackagingPath & "\" & strZipFile & Chr(34) _
            & " -y -le -overwrite -auto -c " & Chr(34) & ".\" & strBatchFile & Chr(34)
 ShellExecute 0&, vbNullString, strWinZipLoc & strCmd, vbNullString, vbNullString, vbHide


Is there a workaround?  My constraints are that I need to use winzip and that I need to create the self-extracting file programmatically.  And I need to resolve this fast.

-Thanks!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros