LoWrIdErTJ - BotGuru 904 Posted June 27, 2011 Report Share Posted June 27, 2011 What I am trying to do is use the shell command to unzip a .zip file to a specified folder. It should:create folder (UI text area command)unzip specified zip file (UI open file command) to created folder Really need this functionality, let me know your thoughts, ideas, and feedback. TJ Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted June 28, 2011 Author Report Share Posted June 28, 2011 Willing to pay for this to work properly.. Let me know if you know how to set this up and how much you want to charge if anything. TJ Quote Link to post Share on other sites
k1lv9h 76 Posted June 28, 2011 Report Share Posted June 28, 2011 My sample using 7 zip. Of course it does not work with 64 bit version of 7 zip. My Idea.unzip.ubot Kevin Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted June 28, 2011 Author Report Share Posted June 28, 2011 its a nice attempt and thank you. I'm looking to use the built in unzip feature of windows. This way i do not have to require a client to download and install a separate zip program. TJ Quote Link to post Share on other sites
k1lv9h 76 Posted June 28, 2011 Report Share Posted June 28, 2011 Microsoft does not provide that.This one uses vbscript.unzip-vbs.ubot vbscript: set sa = CreateObject("Shell.Application") ReDim strArgumentArray(0) Dim strFlag,objArgs Dim strType,strInputType Dim strComputer Dim strMessage Set objArgs = WScript.Arguments 'Get the command line arguments For i = 0 to objArgs.count - 1 ReDim Preserve strArgumentArray(i) strArgumentArray(i) = objArgs.item(i) Next strFlag = strArgumentArray(0) If strFlag = "" then 'No arguments have been received workmsgout = "Please specific parameters : " & wscript.scriptname & " /unzipfile:directoryandfilename /putfilehere:directory" msgout = workmsgout wscript.echo msgout Wscript.Quit End If For i = 0 to UBound(strArgumentArray) strFlag = Left(strArgumentArray(i), InStr(1, strArgumentArray(i), ":")-1) 'Prevent parameter error : An error occurs if there is no : in the string If Err.Number Then Err.Clear msgout = strArgumentArray(i) & " is NOT recognized as a valid input." wscript.echo msgout Wscript.Quit Else Select Case LCase(strFlag) Case "/unzipfile" pathToZipFile = Right(strArgumentArray(i), Len(strArgumentArray(i))-11) Case "/putfileshere" extractTo = Right(strArgumentArray(i), Len(strArgumentArray(i))-14) Case else msgout = strArgumentArray(i) & " is not recognized as a valid input." wscript.echo msgout End Select End If Next 'pathToZipFile="C:\dnld\ubotstudio\samplescript\zipped-file.zip" 'extractTo="C:\dnld\unzip" set filesInzip=sa.NameSpace(pathToZipFile).items sa.NameSpace(extractTo).CopyHere(filesInzip) Kevin Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted June 29, 2011 Author Report Share Posted June 29, 2011 Microsoft does not provide that.This one uses vbscript.unzip-vbs.ubot vbscript: set sa = CreateObject("Shell.Application") ReDim strArgumentArray(0) Dim strFlag,objArgs Dim strType,strInputType Dim strComputer Dim strMessage Set objArgs = WScript.Arguments 'Get the command line arguments For i = 0 to objArgs.count - 1 ReDim Preserve strArgumentArray(i) strArgumentArray(i) = objArgs.item(i) Next strFlag = strArgumentArray(0) If strFlag = "" then 'No arguments have been received workmsgout = "Please specific parameters : " & wscript.scriptname & " /unzipfile:directoryandfilename /putfilehere:directory" msgout = workmsgout wscript.echo msgout Wscript.Quit End If For i = 0 to UBound(strArgumentArray) strFlag = Left(strArgumentArray(i), InStr(1, strArgumentArray(i), ":")-1) 'Prevent parameter error : An error occurs if there is no : in the string If Err.Number Then Err.Clear msgout = strArgumentArray(i) & " is NOT recognized as a valid input." wscript.echo msgout Wscript.Quit Else Select Case LCase(strFlag) Case "/unzipfile" pathToZipFile = Right(strArgumentArray(i), Len(strArgumentArray(i))-11) Case "/putfileshere" extractTo = Right(strArgumentArray(i), Len(strArgumentArray(i))-14) Case else msgout = strArgumentArray(i) & " is not recognized as a valid input." wscript.echo msgout End Select End If Next 'pathToZipFile="C:\dnld\ubotstudio\samplescript\zipped-file.zip" 'extractTo="C:\dnld\unzip" set filesInzip=sa.NameSpace(pathToZipFile).items sa.NameSpace(extractTo).CopyHere(filesInzip) Kevin Seems like this would workHowever on testing came up with an error for line strFlag = Left(strArgumentArray(i), InStr(1, strArgumentArray(i), ":")-1) Error readsInvalid procedure call or argument: 'Left'code: 800A0005 Quote Link to post Share on other sites
k1lv9h 76 Posted June 29, 2011 Report Share Posted June 29, 2011 I will be more than happy to fix this. I will need your help. It works for me here. This will run the Vbscript in a command prompt window. unzip-vbscript /putfileshere:whereever /unzipfile:zipfileex. unzip-vbscript /putfileshere:c:\download\unziparea /unzipfile:c:\download\zippedarea\azipfile.zip I figured it out. There seems to me an extra character or two in the arguments missing the ":" being passed to the vbscript. I can check for that but the script will stop because of invalid arguments. Easier to just remove the extra stuff. My sample vbscript bot did not have anything extra. Update to vbs code.Added checks for valid data being passed.It will create the output target directory if it does not exist.Skip the unzip if the zip file is missing. Set fso = CreateObject("Scripting.FileSystemObject") set sa = CreateObject("Shell.Application") ReDim strArgumentArray(0) Dim strFlag,objArgs Dim strType,strInputType Dim strComputer Dim strMessage Set objArgs = WScript.Arguments 'Get the command line arguments For i = 0 to objArgs.count - 1 ReDim Preserve strArgumentArray(i) strArgumentArray(i) = objArgs.item(i) Next strFlag = strArgumentArray(0) If strFlag = "" then 'No arguments have been received workmsgout = "Please specific parameters : " & wscript.scriptname & " /unzipfile:directoryandfilename /putfileshere:directory" msgout = workmsgout wscript.echo msgout Wscript.Quit End If For i = 0 to UBound(strArgumentArray) 'wscript.echo strArgumentArray(i) strFlag = Left(strArgumentArray(i), InStr(1, strArgumentArray(i), ":")-1) 'Prevent parameter error : An error occurs if there is no : in the string If Err.Number Then Err.Clear msgout = strArgumentArray(i) & " is NOT recognized as a valid input." wscript.echo msgout Wscript.Quit Else Select Case LCase(strFlag) Case "/unzipfile" pathToZipFile = Right(strArgumentArray(i), Len(strArgumentArray(i))-11) Case "/putfileshere" extractTo = Right(strArgumentArray(i), Len(strArgumentArray(i))-14) Case else msgout = strArgumentArray(i) & " is not recognized as a valid input." wscript.echo msgout End Select End If Next 'create folder if it does not exist If NOT fso.FolderExists(ExtractTo) Then fso.CreateFolder(ExtractTo) End If 'do nothing if zip file is missing if fso.fileexists(pathToZipFile) then set filesInzip=sa.NameSpace(pathToZipFile).items sa.NameSpace(extractTo).CopyHere(filesInzip) end if Thanks,Kevin Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted June 29, 2011 Author Report Share Posted June 29, 2011 Do you have any sort of messenger for contact.Not sure if i'm doing something wrong or not. Quote Link to post Share on other sites
k1lv9h 76 Posted June 29, 2011 Report Share Posted June 29, 2011 I updated the VBScript code to check for the extra characters. Once the character(s) are identified a simple adjustment of bot shell would do the trick. Set fso = CreateObject("Scripting.FileSystemObject") set sa = CreateObject("Shell.Application") ReDim strArgumentArray(0) Dim strFlag,objArgs Dim strType,strInputType Dim strComputer Dim strMessage Set objArgs = WScript.Arguments 'Get the command line arguments For i = 0 to objArgs.count - 1 ReDim Preserve strArgumentArray(i) strArgumentArray(i) = objArgs.item(i) Next strFlag = strArgumentArray(0) If strFlag = "" then 'No arguments have been received workmsgout = "Please specific parameters : " & wscript.scriptname & " /unzipfile:directoryandfilename /putfileshere:directory" msgout = workmsgout wscript.echo msgout Wscript.Quit End If For i = 0 to UBound(strArgumentArray) strFlag = Left(strArgumentArray(i), len(strArgumentArray(i))) if instr(1,strFlag,":") then strFlag = Left(strArgumentArray(i), InStr(1, strArgumentArray(i), ":")-1) end if 'Prevent parameter error : An error occurs if there is no : in the string If Err.Number Then Err.Clear msgout = strArgumentArray(i) & " is NOT recognized as a valid input." wscript.echo msgout Wscript.Quit Else Select Case LCase(strFlag) Case "/unzipfile" pathToZipFile = Right(strArgumentArray(i), Len(strArgumentArray(i))-11) Case "/putfileshere" extractTo = Right(strArgumentArray(i), Len(strArgumentArray(i))-14) Case else msgout = strArgumentArray(i) & " is not recognized as a valid input." wscript.echo msgout End Select End If Next 'create folder if it does not exist if ExtractTo>"" then If NOT fso.FolderExists(ExtractTo) Then fso.CreateFolder(ExtractTo) End If end if 'do nothing if zip file is missing if pathToZipFile>"" then if fso.fileexists(pathToZipFile) then set filesInzip=sa.NameSpace(pathToZipFile).items sa.NameSpace(extractTo).CopyHere(filesInzip) end if end if Thanks,KevinI am working on the messenger thing. Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted June 29, 2011 Author Report Share Posted June 29, 2011 I think my executing in shell is incorrectly formated to execute the vbs script I have it setup as cmd /PATH_TO_VBS_FILE /putfileshere:PATH_TO_FOLDER_TO_SAVE_TO /unzipfile:PATH_TO_ZIP_FILE Quote Link to post Share on other sites
k1lv9h 76 Posted June 29, 2011 Report Share Posted June 29, 2011 Take a look in my sample bot I provided when I posted the vbscript. Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted June 29, 2011 Author Report Share Posted June 29, 2011 Take a look in my sample bot I provided when I posted the vbscript. Using the original example utilizes 7zip (slightly modified) Came back with errorpath/to/zip.zip is not recognized as a valid input line: 60Char: 5Unspecified errorcode: 80004005source null I have attached what I have in my .ubot Using 2 UI elements to setName of folder to save toAnd open the path to the zip file It creates the vbs file on the desktop, and the folder to save to, than attempts to execute the shell command to run the vbscript file which at that point brings back the error. after the shell runs it removes the vbscript file from the desktop area.move the stop script node up 1 if you wish to have it not delete the file for testing. I do appreciate your help on this. TJ Quote Link to post Share on other sites
k1lv9h 76 Posted June 29, 2011 Report Share Posted June 29, 2011 TJ, That worked fine for me. Kevin I did add more code to replace "/" with "\" in the vbscript. My testing pop a message error message when I sent it unix file names. Attached bot with replace updates.unzip to folder.ubot Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted June 29, 2011 Author Report Share Posted June 29, 2011 tested with file test_file.zipcreated with winrar as zip file came up same error Came back with errorpath/to/zip.zip is not recognized as a valid input Does my version of windows play a role in this?windows 7 64bit (x86) I just can't seem to get it to work on my end to unzipping the zip document to the folder created. TJ Quote Link to post Share on other sites
k1lv9h 76 Posted June 29, 2011 Report Share Posted June 29, 2011 TJ, Can you view the contents of your zip file with Windows explorer? Can you give me your exact ui input values you used? So I can try to recreate the issue. Lastly a little sample zip file please. I create mine with 7-zip. Yep I am Windows 7 64bit. Thanks,Kevin Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted June 29, 2011 Author Report Share Posted June 29, 2011 this has the .ubot file in itthe zip file I am usingand process taken to replication in instructions.txt TJ Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted July 13, 2011 Author Report Share Posted July 13, 2011 After further testing with this I could that the same vbscript that will work in Vista and Win 7 32 and 64 bit will not work with Win XP sp3 Hmm. TJ Quote Link to post Share on other sites
k1lv9h 76 Posted July 14, 2011 Report Share Posted July 14, 2011 TJ, Update the sample bot and vbscript. Added ability to turn on debug and missing zip file messages externally. No recompiling bot.To get zip missing message create file named: zip-missing-message.dat in the directory the sample bot is.To get debug message create file named: vbscript-debug-message.dat in the directory the sample bot is.Sample bot is only looking for the file name. Files can be empty. I have and continue to run this on my WinXP SP3 box with all the latest Microsoft patches. It runs without a issue. So I am stumped as what the problem could be. unzip to folder-002.ubot Kevin Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted July 14, 2011 Author Report Share Posted July 14, 2011 k1v9h contact me on skype if you can. I will send you a copy of the very production bot where users are having an issue and let me know if you have the same issue on your pc since its the same setup if you dont mind? TJ Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.