la_signorina_quy
asked on
vb 6.0 shelling a command
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.EX E" "\\servername\proj_package s$\Downloa d\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!
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.EX
==========================
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
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
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
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!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So after all that, my original statement did work. I'm not sure what was the problem before.
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)
strWinZipLoc = Chr(34) & GetWinZipLoc("wzipse32.exe
strCmd = strWinZipLoc _
& " " & Chr(34) & strPackagingPath & "\" & strZipFile & Chr(34) _
& " -y -le -overwrite -auto -c " & Chr(34) & ".\" & strBatchFile & Chr(34)
Call ShellAndWait(strCmd)
strWinZipLoc = Chr(34) & GetWinZipLoc("wzipse32.exe
strCmd = "" _
& " " & Chr(34) & strPackagingPath & "\" & strZipFile & Chr(34) _
& " -y -le -overwrite -auto -c " & Chr(34) & ".\" & strBatchFile & Chr(34)
ShellExecute 0&, vbNullString, strWinZipLoc, strCmd, vbNullString, vbHide