Jump to content

Source drive identification for bootable USB


derickmoore

Recommended Posts

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 boot

Shortcuts cannot be pre-configured, because they are drive letter sensitive

and, that getting the drive letter can be tricky if you don't already know how

I'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 off

if "%~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,27

The 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 off

IF EXIST C:\UTIL\PUSHME.CMD GOTO SETC

IF EXIST D:\UTIL\PUSHME.CMD GOTO SETD

IF EXIST E:\UTIL\PUSHME.CMD GOTO SETE

IF EXIST F:\UTIL\PUSHME.CMD GOTO SETF

ECHO Error in finding the USB stick

pause

GOTO FINAL

:SETC

SET USB=C:\

GOTO FINI

:SETD

SET USB=D:\

GOTO FINI

:SETE

SET USB=E:\

GOTO FINI

:SETF

SET USB=F:\

GOTO FINI

:FINI

CALL %USB%UTIL\SETSCRN.CMD

:FINAL

It 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.exe

x:\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


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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...