Martin Zugec Posted December 30, 2004 Share Posted December 30, 2004 Hi! I read through articles at msfn.org (btw GREAT work). I am working as deployment consultant and I think I could help/improve few things... For example RunOnceEx from CD - U dont need to search cd.txt, U can use WMI (WMIC) to find the cd drive... For example this "script" will make the job:wmic cdrom where "VolumeName='0006'" get drive /value > temp.txtFOR /F "usebackq tokens=2 delims==" %i IN (`type temp.txt`) DO echo %i > temp.txtset /p test1= < temp.txt Link to comment Share on other sites More sharing options...
blinkdt Posted December 30, 2004 Share Posted December 30, 2004 OK, I found further reading about WMI HERE, but I'm not a programmer. Can you provide a real-life example of how this script would be implemented to initialize RunOnceEX from CD? Real tutorial-type leg bone connected to the hip bone stuff for dumb-dumb heads. Link to comment Share on other sites More sharing options...
Martin Zugec Posted December 30, 2004 Author Share Posted December 30, 2004 Wmic is EXTREMELY powerfull command-line utility, that provides access to WMI classes without knowing about programming. I made presentation about it for Microsoft few weeks ago So this is script to find the letter of cddrive, where boot cd is inside...wmic cdrom where "VolumeName='XPSP2'" get drive /value > cddrive.txtthis command will find the cdrom drive, where is media named XPSP2. Then it will same the drive letter to file cddrive.txt (it will looks like Drive=D:)FOR /F "usebackq tokens=2 delims==" %i IN (`type cddrive.txt`) DO echo %i > drive.txtThis line will open the file, pick up X: part and save it to same file again.set /p cddrive= < cddrive.txtthis last drive will input the cddrive letter do variable cddrive... Link to comment Share on other sites More sharing options...
MHz Posted December 30, 2004 Share Posted December 30, 2004 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:\WIN51 set CDROM=%%a:Here is plain batch, without the need to make a temp file. Link to comment Share on other sites More sharing options...
Incroyable HULK Posted December 30, 2004 Share Posted December 30, 2004 I preffer MHz method. It works great in Win2K, WinXP and the code is reusable with all my versions since I am looking for CD.bin which is present on all of my CD. The method you suggested is checking for the CD label which is different on every CD.I like it when my Unattended OS are updated the same way. One less thing to worry about. I can copy/paste my code from one another without having to care about fancy details Link to comment Share on other sites More sharing options...
DLF Posted December 30, 2004 Share Posted December 30, 2004 @SoulinBit hit and miss asking it for a Vol descriptor! Surely better to look for the ident file which should be omni-present. Link to comment Share on other sites More sharing options...
ankap Posted December 31, 2004 Share Posted December 31, 2004 Look this ThreadThis not only gets CD letter but ejects CD then loads it checks for correct CD and runs specified command from CD.Any questions? Link to comment Share on other sites More sharing options...
jjvs Posted June 22, 2005 Share Posted June 22, 2005 Hello,Yesterday I've found a new way to determine the cdrom drive letter during installation. It's quite simple and less typing. Replace in the RunOnceEx.cmd (or any other batchfile) the following: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:\WIN51 set CDROM=%%a:withset CDROM=%~d0Now a little explanation for "%~d0"%0 (zero) is a variable which contains the filename being executed. With the "~ + a letter" you can retrieve several details about the executed file and ~d will retrieve the drive letter. Since RunOnceEx.cmd in on the CD, it returns your cdrom driveletter (assigned during installation).Here is a little batchfile to show you what you can do with it:@echo offecho This script will show several (hopefully) interresting things of the echo variable %%0 echo.echo Command executed (%%0) : %0echo Directories (%%~p0): %~p0echo Drive (%%~d0): %~d0echo Filename (no ext.) (%%~n0): %~n0echo Extension (%%~x0): %~x0echo Full path + filename (%%~f0): %~f0echo Modification time (file) (%%~t0): %~t0echo Filesize (%%~t0): %~t0pausePut this in a batchfile and execute it. copy/move it to another directory (and/or drive) to see how it's effect. rename it and execute it again. This method cannot determine you cdrom driveletter when the batchfile is not stored on you CD. More info can be found in the help of the FOR command (for /?)It works on Win XP (Pro). I don't know about other OS'es.I hope you can do something with it. Link to comment Share on other sites More sharing options...
jjvs Posted June 22, 2005 Share Posted June 22, 2005 Sorrythe line:echo Filesize (%%~t0): %~t0should be:echo Filesize (%%~z0): %~z0 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