coucou Posted July 3, 2005 Share Posted July 3, 2005 Hi,TNX for this thread, I red it very carefully because i'm very concerned by.DarkShadowsEven more critical is something that could happen if you have more than one CD-ROM drive (which I do). Because the code you posted searches all drives, it will also search my second CD drive that I do not have CD in. At which time Windows will generate a dialog with a message stating that media is not ready in the drive (or something like that). I personally find this problematic. You describe exactly my problem. I tried many advises for a while without success.I've 2CDCD-ROM and I'm using a UA/WPI (WinXP+Appz) DVD. When I run it, after the WinXP install and restart, i got an error message: "'Windows No Disk' 'There is no disk in the drive. [Cancel] [Try Again] [Continue]" . I've to click 2 or 3 times on [Continue] then WPI started from the DVD.Here my winnt.sif command [GuiRunOnce]%systemdrive%\install\wpi\wpi.cmd@Yzöwl: I'm not a coder and don't want making mistakes. May you please help me merging @echo off&Mode 55,3&Color f2&Title Script By YzOwlfor %%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 ( fsutil fsinfo volumeinfo %%a:|find "UWXPCD">nul 2>&1&&echo Your specified drive is -^> %%a:\)ping -n 4 127.0.0.1>nul&goto :eofto my wpi.cmd here enclosed??? Regardscoucou Link to comment Share on other sites More sharing options...
Yzöwl Posted July 3, 2005 Share Posted July 3, 2005 (edited) @ coucouAll you need to do is use the template I've already posted!Example just put everything, (from your file), betweenecho Found CD-Rom as drive %CDROM%andexitin the appropriate place.<Edit>Alternatively, if you don't want to use the 'label' method, below is the template for 'CD loaded' method@echo off&setlocal enableextensions&call :findriveif '%CDROM%' equ '' echo/CD-ROM not found&ping -n 4 127.0.0.1>nul&goto endit:: put your commands below here (%CDROM% variable is set):: do not add or replace anything below heregoto :endit:findrivefor /f "tokens=1,2 delims=\ " %%a in ('fsutil fsinfo drives^|find /v "Drives"') do call :findcd %%agoto :eof:findcdfsutil fsinfo volumeinfo %1|find "CDFS">nul 2>&1&&set CDROM=%1&goto :eof:enditendlocal&goto :eofRemember it's still only for XP and above</Edit> Edited July 3, 2005 by Yzöwl Link to comment Share on other sites More sharing options...
coucou Posted July 4, 2005 Share Posted July 4, 2005 TNX YzOwl for the advise.May you let me know if the script bellow is correct???@echo off&Mode 55,3&Color f2&Title Script By YzOwlfor %%i 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 (fsutil fsinfo volumeinfo %%i:|find "UWXPCD">nul 2>&1&&echo Your specified drive is -^> %%i:\)ping -n 4 127.0.0.1>nul&goto :eofset CDROM=%%i:REM Determine the WPI startup path. REM if wpi should run off the cd the replace %~dp0 with %cdrom%.set wpipath=%cdrom%\Software\WPIREM Force resolution to needed size for wpi interface.start %wpipath%\common\VideoChanger.exe 1024x768x32@85 -qREM Hide this command window."%wpipath%\common\cmdow.exe" @ /hidREM Font installation - the smooth and customizable way.start /wait %wpipath%\common\fonts\fontinstaller.exeREM Special registry tweak needed.regedit /s "%wpipath%\common\wpi.reg"REM Make WPI directory the current directory.for /f "delims=: tokens=1" %%i in ("%wpipath%") do %%i:cd "%wpipath%"REM Start WPI and wait for its endstart /wait WPI.htaREM Cleaning up the desktop.del /s/q "%userprofile%\desktop\*.lnk"REM Rebooting the sytem to finalize the installation process.--shutdown.exe -r -f -t 20 -c "Reboot in 10 sec..."exit:endRegardscoucou Link to comment Share on other sites More sharing options...
Yzöwl Posted July 4, 2005 Share Posted July 4, 2005 (edited) Firstly, you haven't used either of the templates I posted!Secondly, some of the commands you are adding are incorrect.Thirdly, my own preference, lose all the comment lines, (i.e those starting with REM).<Edit>First of all let me apologize to readers of this thread for answering an off topic question here.Here is an idea of how I would use the template@echo off&setlocal enableextensions:: enter your CD label below e.g. set lab=UWXPCD (case insensitive)set lab=call :findrive:: put your commands below here (%CDROM% variable is set)pushd %CDROM%\Software\WPI\commoncmdow.exe @ /hidstart VideoChanger.exe 1024x768x32@85 -qstart /wait fonts\fontinstaller.exeregedit /s wpi.regcd..start /wait WPI.htapopddel /s/q "%userprofile%\desktop\*.lnk"shutdown.exe -r -f -t 20 -c "Reboot in 20 sec...":: do not add or replace anything below hereendlocal&goto :eof:findriveset drv=c d e f g h i j k l m n o p q r s t u v w x y zfor %%a in (%drv%) do (fsutil fsinfo volumeinfo %%a:|find /i "%lab%">nul 2>&1&&set CDROM=%%a:)goto :eof</Edit> Edited July 4, 2005 by Yzöwl Link to comment Share on other sites More sharing options...
coucou Posted July 4, 2005 Share Posted July 4, 2005 (edited) Apologies to all readers of this thread too and sorry to pollute it... i'm not a coder although i try hardly.Many TNX Yzöwl and sorry for bothering you.Regardscoucou Edited July 4, 2005 by coucou Link to comment Share on other sites More sharing options...
JoeMSFN Posted July 8, 2005 Share Posted July 8, 2005 (edited) I Apologize for the slight off topicness of this, but Since noone berated Yzöwl for his most excellent explanation of redirects, I figured I'd contribute... As far as redirects, I've read that 0> is equivalent to | (aka the pipe symbol).Anyone heard of this?<{POST_SNAPBACK}> Edited July 8, 2005 by JoeMSFN Link to comment Share on other sites More sharing options...
Delprat Posted July 8, 2005 Share Posted July 8, 2005 '0>' seems like a joke :'1>' or '>' redirects STDOUT of preceding command to following file/port'2>' redirects STDERR of preceding command to following file/port'1>>' or '>>' appends STDOUT of preceding command to following file'2>>' appends STDERR of preceding command to following file'<' redirects following file/port to STDIN of preceding command' | ' redirects STDOUT of preceding command to STDIN of following commandWhat is obvious is that the '>' and '>>' redirectors does execute only the preceding command ; where ' | ' redirector execute both preceding and following command.And if you specify any number other than '1' or '2' before '>' or '>>', you get "access disallowed" ("accès refusé" in french) error...You didn't test before posting that, did you ??? Link to comment Share on other sites More sharing options...
dwit Posted July 8, 2005 Share Posted July 8, 2005 MSDOC>>Utilites>>Batch Filescheck out this site Link to comment Share on other sites More sharing options...
Doc Symbiosis Posted July 11, 2005 Share Posted July 11, 2005 (edited) Don't know, if anyone needs this, but you can use parametres in batch script with %1,%2,...( %1 for first, %2 for second,.....parameter). So if you have the file test.cmd:@echo offecho %2 %1exitand call through command line:"test.cmd there hello" it will output "hello there"It's a useless example, but just to point out, how it works. With this you can get more variable batch files, for example the name of the CD or the file on CD, you're looking for. Edited July 12, 2005 by Doc Symbiosis Link to comment Share on other sites More sharing options...
Doc Symbiosis Posted July 12, 2005 Share Posted July 12, 2005 Great work DarkShadows.But after some time I played with the scripts, I couldn't figure out, how to get the first free drive letter.Only can get a list of all free drives with the following script:@echo offfor %%a in (a b 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 ( fsutil fsinfo drivetype %%a:|find "No such Root Directory">nul 2>&1&&echo/%%a:)pause&goto :eofThanks in advance. Link to comment Share on other sites More sharing options...
DarkShadows Posted July 12, 2005 Author Share Posted July 12, 2005 (edited) Great work DarkShadows. But after some time I played with the scripts, I couldn't figure out, how to get the first free drive letter. Only can get a list of all free drives with the following script::Start @Echo Off Setlocal enableextensions enabledelayedexpansion:SetVars Call :FreeDrvL:Logic :: Place your script command logic between :Logic and :End :: (The %FreeDrvL% variable is set to your first available drive letter) CLS Echo. Echo %%FreeDrvL%% = %FreeDrvL% Echo. Pause:End EndLocal Goto :EOF :: Only place called functions below this comment. Do NOT place an Exit :: command anywhere in this script, if you plan to call it from :: other batch scripts. Doing so will kill the parent script!:FreeDrvL Set SearchString="Error: The system cannot find the path specified." For %%L 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 {!FreeDrvL!}=={} fsutil fsinfo volumeinfo %%L:|Find /I %SearchString%> Nul 2>&1&&Set FreeDrvL=%%L: ) Set SearchString= Goto :EOF:Notes:: 1. This script is for WINDOWS XP ONLY! The command "fsutil" is only:: supported in Windows XP or later.:::: 2. The "Setlocal enableextensions" command in the :Start section, is not:: required, unless you have explicitly disabled command extensions:: somewhere in: your Windows registry, Cmd.exe call, or a Setlocal:: command in a parent command batch script calling this batch script.:: Command extensions are enabled by default in Windows XP. Therefore,:: if you haven't made any of the above mentioned changes, you can delete:: "enableextensions" from the Setlocal command, and this script will work.:::: 3. The "Setlocal enabledelayedexpansion" command in the :Start section:: is STRICTLY REQUIRED; it enables the !VariableName! expansion method.:: This method allows code to check the dynamic status of an environmental:: variable from within a For-In-Do loop. The %VariableName% method only:: checks the value once just before execution. Therefore if you change:: a variable from within a For-In-Do loop, !VariableName! will ALWAYS:: pick up it's current value; however, %VariableName% will ONLY pick up:: what the value was BEFORE the For-In-Do loop began.Or this:Method B::Start @Echo Off Setlocal enableextensions:SetVars Call :FreeDrvL:Logic :: Place your command batch script logic between :Logic and :End :: At this point, The %FreeDrvL% variable has been set to your first :: unused available drive letter. CLS Echo. Echo First Free Drive Letter = %%FreeDrvL%% = %FreeDrvL% Echo. Pause:End EndLocal Goto :EOF :: Only place called functions below this comment. Do NOT place an Exit :: command anywhere in this script, if you plan to call it from other :: batch scripts, doing so will exit the parent script as well!:FreeDrvL Set SearchString="Error: The system cannot find the path specified." For %%L 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 NOT Defined FreeDrvL ( fsutil fsinfo volumeinfo %%L:|Find /I %SearchString%> Nul 2>&1&&Set FreeDrvL=%%L: ) ) Set SearchString= Goto :EOF:Notes:: 1. This script is for WINDOWS XP ONLY! The command "fsutil" is only:: supported in Windows XP or later.:::: 2. The "Setlocal enableextensions" command in the :Start section, and the:: corresponding "Endlocal" command in the :End section aren't strictly:: required, unless you have explicitly disabled command extensions:: somewhere in: your Windows registry, Cmd.exe call, or a Setlocal:: command in a parent command batch script calling this batch script.:: Command extensions are enabled by default in Windows XP. Therefore,:: if you haven't made any of the above mentioned changes, you can delete:: these Setlocal and EndLocal commands, and this script will still work.<Edits on 2005-07-13>• Touched up Method A (and labled it Method A)• Added Method B (inspired by Yzöwl's work below)• Added FindFreeDriveLetter.zip download of both files.Differences Between Method B and Yzöwl's work below1) I've presented it in my command batch script template style2) I use volumeinfo whereas Yzöwl's code uses drivetype3) I have eliminated the need for the "Call :Check" and the :Check Label altogether in the code. This allows us to use just one label to self-contain the function. I do not intend to take anything away from Yzöwl's contribution, I merely mean to add value to it.Differences Between Method A and Method B1) Method A requires delayed variable expansion Method B (like Yzöwl's code below) does not.</Edits on 2005-07-13>WARNING: This code is only for Windows XPFindFreeDriveLetter.zip Edited July 13, 2005 by DarkShadows Link to comment Share on other sites More sharing options...
Yzöwl Posted July 12, 2005 Share Posted July 12, 2005 (edited) @ Doc SymbiosisAnother method@echo off&setlocal enableextensionsfor %%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 ( fsutil fsinfo drivetype %%a:|find "No such Root Directory">nul 2>&1&&call :check %%a:):: put your commands below here %drvlet% is set:: exampleecho/%drvlet%endlocal&goto :eof:checkif not defined drvlet set drvlet=%1&goto :eofI have started at C: since I'm fairly sure you aren't wanting A: or B:<Edit>Usual stuff about only for XP and newer</Edit> Edited July 12, 2005 by Yzöwl Link to comment Share on other sites More sharing options...
gunsmokingman Posted July 13, 2005 Share Posted July 13, 2005 Here Are Two One Long Line Cmd That Make A Basic Ua Work Area For Either A CDROM Install Of The Apps , Or Harddrive Install Of The Apps, After XP Is Installed. CDROM Install Ua Work AreaEcho Off && CLS && Mode 55,4 && Color 5e && Title Gsm MKUaDirForCD_Intall && Mkdir %SystemDrive%\XPCD %SystemDrive%\XPCD\Apps %SystemDrive%\XPCD\$OEM$ %SystemDrive%\XPCD\$OEM$\$$ %SystemDrive%\XPCD\$OEM$\$$\Fonts %SystemDrive%\XPCD\$OEM$\$$\Media %SystemDrive%\XPCD\$OEM$\$$\Resources %SystemDrive%\XPCD\$OEM$\$$\Resources\Themes %SystemDrive%\XPCD\$OEM$\$$\System32 %SystemDrive%\XPCD\$OEM$\$$\Web %SystemDrive%\XPCD\$OEM$\$$\Web\Wallpaper %SystemDrive%\XPCD\$OEM$\$1 %SystemDrive%\XPCD\$OEM$\$1\Drivers %SystemDrive%\XPCD\$OEM$\$1\Drivers\002_graphics %SystemDrive%\XPCD\$OEM$\$1\Drivers\004_sound %SystemDrive%\XPCD\$OEM$\$Docs "%SystemDrive%\XPCD\$OEM$\$Docs\All Users" "%SystemDrive%\XPCD\$OEM$\$Docs\All Users\Start Menu" "%SystemDrive%\XPCD\$OEM$\$Docs\All Users\Start Menu\Programs" %SystemDrive%\XPCD\$OEM$\$ProgsHard Drive Install Ua Work AreaEcho Off && CLS && Mode 55,4 && Color 5e && Title Gsm MKUaDirForHD_Intall && Mkdir %SystemDrive%\XPCD %SystemDrive%\XPCD\$OEM$ %SystemDrive%\XPCD\$OEM$\$$ %SystemDrive%\XPCD\$OEM$\$$\Fonts %SystemDrive%\XPCD\$OEM$\$$\Media %SystemDrive%\XPCD\$OEM$\$$\Resources %SystemDrive%\XPCD\$OEM$\$$\Resources\Themes %SystemDrive%\XPCD\$OEM$\$$\System32 %SystemDrive%\XPCD\$OEM$\$$\Web %SystemDrive%\XPCD\$OEM$\$$\Web\Wallpaper %SystemDrive%\XPCD\$OEM$\$1 %SystemDrive%\XPCD\$OEM$\$1\Drivers %SystemDrive%\XPCD\$OEM$\$1\Drivers\002_graphics %SystemDrive%\XPCD\$OEM$\$1\Drivers\004_sound %SystemDrive%\XPCD\$OEM$\$1\Install %SystemDrive%\XPCD\$OEM$\$Docs "%SystemDrive%\XPCD\$OEM$\$Docs\All Users" "%SystemDrive%\XPCD\$OEM$\$Docs\All Users\Start Menu" "%SystemDrive%\XPCD\$OEM$\$Docs\All Users\Start Menu\Programs" %SystemDrive%\XPCD\$OEM$\$Progs Link to comment Share on other sites More sharing options...
Doc Symbiosis Posted July 18, 2005 Share Posted July 18, 2005 @Yzöwl: At first very much thanks for the script to detect the first free drive letter. Works fine. Only thing is, that I wonder, were the variable %drvlet% comes from, because it isn't mentioned in the script before. Why does it have the right value? Link to comment Share on other sites More sharing options...
DarkShadows Posted July 19, 2005 Author Share Posted July 19, 2005 (edited) @Yzöwl: At first very much thanks for the script to detect the first free drive letter. Works fine. Only thing is, that I wonder, were the variable %drvlet% comes from, because it isn't mentioned in the script before. Why does it have the right value?<{POST_SNAPBACK}>Look closer at his code, it comes from the Set command in the IF condition::checkif not defined drvlet set drvlet=%1&goto :eof Edited September 30, 2005 by DarkShadows 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