Denney Posted March 21, 2006 Posted March 21, 2006 Here's one for you "pros".Current code:SET UUCDDRIVE=nocdFOR %%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 IF EXIST %%i:\UCD SET UUCDDRIVE=%%i:IF NOT "%UUCDDRIVE%"=="nocd" ( IF EXIST %UUCDDRIVE%\ALL XCOPY %UUCDDRIVE%\ALL %SystemDrive%\UOS /E /C /I /Q /H /Y IF EXIST %UUCDDRIVE%\PDC XCOPY %UUCDDRIVE%\PDC %SystemDrive%\UOS /E /C /I /Q /H /Y) ELSE ( ECHO. ECHO Ultimate Update CD not found. ECHO. PAUSE)ECHO is turned OFF at the start of this script. During execution, the XCOPY commands return the error:Current directory doesn't exist.And they don't copy the files over.Here's the thing, if I add an "ECHO ON" statement before the "IF" statement or if I don't turn ECHO off at all, it works flawlessly. I tried using CMDOW to hide the window during the "ECHO ON" time and it, again, ceased to work.It's got me stumped how an "XCOPY" command could require ECHO to be ON for it to work. Any thoughts?
Noise Posted March 21, 2006 Posted March 21, 2006 Surround your directory entries in quotes:IF EXIST "%UUCDDRIVE%\ALL" XCOPY "%UUCDDRIVE%\ALL" "%SystemDrive%\UOS" /E /C /I /Q /H /YThat's may not be the problem, but it's good practice. Try turning echo on right before the "if not" statement to debug.
Delprat Posted March 21, 2006 Posted March 21, 2006 (edited) You've found the Ultimate Bug This script will not show that error :SET UUCDDRIVE=FOR %%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 IF EXIST %%i:\UCD SET UUCDDRIVE=%%i:IF NOT DEFINED UUCDDRIVE ( ECHO. ECHO Ultimate Update CD not found. ECHO. PAUSE GOTO :THERE)CHDIR /D %SystemDrive%\MKDIR UOSCHDIR UOSXCOPY %UUCDDRIVE%\ALL . /E /C /I /Q /H /YIF EXIST %UUCDDRIVE%\PDC XCOPY %UUCDDRIVE%\PDC . /E /C /I /Q /H /Y:THERE Edited March 21, 2006 by Delprat
Denney Posted March 21, 2006 Author Posted March 21, 2006 (edited) Ok, so maybe you've fixed it but I'm more of the sorta person who wants to know WHY it doesn't work rather than what I have to do to fix it.Why was I getting that error?Oh, btw, the %SystemDrive%\UOS directory already exists on the hard drive when I copy the stuff over so the "MKDIR" command is pointless.Also, thanks for the quick response. Edited March 21, 2006 by RaveRod
Denney Posted March 21, 2006 Author Posted March 21, 2006 (edited) Ok, now that's weird.Changed my code to a mutation of yours for testing:SET UUCDDRIVE=nocdFOR %%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 IF EXIST %%i:\UCD SET UUCDDRIVE=%%i:IF "%UUCDDRIVE%"=="nocd" GOTO NOTFOUNDCHDIR /D %SystemDrive%\UOS\IF EXIST %UUCDDRIVE%\ALL XCOPY %UUCDDRIVE%\ALL %SystemDrive%\UOS /E /C /I /Q /H /YIF EXIST %UUCDDRIVE%\PDC XCOPY %UUCDDRIVE%\PDC . /E /C /I /Q /H /YPAUSEGOTO MORE:NOTFOUNDECHO.ECHO Ultimate Update CD not found.ECHO.PAUSE:MOREThat works perfectly. Note that one IF statement copied to "%SystemDrive%\UOS" and the other copies to ".". Both the IF statements works... It seems to pivot on that CHDIR command. Without it, the script dies. That I can't explain and I guess I only have Microsoft to thank for that error.Thanks for the fix Delprat. Much appreciated after my 4 hours of figuring nothing out.... Edit: Went back to my ORIGINAL code and added the "CHDIR /D %SystemDrive%\UOS\" command just before the "IF EXIST" command and it works perfectly! God damnit, all that wasted time when it was that simple! Anyway, thanks again for the help. Much appreciated. Edited March 21, 2006 by RaveRod
Delprat Posted March 22, 2006 Posted March 22, 2006 (edited) Why was I getting that error?That's the hard question...[edit: lots of stupid ideas based on wrong suppositions... ] Edited April 11, 2006 by Delprat
Denney Posted March 23, 2006 Author Posted March 23, 2006 Thanks for that code Delprat. Didn't even think about doing the for loop like that.Has the hidden advantage of letting me use 2 update cds in different drives without prompting.Thanks.
Delprat Posted March 23, 2006 Posted March 23, 2006 Has the hidden advantage of letting me use 2 update cds in different drives without prompting. The GOTO will break the loop after the first CD.
Denney Posted March 23, 2006 Author Posted March 23, 2006 (edited) Yeah I took that GOTO command out...Didn't mention that.Replaced it with a SET command and then after the loop has finished, I check if the variable is defined. If it is, I THEN use the GOTO command. Edited March 23, 2006 by RaveRod
IcemanND Posted March 24, 2006 Posted March 24, 2006 use CALL instead of GOTO and it will return.at the end of the called section send it to the EOF and it will return to the loop..........Call :UUCDFOUND):UUCDFOUNDcommandxcommandxgoto EOF...............:EOF
Guest Denney Posted April 11, 2006 Posted April 11, 2006 I FINALLY FIGURED IT OUT!!!At that point during setup, the "current directory" for the "cmd" prompt is "D:\$OEM$".The problem is, when you remove the CD and put another one in, the "$OEM$" directory doesn't exist so when you go to perform any operations, the error will come up.So after all of that, the "CHDIR" command IS required for the script to work properly when performing the FOR loop. It only just occured to me today what the problem was... :S
Delprat Posted April 11, 2006 Posted April 11, 2006 (edited) that issue is from good old dos...next time, i won't suppose anything about your knowledge before making suppositions Edited April 11, 2006 by Delprat
Guest Denney Posted April 11, 2006 Posted April 11, 2006 I've learnt never to assume anything about anyone around here. Especially when they've been around for awhile.I now have another couple of problems but they're with my coding and can be figured out pretty easily. Thankfully that biggest problem has now been sorted out.
Denney Posted April 12, 2006 Author Posted April 12, 2006 Another quick update...In some circumstances, adding the CHDIR %SomeDir% command won't work if it's on another drive. You need to add the /D switch to change the current drive as well as the current directory.Strange quirk in that it works sometimes but not others. So, the FINAL script is:CLSECHO Please insert an Ultimate Update CD now.PAUSEECHO ONCD /D %SystemDrive%CMDOW.EXE @ /HIDSET UUCDDRIVE=FOR %%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 IF EXIST %%i:\UUCD.cmd SET UUCDDRIVE=%%i:IF DEFINED UUCDDRIVE ( START /WAIT %UUCDDRIVE%\UUCD.cmd %UUCDDRIVE% %ADMINUSER%)CMDOW.EXE @ /VISECHO OFFCLSSET /P MORE="Do you have anymore Ultimate Update CD's (y/n)? "IF "%MORE%" == "y" GOTO STARTSEARCH
Delprat Posted April 12, 2006 Posted April 12, 2006 In some circumstances, adding the CHDIR %SomeDir% command won't work if it's on another drive. You need to add the /D switch to change the current drive as well as the current directory.Try "CHDIR /?" in the console START /WAIT %UUCDDRIVE%\UUCD.cmd %UUCDDRIVE% %ADMINUSER%Remove the first parameter (%UUCDDRIVE%), and in UUCD.cmd use %~d0 (instead of %1) to refer to the drive the UUCD.cmd file is in
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