edg21 Posted September 7, 2004 Posted September 7, 2004 Unattended Installation using FTP - Last Update: 9/20/04This script can be used for post installation of applications, udpates, drivers, & just about anything you want. You can run this @ GUIRUNONCE, RUNONCEEX, whenever you choose. What this does is download "packages" from the specified FTP server & then builds the installation script for those packages. The advantage of doing it this way is that you don't have to reburn your installation cd everytime you want to add/update something. All you will have to do is make/edit a package & put it on the ftp server. You could even put this on a bootable floppy/cd & have it do a complete unattended setup with minor editing. I tried to give this post more detailed instructions on usage, let me know if this is enough. I might just put up a page on my site, but I'm not sure if enough people are interested or not.Changes:9/20/04 - Script now obtains its variables from an INI file. NOTE: Now the script is called like: ftp.cmd [path to ini]9/20/04 - Fixed a missing BYE command in the ftp login test.9/12/04 - Fixed missing bin & prom commands while downloading required EXEs.9/10/04 - Removed the DEVCON.EXE section for now.9/10/04 - Now downloads any required EXEs before anything else.9/10/04 - Fixed some typos, must be the lack of sleep.9/06/04 - Added more variables to give better control over the whole process.9/06/04 - Changed the way the FTP script is generated.9/05/04 - Added /I swith to the IF Y/N commands so it's no longer case sensitive *greenmachine9/04/04 - Added definitions for all the variables, will hopefully make editing the script for your own use easier.9/02/04 - Now tests the FTP server un/pw specified in the batch, if it's incorrect it will prompt user for input.8/29/04 - Detects ATI or NVIDIA video card & downloads appropriate package.8/29/04 - Added DRIVERS folder for device drivers8/29/04 - Added MODS folder for modified files (uxtheme.dll etc.)8/28/04 - Packages structure is easier to manage, just put commands.txt in the folder & rar it up.8/28/04 - Now tests for existance of FTP server.8/28/04 - All necessary tools are downloaded (NO EXTRA FILES REQUIRED ON YOUR INSTALL CD)Requirments:Network Access (Use the LANPack to make sure)FTP Server to serve up packages.UNRAR.EXEWhat it Does:Checks for existance of ftp server.Checks username/password on server & prompts for user input if it can't login.Downloads "packages" via ftp.exeExtracts the packagesCreates an installation script for the packages (based off commands.txt)Applies registry tweaksInstalls packagesCreating Packages:To dowload & install applications, updates, etc.. you will need to make each of them into individual "packages".Making packages is a pretty straightforward process. The video drivers are the only exception to the rule really, you need to set the name of these packages in the variables later on.Create folder named after your application.Put setup.exe for your application into the folderCreate a text file named commands.txt in the folderEdit commands.txt & put in your applications silent install commands. Compress the folder using winRAR to a file with the same name.Example Package: DOWNLOADCOMMANDS.TXT EXAMPLE: (Note: The first line of the commands.txt file needs to be blank.) example ECHO.ECHO Installing Winrar v3.30 ...start /wait %APP_DIR%\winrar330\setup.exe /sREGEDIT /S %APP_DIR%\winrar330\cascade.regFTP Server Setup:Create the following directory structure on your ftp server:/unattend/unattend/apps/unattend/mods/unattend/updates/unattend/drivers/unattend/tweaks/unattend/toolsCopy your packages to their perspective folders & put your .reg files in the /tweaks folder. (Note: I have my reg tweaks in seperate files (enable_rdp.reg, disable_error_report.reg, etc.)/unattend/tools Needs to contain devcon.exe & unrar.exeEditing The INI File:You will need to edit some of the variables in FTP_VAR.INI to fit your setup. If you follow my setup you should really only have to edit FTP_ADDY, FTP_USER, FTP_PASS, & TOP_DIR. There is a full list of the variables & their functions listed below, as you can see you can change just about everything, from temp files it creates to the name of the installation script it generates.FTP_VAR.INI Variable Settings:FTP_ADDY = 192.168.1.25 (ip of your ftp server)FTP_USER = username (ftp username)FTP_PASS = password (ftp password)FTP_CANC = undefined (part of ftp server testing **DO NOT EDIT**)PAK_DIR = unattend (base folder for packages on ftp server)TOP_DIR = %SYSTEMDRIVE%\install (Local download directory)FTP_SCR = c:\install\ftp_scr.txt (generated ftp script)FTP_TSCR = c:\install\ftp_tscr.txt (generated ftp testing script)FTP_OUT = c:\install\ftp_out.txt (generated ftp testing output)INSTALL_SCR = c:\install\install.cmd (generated package installation script)PACK_SCR = commands.txt (filename containing package install commands)TOOL_SCR = generated ftp script to download toolsTOOL_DIR = c:\windows\system32 (location commandline tools will be downloaded to)APP_DIR = c:\install\apps (Local directory for apps)UPD_DIR = c:\install\updates (local directory for updates/patches)TWK_DIR = c:\install\tweaks (local directory for .reg tweaks)MOD_DIR = c:\install\mods (local directory for modded files)DRV_DIR = c:\install\drivers (local directory for drivers)FTP_VAR.INI# Format: VariableName=VariableValue# Do not use spaces around the equal sign.FTP_ADDY=192.168.1.25FTP_USER=testFTP_PASS=testFTP_CANC=undefinedPAK_DIR=unattendTOP_DIR=c:\installFTP_SCR=c:\install\ftp_scr.txtFTP_TSCR=c:\install\ftp_tscr.txtFTP_OUT=c:\install\ftp_out.txtINSTALL_SCR=c:\install\install.cmdPACK_SCR=commands.txtTOOL_SCR=c:\install\tool_scr.txtTOOL_DIR=c:\windows\system32APP_DIR=c:\install\appsUPD_DIR=c:\install\updatesTWK_DIR=c:\install\tweaksMOD_DIR=c:\install\modsDRV_DIR=c:\install\driversFTP.CMD@ECHO OFFSET SCR_VER=PACK_GET.CMD v1.0if .%1.==.. goto usageset INI_FILE=%1set INI_FILE=%INI_FILE:"=%if not exist "%INI_FILE%" goto missing_iniECHO.ECHO Setting variables defined in %INI_FILE% ...for /f "eol=# tokens=1* delims==" %%a in ('type %INI_FILE%') do set %%a=%%b:: CREATING DIRECTORIES FOR PACKAGESECHO.ECHO Creating directories ...md %TOP_DIR%md %APP_DIR%md %UPD_DIR%md %TWK_DIR%md %DRV_DIR%md %MOD_DIR%::BEGIN FTP SERVER TESTING:FTP_EXISTECHO ping ftp ... PING %FTP_ADDY% ¦ FIND "TTL" >NULIF ERRORLEVEL 0 GOTO FTP_TESTIF ERRORLEVEL 1 GOTO FTP_INPUT:FTP_TESTECHO. ftp exists ... testing login ...> %FTP_TSCR% ECHO open %FTP_ADDY%>>%FTP_TSCR% ECHO %FTP_USER%>>%FTP_TSCR% ECHO %FTP_PASS%>>%FTP_TSCR% ECHO bye%WINDIR%\system32\ftp.exe -s:%FTP_TSCR% > %FTP_OUT%FIND "User logged in" %FTP_OUT% >NULIF ERRORLEVEL 1 GOTO FTP_CHOICEGOTO FTP_START:FTP_CHOICEECHO.SET /P FTP_CANC=[Cancel FTP download? Y/N:]IF /I "%FTP_CANC%" == "Y" goto CANCELIF /I "%FTP_CANC%" == "N" goto FTP_INPUTGOTO FTP_CHOICE:FTP_INPUTif exist %FTP_OUT% del %FTP_OUT%if exist %FTP_TSCR% del %FTP_TSCR%SET /P FTP_ADDY=[FTP Address:]SET /P FTP_USER=[FTP Username:]SET /P FTP_PASS=[FTP Password:]SET /P PAK_DIR=[Base Package Directory:]ECHO.ECHO You specified:ECHO FTP Address: %FTP_ADDY%ECHO FTP Username: %FTP_USER%ECHO FTP Password: %FTP_PASS%ECHO FTP Package Directory: %PAK_DIR%:FTP_CONFIRMECHO.SET /P FTP_CONF=[Is this correct? Y/N:]IF /I "%FTP_CONF%" == "Y" GOTO FTP_EXISTIF /I "%FTP_CONF%" == "N" GOTO FTP_INPUTGOTO FTP_CONFIRM::END FTP SERVER TESTING::BEGIN BUILDING FTP SCRIPT:FTP_STARTdel %FTP_OUT%del %FTP_TSCR%ECHO Getting Required files ...> %TOOL_SCR% ECHO open %FTP_ADDY%>>%TOOL_SCR% ECHO %FTP_USER%>>%TOOL_SCR% ECHO %FTP_PASS%>>%TOOL_SCR% ECHO bin>>%TOOL_SCR% ECHO prom>>%TOOL_SCR% ECHO lcd %TOOL_DIR%>>%TOOL_SCR% ECHO cd unattend>>%TOOL_SCR% ECHO cd tools>>%TOOL_SCR% ECHO mget *.*>>%TOOL_SCR% ECHO bye%WINDIR%\system32\ftp.exe -s:%TOOL_SCR%del %TOOL_SCR%ECHO Building FTP Script ...> %FTP_SCR% ECHO open %FTP_ADDY%>>%FTP_SCR% ECHO %FTP_USER%>>%FTP_SCR% ECHO %FTP_PASS%>>%FTP_SCR% ECHO bin>>%FTP_SCR% ECHO prom>>%FTP_SCR% ECHO cd %PAK_DIR%>>%FTP_SCR% ECHO lcd %APP_DIR%>>%FTP_SCR% ECHO cd apps>>%FTP_SCR% ECHO mget *.rar>>%FTP_SCR% ECHO lcd %UPD_DIR%>>%FTP_SCR% ECHO cd ../updates>>%FTP_SCR% ECHO mget *.rar>>%FTP_SCR% ECHO lcd %TWK_DIR%>>%FTP_SCR% ECHO cd ../tweaks>>%FTP_SCR% ECHO mget *.reg>>%FTP_SCR% ECHO lcd %MOD_DIR%>>%FTP_SCR% ECHO cd ../mods>>%FTP_SCR% ECHO mget *.rar>>%FTP_SCR% ECHO lcd %DRV_DIR%>>%FTP_SCR% ECHO cd ../drivers>>%FTP_SCR% ECHO mget *.rar:FTP_DONE>>%FTP_SCR% ECHO bye::END BUILDING FTP SCRIPTECHO.ECHO Downloading per FTP_CMD.TXT ....%WINDIR%\system32\ftp.exe -s:%FTP_SCR%del %FTP_SCR%ECHO. ECHO Extracting Packages ...for %%i in (%APP_DIR%\*.rar) do UNRAR x %%i %APP_DIR%for %%i in (%UPD_DIR%\*.rar) do UNRAR x %%i %UPD_DIR%for %%i in (%DRV_DIR%\*.rar) do UNRAR x %%i %DRV_DIR%for %%i in (%MOD_DIR%\*.rar) do UNRAR x %%i %MOD_DIR%for %%i in (%APP_DIR%\*.rar %UPD_DIR%\*.rar %DRV_DIR%\*.rar %MOD_DIR%\*.rar) do DEL %%iECHO.ECHO Applying various registry tweaks ...for %%i in (%TWK_DIR%\*.reg) do REGEDIT /S %%ifor %%i in (%TWK_DIR%\*.reg) do DEL %%iECHO.ECHO Building installation script ...for /d %%i in (%APP_DIR%\*.*) do type "%%i\%PACK_SCR%" >> %INSTALL_SCR%for /d %%i in (%UPD_DIR%\*.*) do type "%%i\%PACK_SCR%" >> %INSTALL_SCR%for /d %%i in (%DRV_DIR%\*.*) do type "%%i\%PACK_SCR%" >> %INSTALL_SCR%for /d %%i in (%MOD_DIR%\*.*) do type "%%i\%PACK_SCR%" >> %INSTALL_SCR%call %INSTALL_SCR%GOTO CLEANUP:CANCELECHO Package installation was canceled.GOTO CLEANUP:MISSING_INIECHO %SCR_VER% - ERROR!ECHO The specified INI does not exist.GOTO END:USAGEECHO %SCR_VER% - ERROR!ECHO You must specify the location of the INI file containing variables.ECHO.ECHO Syntax:ECHO ftp_ini.cmd [path to ini file]ECHO.ECHO Usage:ECHO ftp_ini.cmd z:\config\ftp_var.iniECHO.GOTO END:CLEANUPECHO.ECHO Cleaning up ...rd /s /q %TOP_DIR%SHUTDOWN -r -t 10:END
joebells Posted September 8, 2004 Posted September 8, 2004 edg21 you are the man (or woman perhaps) thanks for all these methods. I'm very appreciative.
joebells Posted September 10, 2004 Posted September 10, 2004 I'm getting ready to do this and I am going over it and I can't figure out how the script knows what PACK_EXT is I don't see a mention of it anywhere else. I will probably just go ahead and put static names in there I think unless I'm missing somethign or maybe just don't understand something about it? Really I don't quite understand any of the for %%i lines.
joebells Posted September 11, 2004 Posted September 11, 2004 hrrrrm I ran a test of ftp.cmd and it loops at the [Cancel FTP download? Y/N:] if I say n then it asks me for my username and password and ftp addy. and it keeps doing it if I say y then it cancels everything.
joebells Posted September 11, 2004 Posted September 11, 2004 I bypassed the ftp test by pointing it at the ftp_start command early on and it works ok until it tries to unrar the packages and then it just wasn't doing anything so I changed %PACK_EXT% to rar and it unpacks the files and makes the script ok. I of course took out the part where it would install for now.
edg21 Posted September 11, 2004 Author Posted September 11, 2004 I bypassed the ftp test by pointing it at the ftp_start command early on and it works ok until it tries to unrar the packages and then it just wasn't doing anything so I changed %PACK_EXT% to rar and it unpacks the files and makes the script ok. I of course took out the part where it would install for now.Sorry bout that, I posted my "in progress" version that lets you use something other than unrar.exe (pkunzip.exe or whatever you want). As far as the FTP_TEST section, it seems to be working fine here, try the code again, there could've been more problems with the version I had up.
edg21 Posted September 11, 2004 Author Posted September 11, 2004 what is EMD?haha I try and fix typos & just make more, must be the lack of sleep
evilvoice Posted September 11, 2004 Posted September 11, 2004 also, i really like this script...but I also wanna have the option of downloading from web, so, if you give me permission, im changing your ftp script to be used for web...so far Ive got it almost done, just need to set up the script WEB_SCR (im not very imaginative lol) for use with wget...other than that, I think ive got it down.
edg21 Posted September 11, 2004 Author Posted September 11, 2004 also, i really like this script...but I also wanna have the option of downloading from web, so, if you give me permission, im changing your ftp script to be used for web...so far Ive got it almost done, just need to set up the script WEB_SCR (im not very imaginative lol) for use with wget...other than that, I think ive got it down.I've been thinking about doing the same thing, you can probably add this with minor editing, I will edit the entire post to include this option. If you want to edit it feel free, just be sure to post what you come up with I just whipped this up after reading your post, so no guarantees :WEB_GETrem set variables for url listsset WEB_TOOL=http://bender/unattend/tools/url_list.txtset WEB_APP=http://bender/unattend/apps/url_list.txtset WEB_UPD=http://bender/unattend/updates/url_list.txtset WEB_DRV=http://bender/unattend/drivers/url_list.txtset WEB_MOD=http://bender/unattend/mod/url_list.txtrem downloading url listswget -P%TOOL_DIR% %WEB_TOOL%wget -P%APP_DIR% %WEB_APP%wget -P%UPD_DIR% %WEB_UPD%wget -P%DRV_DIR% %WEB_DRV%wget -P%MOD_DIR% %WEB_MOD%rem downoading packages from url listswget -P%TOOL_DIR% -i%TOOL_DIR%\url_list.txtwget -P%APP_DIR% -i%APP_DIR%\url_list.txtwget -P%APP_DIR% -i%UPD_DIR%\url_list.txtwget -P%APP_DIR% -i%DRV_DIR%\url_list.txtwget -P%APP_DIR% -i%MOD_DIR%\url_list.txt
evilvoice Posted September 11, 2004 Posted September 11, 2004 I did notice an error with ftp.cmd....you dont download the tools until after the script is done, so how can you run devcon in its location??
edg21 Posted September 11, 2004 Author Posted September 11, 2004 I did notice an error with ftp.cmd....you dont download the tools until after the script is done, so how can you run devcon in its location??Yep, you're right, that should be fixed now. I've been running it off a winPE cd to test and had devcon.exe in my path already
evilvoice Posted September 11, 2004 Posted September 11, 2004 well, this is what I have so far for the web...@ECHO OFFECHO.ECHO Setting variables ...:: SET VARIABLES TO REFLECT YOUR SETUPset PAK_DIR=unattendset TOP_DIR=%SYSTEMDRIVE%\installset WEB_SCR=%TOP_DIR%\WEB_SCR.CMDset INSTALL_SCR=%TOP_DIR%\install.cmdset PACK_SCR=commands.txtset TOOL_DIR=%WINDIR%\system32set APP_DIR=%TOP_DIR%\appsset UPD_DIR=%TOP_DIR%\updatesset TWK_DIR=%TOP_DIR%\tweaksset MOD_DIR=%TOP_DIR%\modsset DRV_DIR=%TOP_DIR%\drivers:: CREATING DIRECTORIES FOR PACKAGESECHO.ECHO Creating directories ...rem md %TOP_DIR%md %APP_DIR%md %UPD_DIR%md %TWK_DIR%md %DRV_DIR%md %MOD_DIR%:WEB_INPUTSET /P WEB_ADDY=[Web Address: (include http://)]ECHO.ECHO You specified:ECHO WEB Address: %WEB_ADDY%:WEB_CONFIRMECHO.SET /P WEB_CONF=[Is this correct? Y/N:]IF /I "%WEB_CONF%" == "Y" GOTO WEB_EXISTIF /I "%WEB_CONF%" == "N" GOTO WEB_INPUTGOTO WEB_CONFIRM::END WEB SERVER TESTING::BEGIN WEB SERVER TESTING:WEB_EXISTECHO ping web ... PING %WEB_ADDY% ¦ FIND "TTL" >NULIF ERRORLEVEL 0 GOTO WEB_STARTIF ERRORLEVEL 1 GOTO WEB_INPUT:WEB_CHOICEECHO.SET /P WEB_CANC=[Cancel WEB download? Y/N:]IF /I "%WEB_CANC%" == "Y" goto CANCELIF /I "%WEB_CANC%" == "N" goto WEB_INPUTGOTO WEB_CHOICE::BEGIN BUILDING WEB SCRIPT:WEB_STARTECHO Downloading TOOLS...wget -P%TOOL_DIR%\ %WEB_ADDY%/%PAK_DIR%/tools/url_list.txtwget -P%TOOL_DIR%\ -i%TOOL_DIR%\url_list.txtECHO Building WEB Script ...>%WEB_SCR% ECHO @ECHO OFF>>%WEB_SCR% ECHO wget -P%APP_DIR%\ %WEB_ADDY%/%PAK_DIR%/apps/url_list.txt>>%WEB_SCR% ECHO wget -P%UPD_DIR%\ %WEB_ADDY%/%PAK_DIR%/updates/url_list.txt>>%WEB_SCR% ECHO wget -P%TWK_DIR%\ %WEB_ADDY%/%PAK_DIR%/tweaks/url_list.txt>>%WEB_SCR% ECHO wget -P%MOD_DIR%\ %WEB_ADDY%/%PAK_DIR%/mods/url_list.txt>>%WEB_SCR% ECHO wget -P%DRV_DIR%\ %WEB_ADDY%/%PAK_DIR%/drivers/url_list.txt>>%WEB_SCR% ECHO wget -P%TOP_DIR%\ -i%APP_DIR%\url_list.txt>>%WEB_SCR% ECHO wget -P%TOP_DIR%\ -i%UPD_DIR%\url_list.txt>>%WEB_SCR% ECHO wget -P%TOP_DIR%\ -i%TWK_DIR%\url_list.txt>>%WEB_SCR% ECHO wget -P%TOP_DIR%\ -i%MOD_DIR%\url_list.txt>>%WEB_SCR% ECHO wget -P%TOP_DIR%\ -i%DRV_DIR%\url_list.txt:WEB_DONE>>%WEB_SCR% ECHO END::END BUILDING WEB SCRIPTECHO.ECHO Downloading per WEB_SCR.CMD ....CALL %WEB_SCR%ECHO. ECHO Extracting Packages ...for %%i in (%APP_DIR%\*.rar) do UNRAR x %%i %APP_DIR%for %%i in (%UPD_DIR%\*.rar) do UNRAR x %%i %UPD_DIR%for %%i in (%DRV_DIR%\*.rar) do UNRAR x %%i %DRV_DIR%for %%i in (%MOD_DIR%\*.rar) do UNRAR x %%i %MOD_DIR%for %%i in (%APP_DIR%\*.rar %UPD_DIR%\*.rar %DRV_DIR%\*.rar %MOD_DIR%\*.rar) do DEL %%iECHO.ECHO Applying various registry tweaks ...for %%i in (%TWK_DIR%\*.reg) do REGEDIT /S %%irem for %%i in (%TWK_DIR%\*.reg) do DEL %%iECHO.ECHO Building installation script ...for /d %%i in (%APP_DIR%\*.*) do type "%%i\%PACK_SCR%" >> %INSTALL_SCR%for /d %%i in (%UPD_DIR%\*.*) do type "%%i\%PACK_SCR%" >> %INSTALL_SCR%for /d %%i in (%DRV_DIR%\*.*) do type "%%i\%PACK_SCR%" >> %INSTALL_SCR%for /d %%i in (%MOD_DIR%\*.*) do type "%%i\%PACK_SCR%" >> %INSTALL_SCR%call %INSTALL_SCR%GOTO CLEANUP:CANCELECHO. Package installation was canceled.:CLEANUPECHO.ECHO Cleaning up ...rd /s /q %TOP_DIR%SHUTDOWN -r -t 10:ENDI didnt invlude devcon, cuz devcon doesnt even work for my pc...it finds both ati and nvidia, and actually, it doesnt even find my video card...its an all-in-wonder...and in devcon, it doesnt have ati in the name...so I dont know how useful devcon is gonna be in anyones case...
edg21 Posted September 11, 2004 Author Posted September 11, 2004 I didnt invlude devcon, cuz devcon doesnt even work for my pc...it finds both ati and nvidia, and actually, it doesnt even find my video card...its an all-in-wonder...and in devcon, it doesnt have ati in the name...so I dont know how useful devcon is gonna be in anyones case...I've only tested the devcon method on about 12 pcs... they all worked fine, but I dont doubt that it doesn't work on others. Nice work btw, once you're finished I will put it all together @ the top of the post. I'm currently trying to merge this script & another script I used to install XP from inside winPE & a method for WEB d/l would be great. I will go ahead and remove the devcon section for now until someone can tell me a reliable way to test for this.
evilvoice Posted September 11, 2004 Posted September 11, 2004 well, this is where i need your help or whoevers...as far as I can see, its now done...I did have to make some changes after posting, but to me, it looks complete...but, I dont know about the cleanup...and also, dont really know if it all flows (ie, if it will work, it should in theory...)...as for the cleanup, there might be some strangling url files somewhere...like in system32 dir...but other than that, I think its done...give it a test, I guess...I would test it, but I dont have a web server up yet....Also, another thing, if using runonceex, most people are gonna have $OEM$...so why not dump devcon and unrar in the system32 folder in there...$$\system32?
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now