Batch File Help

Status
Not open for further replies.

EnigmaX

Baseband Member
Messages
28
Well guy's, here is my question, and forgive me as I haven't dove into the .bat file's to much.

Here is what I'm looking to do.

I have a folder with 23 files in it. I want to be able to ZIP that folder (including files) and create a batch file that will unzip the files to a certain directory.

I know the first thing your thinking is why not use WinZip or something of that nature? Well it may be possible, but the directory I need the files placed in will be C:\Document and Settings\%USERNAME%\temp\etc etc (meaning I can't hard code the directory)

I also want to be able to name the folder as it's extracted, as the name will be dependent on the User ID of the workstation (this will be pushed across the LAN).


Any idea's anyone?
 
Would the end user workstations need the Command Line addon as well, or just WinZip?


If that's not available, could IExpress (C:\Windows\system32\iexpress.exe) be used?
 
I apologize, you don't need the wzunzip command line utility.

Each computer will need winzip at least. Here's an updated code snippet.
Code:
set extractpath = "c:\documents and settings\" + %USERNAME% + "temp\etc\" + %hostname% + "\"
set zippath = "path to zip file"

"c:\program files\winzip\winzip32.exe" -e -o zippath extractpath

I've never played around with iexpress, but from what I just read on their page, you can make an inf out of the file. Here's the code to install an inf from a batch file. I'm not sure how to make it extract to the correct path though (it should tell you on that site though)

Code:
pathtoinf = "path to inf file"

rundll32 syssetup,SetupInfObjectInstallAction DefaultInstall 128 pathtoinf
 
Thanks for the information!

That takes care of getting the files where they need to be, I guess my next question is, is it possible to name the folder upon extraction?

The folder has to follow a certain naming convention related to the name of the software, with the LAN User ID appended to it

Example: C:\documents and settings\%USERNAME%\local settings\temp\"software name"_"username"

Let's just say for me the folder would have to be called "software_EnigmaX", but for you it would have to be "software_Bla!!"

I haven't figured out how to accommodate that, if at all possible...


P.S.

Where do I put this code?

set extractpath = "c:\documents and settings\" + %USERNAME% + "temp\etc\" + %hostname% + "\"
set zippath = "path to zip file"

"c:\program files\winzip\winzip32.exe" -e -o zippath extractpath
 
Is the software name dynamic also?

If it's not here's the exact code you need to paste into a blank notepad document and name as whatever.bat

Code:
set extractpath = "c:\documents and settings\" + %USERNAME% + "local settings\temp\etc\softwarename_" + %username% + "\"
set zippath = "path to zip file"

"c:\program files\winzip\winzip32.exe" -e -o zippath extractpath

If it is, you're going to need to pass the software name as an argument to the batch file and use this code.

Code:
set extractpath = "c:\documents and settings\" + %USERNAME% + "local settings\temp\etc\%1_" + %username% + "\"
set zippath = "path to zip file"

"c:\program files\winzip\winzip32.exe" -e -o zippath extractpath

To pass the argument you'd call it from a command like like this
whatever.bat softwareName
 
The software name is static, so I should be able to go with the first code snippet. I'll do some tinkering, but it looks like that just might do it, thanks again for all your help.
 
Status
Not open for further replies.
Back
Top Bottom