derickmoore Posted October 11, 2010 Share Posted October 11, 2010 I learned a good deal over this last weekend, and I want to share it. Nothing I will write can't be found with a good deal of searching, but it is so rarely mentioned, that I can't find it again on Monday morning.I wanted to set up Hiren's boot CD on a USB stick, add PortableApps, and make the stick useful to a new user. In particular, I wanted to lead the new user through the steps needed to modify settings to put the screen in a higher resolution, unlock the taskbar, start network support, access OpenOfficeWriter, and go online with FireFox.I started with the goal of putting a 'Push Button' on the desktop and command (.CMD) files to do the behind the scene work.Quickly I learned that:The stick is not location aware, and will have different drive letters on different PCs.Environmental Variables are not 'stickey'Desktop Icons will not be retained from boot to bootShortcuts cannot be pre-configured, because they are drive letter sensitiveand, that getting the drive letter can be tricky if you don't already know howI'm tempted to put the files here, but will try to trim the content to the bare essentials instead.In XpAutoRun.CMD in the HBCD subdir, I added this:@echo offif "%~d0"=="C:" set drv=C:\if "%~d0"=="D:" set drv=D:\if "%~d0"=="E:" set drv=E:\if "%~d0"=="F:" set drv=F:\%drv%util\shortcut /f:"b:\Documents and Settings\Default User\Desktop\pushme.lnk" /a:c /t:"%drv%\util\pushme.cmd" /d:"Push Button" /i:x:\i386\system32\shell32.dll,27The first five lines shouldn't require explanation beyond the '%~d0' stuff. I can't find an explanation anyplace, but I did find the information on line. It appears that %~d0 is something like an environmental variable, and it will contain the drive letter of the boot source drive. If anyone can explain where that value comes from, I'm curious to know the origin.When I find out the drive letter, I set the environment variable drv (%drv%) to that drive letter plus the backslash.Then the last line runs the program 'Shortcut.exe' with the parameters necessary to find 'Pushme.cmd' in the 'util' subdir of the stick and create a link on the desktop. Find 'shortcut.exe' on the web, and check its /? dump for the particulars.PUSHME.CMD uses a different method to find the drive letter. This is a little more conventional! (Keep in mind that the %drv% is gone when you finally push the button)@echo offIF EXIST C:\UTIL\PUSHME.CMD GOTO SETCIF EXIST D:\UTIL\PUSHME.CMD GOTO SETDIF EXIST E:\UTIL\PUSHME.CMD GOTO SETEIF EXIST F:\UTIL\PUSHME.CMD GOTO SETFECHO Error in finding the USB stickpauseGOTO FINAL:SETCSET USB=C:\GOTO FINI:SETDSET USB=D:\GOTO FINI:SETESET USB=E:\GOTO FINI:SETFSET USB=F:\GOTO FINI:FINICALL %USB%UTIL\SETSCRN.CMD:FINALIt looks for itself in a specific path location, and sets the USB (%USB%) variable before CALLing another .CMD file. I could have put the rest of the commands here, but this demonstrates that you have to CALL the next steps in the sequence rather than simply execute them, because the variable will be lost when the program closes. (I also separated it to make modifications more modular)The next .CMD file prints instructions for unlocking the taskbar, setting screen resolution and pauses while the user follow those instructions.Then I invoke StartPortableApps.exe and PeNetwork.exe, place icons on the desktop for FireFox and OpenOfficeWriter and delete the Push Button.%USB%StartPortableApps.exex:\i386\system32\penetwork.exe%USB%util\shortcut /f:"B:\Documents and Settings\Default User\Desktop\OpenOfficeWriterPortable.lnk" /a:c /t:"%USB%PortableApps\OpenOfficePortable\OpenOfficeWriterPortable.exe" /d:"Portable Writer"%USB%util\shortcut /f:"B:\Documents and Settings\Default User\Application Data\Microsoft\Internet Explorer\Quick Launch\OpenOfficeWriterPortable.lnk" /a:c /t:"%USB%PortableApps\OpenOfficePortable\OpenOfficeWriterPortable.exe" /d:"Portable Writer"%USB%util\shortcut /f:"B:\Documents and Settings\Default User\Desktop\FireFoxPortable.lnk" /a:c /t:"%USB%PortableApps\FireFoxPortable\FireFoxPortable.exe" /d:"Portable FireFox"%USB%util\shortcut /f:"B:\Documents and Settings\Default User\Application Data\Microsoft\Internet Explorer\Quick Launch\FireFoxPortable.lnk" /a:c /t:"%USB%PortableApps\FireFoxPortable\FireFoxPortable.exe" /d:"Portable FireFox"del "b:\Documents and Settings\Default User\Desktop\pushme.lnk"The system is now ready for use.I set this up for a novice user, but now that I have a handle on how to do it, I'm using it for myself too. It now has my favorite editor (Mansfields Kedit) and other icons on the desktop.Derick Moore Link to comment Share on other sites More sharing options...
derickmoore Posted October 11, 2010 Author Share Posted October 11, 2010 By the way, I'm aware that I could have done this:set USB=%~d0or this:%~d0\util\setscrn.cmdbut, I wanted to 'show your steps' like the math teacher used to say!Derick Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now