evilvoice Posted July 18, 2004 Share Posted July 18, 2004 here is a batch, it is not mine, but I did change a little thing...first, this is only for 2k/xp instead of the whole batch consisting of 98/nt/2k/xp. I also have it set instead of all cdroms, to the first one it finds...this means that if youre not using the master cdrom drive to install or whatever, then you need to change this...it came from http://www.robvanderwoude.com/amb_cdrom.html@ECHO OFF:: For Windows 2000:W2KSETLOCALSET CDROMS=SET Temp1=%Temp%.\%~n0%Random%1.regSET Temp2=%Temp%.\%~n0%Random%2.regSTART /WAIT REGEDIT /E %Temp1% "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices"TYPE %Temp1% > %Temp2%TYPE %Temp2% | FIND "\\DosDevices\\" | FIND /V "\\DosDevices\\A:" | FIND "=hex:5c," > %Temp1%FOR /F "tokens=3 delims=\:" %%A IN (%Temp1%) DO CALL :ParseW2K %%ASET CDROMSDEL %Temp1%DEL %Temp2%ENDLOCAL & SET CDROMS=%CDROMS:~0,2%GOTO:EOF:ParseW2KIF DEFINED CDROMS (SET CDROMS=%CDROMS%,%1:) ELSE (SET CDROMS=%1:)GOTO:EOFsee where I use %CDROMS:~0,2%, if youre not using the first cdrom, change it accordingly. Link to comment Share on other sites More sharing options...
Guest zippy Posted July 19, 2004 Share Posted July 19, 2004 I'm glad that so many people find this useful. I use it a lot after cyberdiamond told how/why a month ago.When some noob like me posting a newbie question on this board, what we got is only a reply "Do a search". Why dont you?Another method leanred from sleepnmojo "%~d0" and "%~dp0" refers to current drive/directory where your cmd file is when it been called from cd. It's also useful on cmd files on cd when called from RunOnceEx/GuiRunOnce.\$OEM$\RunOnceEx.cmd:...REG ADD %KEY%\050 /V 1 /D "%CD%\install\MSN.cmd" /f...\$OEM$\install\MSN.cmd:@ECHO OFFcmdow @ /HIDCD /D "%~dp0"START /WAIT msiexec /I MsnMsgs.msi /QBSTART /WAIT regedit /s .\MSN.regEXITWe sometimes put application install cmd file on cd. Some additional command needs current working directory to be on the same drive/directory for some .ini/.cfg.CD /D "%~dp0" will chage drive/directory to there.That's what my last post said. %CD%, %0, SourcePath...etc... depends on how/where you use it...Dont put "jealous" or something on me. I'm noob & nobody.DarkPhoenix's post on this thread, that's sharing, told us how/why he do this. Link to comment Share on other sites More sharing options...
tim Posted July 19, 2004 Author Share Posted July 19, 2004 it came from http://www.robvanderwoude.com/amb_cdrom.htmlI actually worked this out for myself, I didn't rip it off from anywhere.I spent ages playing with VBScript and BAT/CMD files before I came across this solution to my problem.BTW thanks for the nice comments everyone. Link to comment Share on other sites More sharing options...
sleepnmojo Posted July 19, 2004 Share Posted July 19, 2004 it came from http://www.robvanderwoude.com/amb_cdrom.htmlI've never seen anything done like that. Thats is just plain awesome. Over the top, but awesome. Link to comment Share on other sites More sharing options...
CoffeeFiend Posted July 19, 2004 Share Posted July 19, 2004 There has been a couple methods listed already but neither work for me.I use GUIRunOnce for a main installer script that launches more scripts. Using GUIRunOnce, the first method won't work, and somehow, the other method in this thread doesn't return the right drive for me... So even if it might work sometimes, I don't trust it, and to be honest, I never thought of doing it that way.There is a much simpler way. Have a unique file on your CD, and look for it:@echo offfor %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\path\to\yourfile.xyz set CDROM=%%a(where \path\to\yourfile.xyz is the path to your uniquely named file called yourfile.xyz or whatever it might be, with no drive letter of course)I GUIRunOnce to start command.cmd, after that, command.cmd uses that code to find the CD Rom drive letter, and starts %CDROM\whatever.cmd that does the installs directly from the CD (Actually, a DVD-R but that's besides the point). Simple to do and works reliably at every stage.Might not be news to most people, some people might like other methods better, it might have been posted 150x before... But anyways. I hope it helps someone... Just "contributing" hoping to make someone else's life easier. Link to comment Share on other sites More sharing options...
evilvoice Posted July 20, 2004 Share Posted July 20, 2004 you say rip off, i say whatever...use yours, but it was pointed out as to certain times when yours would not work...but whatever...PS i think a rip off has to do with me stealing something...as I listed the site, I dont think that constitutes stealing...I just posted what i had because if you have 2-3 cdrom drives, as I do, then youll need to make some changes so it only finds the first one...If you think I stole your idea...try again...I can even show you how long ago I found out how to do this...but believe what you wantIf you didnt mean to come off as an a**, you should choose your wording better. Link to comment Share on other sites More sharing options...
GreenMachine Posted July 20, 2004 Share Posted July 20, 2004 Can I play, too?FOR /F "TOKENS=3" %%I IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "SourcePath" ^| FINDSTR "SourcePath"') DO SET INSTALLCD=%%~dI Link to comment Share on other sites More sharing options...
bookie Posted August 6, 2004 Share Posted August 6, 2004 Thanx for this hint.Any idea, how you can achieve this with 98 ??thxMarkus Link to comment Share on other sites More sharing options...
cyberdiamond Posted August 7, 2004 Share Posted August 7, 2004 I'm glad that so many people find this useful. I use it a lot after cyberdiamond told how/why a month ago.Glad I could help As many have realised there are a lot of different ways to get the same result.Use whatever your comfortable with or whatever you understand best.I always use what I can understand as come trouble shooting time (it will happen) you will know whats going on and will be better able to pinpoint the problem! Link to comment Share on other sites More sharing options...
expert01 Posted August 7, 2004 Share Posted August 7, 2004 Would there be a way to search for \i386\winnt.exe on all drives (until it's found) and use that drive as the CD drive? Link to comment Share on other sites More sharing options...
mazin Posted August 7, 2004 Share Posted August 7, 2004 Would there be a way to search for \i386\winnt.exe on all drives (until it's found) and use that drive as the CD drive?In this case, you need the classical method:if exist D:\i386\winnt.exe set CDROM=D:..if exist Z:\i386\winnt.exe set CDROM=Z: Link to comment Share on other sites More sharing options...
DarkPhoenix Posted August 7, 2004 Share Posted August 7, 2004 Would there be a way to search for \i386\winnt.exe on all drives (until it's found) and use that drive as the CD drive?In this case, you need the classical method:if exist D:\i386\winnt.exe set CDROM=D:..if exist Z:\i386\winnt.exe set CDROM=Z: Nah, crahak's idea is better:for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\i386\winnt.exe set CDROM=%%a Link to comment Share on other sites More sharing options...
mazin Posted August 7, 2004 Share Posted August 7, 2004 Nah, crahak's idea is better:for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\i386\winnt.exe set CDROM=%%aAlright Sir! NP! Link to comment Share on other sites More sharing options...
CoffeeFiend Posted August 9, 2004 Share Posted August 9, 2004 Yes, it work in any scenario, but just a note, I did an error while copy/pasting. It should have been:for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if exist %%a:\i386\winnt.exe set CDROM=%%a:(With a : at the end)That way your CDRom letter is say, J: istead of J ... You get the idea anyways. If you don't want to search thru all these drives, just remove the ones you don't want but eithe way it's pretty quick and never fails me. You could make it look for win51ip.SP2 or winnt.sif or whatever too...I use that to launch my main installing script from a a directory full of installers (not located in $OEM$ at all). I just don't see a point of copying the installers to the HD first during the setup phase like lots of guys seem to do. Also, I much rather have one big script that launches the installers, adds registry entries, and launches more "sub"-scripts to tweak the installation instead of other methods. Some people seem too see GUIRunOnce as a n00b method, I just see it as more versatile and better adapted for my needs... Link to comment Share on other sites More sharing options...
OCedHrt Posted August 9, 2004 Share Posted August 9, 2004 I'll join too Finally got this working.FOR /F "skip=2 delims=\ usebackq" %I IN (`FIND "dospath" %SystemRoot%\SYSTEM32\$WINNT$.INF`) DO SET %IThe above sets the env variable dospath to the installation drive.Here %I is the entire dospath=cddrive: which is convenient for set What I use in my batch file is:FOR /F "eol=\ skip=2 delims=\= tokens=2 usebackq" %%I IN (`FIND "%1" %SystemRoot%\SYSTEM32\$WINNT$.INF`) DO %%I\$OEM$\Files\$OEM$.exe -y /q /r:n -o"%SystemRoot%\Driver Cache"This one only returns "letter:" for %IAnd the great thing is, this runs at T-39 Thanks to zippy's post in another thread that helped me finally figure out how to get batch files to work at T-39Batches files have to be started with cmd.exe with the swiches /C START filename.bat. I used %1 for the find to pass as an argument, but I doubt that does anything special.I haven't tried with cmd so don't know if that works. /C START is very important. just cmd.exe /C filename.bat may work in a command prompt but it doesn't work during setup.Also, from my experiences the batch file is necessary. I've been trying to do it without any intermediate files at all for 12+ hours straight :/ The arguments assignment in winnt.sif won't take more than 1 set of quotes so FIND can't be used there. If anyone figures this out please let me know. 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