Halfwalker Posted January 13, 2006 Posted January 13, 2006 OK, I've had a couple of very late working nights, so I must be missing something painfully obvious here ... In my install script, I have the following chunk at the end ...for /D %%i in (*) do ( %%i\installit.cmd %%~ni %DIR%%%i %KEY% if exist "%DIR%%%i\finishup.cmd" REG ADD %KEY%\%%~ni /V 99 /D "%DIR%%%i\finishup.cmd %DIR%%%i" if exist "%DIR%%%i\Application.html" copy /y "%DIR%%%i\Application.html" "%systemroot%\Config\%%i.html")echo "OK - all done"pause%DIR% and %KEY% are both set higher up. The problem is that it never reaches the "OK - All done" echo statement. I see the last copy command just fine, and then the batchfile just ends. It doesn't do the expected Pause to hit any key, just returns to the prompt.I know it's going to be a forehead slapper, but I don't see it just now through my blurred vision ...D.
boggen Posted January 13, 2006 Posted January 13, 2006 for a in b do (either -1 or + 1 or >< something in the last loop is causing it to hang. you could be trying to run past the array. perhaps not starting at 0 in array. instead the for loop is starting at one in arrary and when it attempts to read last part of array its not there because you didn't start at 0.it could be last %dir% that you have set ealier is feeding a directory name that is to long in amount of characters or directory name is long name format and not 8.3 format.
Yzöwl Posted January 13, 2006 Posted January 13, 2006 for /D %%i in (*) do ( %%i\installit.cmd %%~ni %DIR%%%i %KEY%<snip>Lets take the above:If* = F:\Softwareand contains three subfolders namedProgram1, Program2, Program3i.e.F:\Software\Program1, F:\Software\Program2, F:\Software\Program3thenfor each directory in F:\Software do ( Program1\installit.cmd Program1 %DIR%Program1 %KEY% Program2\installit.cmd Program2 %DIR%Program2 %KEY% Program3\installit.cmd Program3 %DIR%Program3 %KEY%I'm guessing this is not what you want, so please explain your requirements!
IcemanND Posted January 13, 2006 Posted January 13, 2006 well that little snippet seems to work as expected if I run it on my machine. Try putting a pause statement inside of the loop and immediatley following for testing purposes as see if that gives a better clue as to what is going on.
gunsmokingman Posted January 14, 2006 Posted January 14, 2006 Try this vbs script Save As CheckAndCopy.VBSConst OverWriteExiting = True this a varible that cannot be change threw the script, this over write the existing file in the target locationDim Var1, Var2Varible1 = "YOUR_WHAT_EVER_HERE"Varible2 = "YOUR_WHAT_EVER_HERE"This is like the set in cmd promt.You are declairing the varibles for the script here.These can be any name you want. They can be almost any thing you want.Set Fso = CreateObject("Scripting.FileSystemObject")Set Act = CreateObject("Wscript.Shell")These are object that the script uses, they act like cmd promt various cmdseg copy, delete etcNote : For Every If there has to be a End If If Fso.FolderExists("YOUR_WHAT_EVER_HERE") Then This checks for the file or folder exists this is where the script run it cmd if trueElse Act.Popup "Error Missing File Or Folder", 7,"Error Missing", 0 + 32This is what the script does if it falseAct.Popup "Completed The Copy Of" & vbcrlf & "YOUR_WHAT_EVER_HERE", 7,"Completed Copy", 0 + 32This is a timed messagebox made with the Act objectFso.CopyFile ("YOUR_WHAT_EVER_HERE") , ("YOUR_WHAT_EVER_HERE") , OverwriteExistingFso.CopyFolder ("YOUR_WHAT_EVER_HERE") , ("YOUR_WHAT_EVER_HERE"), OverwriteExistingThe Copy Cmd for The Script Const OverWriteExiting = TrueDim Var1, Var2, Act, FsoVar1 = "YOUR_WHAT_EVER_HERE"Var2 = "YOUR_WHAT_EVER_HERE"Set Fso = CreateObject("Scripting.FileSystemObject")Set Act = CreateObject("Wscript.Shell")'''''''''''''''''''COPY A FILEIf Fso.FileExists("YOUR_WHAT_EVER_HERE") Then'''''''''''''''''''''''''''''''START LOCATION '''''''''''''''''END LOCATIONFso.CopyFile ("YOUR_WHAT_EVER_HERE") , ("YOUR_WHAT_EVER_HERE") , OverwriteExistingAct.Popup "Completed The Copy Of" & vbcrlf & "YOUR_WHAT_EVER_HERE", 7,"Completed Copy", 0 + 32Else Act.Popup "Error Missing File Or Folder", 7,"Error Missing", 0 + 32End If '''''''''''''''''''COPY A FOLDERIf Fso.FolderExists("YOUR_WHAT_EVER_HERE") Then '''''''''''''''''''''''''''''''START LOCATION '''''''''''''''''END LOCATIONFso.CopyFolder ("YOUR_WHAT_EVER_HERE") , ("YOUR_WHAT_EVER_HERE"), OverwriteExistingAct.Popup "Completed The Copy Of" & vbcrlf & "YOUR_WHAT_EVER_HERE", 7,"Completed Copy", 0 + 32Else Act.Popup "Error Missing File Or Folder", 7,"Error Missing", 0 + 32End If
Halfwalker Posted January 28, 2006 Author Posted January 28, 2006 for /D %%i in (*) do ( %%i\installit.cmd %%~ni %DIR%%%i %KEY%<snip>Lets take the above:If* = F:\Softwareand contains three subfolders namedProgram1, Program2, Program3i.e.F:\Software\Program1, F:\Software\Program2, F:\Software\Program3thenfor each directory in F:\Software do ( Program1\installit.cmd Program1 %DIR%Program1 %KEY% Program2\installit.cmd Program2 %DIR%Program2 %KEY% Program3\installit.cmd Program3 %DIR%Program3 %KEY%I'm guessing this is not what you want, so please explain your requirements!That's exactly what I want Each directory has a standard installit.cmd that takes 3 parameters. The directories are numbered, as in 205.Program1, 210.Program2, 215.Program3 and so on. That lets me reorder the installation just by renumbering the directories. For example, for 210.FolderShare, installit.cmd contains :@echo offset NUM=%1set DIR=%2set KEY=%3REG ADD %KEY%\%NUM% /VE /D "FolderShare v2.5.10" /fREG ADD %KEY%\%NUM% /V 1 /D "%DIR%\FolderShareSetup-2.5.10.msi ALLUSERS=2 /qb-" /f%DIR% is set further up in the batchfile to the Apps dir on the CD, which results in two keys being added to RunOnceEx :....\RunOnceEx\210 -> FolderShare v2.5.10....\RunOnceEx\210\1 -> d:\apps\FolderShareSetup-2.5.10.msi ALLUSERS=2 /qb-If there was a finishup.cmd there, it would have looked like this :....\RunOnceEx\210 -> FolderShare v2.5.10....\RunOnceEx\210\1 -> d:\apps\210.FolderShare\FolderShareSetup-2.5.10.msi ALLUSERS=2 /qb-....\RunOnceEx\210\99 -> d:\apps\210.FolderShare\finishup.cmdEverything works as expected, except for the final statements after the loop. I actually do a reg export there to check things out, but that never got executed, which led me to check more, which led to putting in the pause etc, which never gets hit.Hrm ...D.
IcemanND Posted February 3, 2006 Posted February 3, 2006 (edited) I must have been sleeping the last time I posted.Add CALL to the installit.cmd line. (see below) That way it calls the cmd file and returns, otherwise it closes the one and continues on in installit.cmd until it finishes and it's done.for /D %%i in (*) do ( CALL %%i\installit.cmd %%~ni %DIR%%%i %KEY% if exist "%DIR%%%i\finishup.cmd" REG ADD %KEY%\%%~ni /V 99 /D "%DIR%%%i\finishup.cmd %DIR%%%i" if exist "%DIR%%%i\Application.html" copy /y "%DIR%%%i\Application.html" "%systemroot%\Config\%%i.html")echo "OK - all done"pause Edited February 3, 2006 by IcemanND
Yzöwl Posted February 3, 2006 Posted February 3, 2006 The call command was what I was trying to explain in my cryptic response previously, I quoted only that line of the batch file and spelled out what it did.However the response was:That's exactly what I want Without the call, control would not be passed back to the invoking script, after running any installit.cmd.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now