gunsmokingman Posted March 8, 2006 Share Posted March 8, 2006 (edited) Mhz no you are wrong because these if statement are the checks, please read the script before making incorrect statements.This is to check if the disks has any thing in itIf strDrive.IsReady = True ThenThis is to check to see if it a CD or DVD driveIf strDrive.DriveType = 4 ThenThis is to check that it the correct path and fileIf Fso.FileExists(strDrive.DriveLetter & Cmd1) Then this will run only if the 3 if statements are true, this would be the CD Or DVD drive letterstrDrive.DriveLetterAct.Run(strDrive.DriveLetter & Cmd1 & " /qb /norestart"),1,TrueThe script will only work if that statement is true, this is better then using a send key method as this is not the best method to do this. Now if I took out the first 2 if statements then it would search for strDrive.DriveLetter & Cmd1 on your floppy drive, harddrive, cd or dvd drive. This builds the completed path to the file,which the action uses. Edited March 8, 2006 by gunsmokingman Link to comment Share on other sites More sharing options...
Yzöwl Posted March 8, 2006 Share Posted March 8, 2006 Here's a TEE like method which doesn't require 3rd party programs, it uses VBS!Set StdIn = WScript.StdInSet StdOut = WScript.StdOutSet Args=WScript.ArgumentsLogFile=Args(0)Set fso = CreateObject("Scripting.FileSystemObject")Set LogFile= fso.CreateTextFile(Args(0))Do While Not StdIn.AtEndOfStream str = StdIn.ReadLine StdOut.WriteLine str LogFile.WriteLine strLoopLogFile.CloseRun your Batch file with a pipe to the filter executed with CSCRIPT and add the logfile name you require as a parameter.Something like this:MyBatchFile.cmd |cscript//nologo TFILTER.VBS MyLogFile.txtThe output of the Batch file is displayed line-by-line and simultaneously captured to MyLogFile.txt line-by-line.If you change the VBS line: LogFile.WriteLine strto LogFile.WriteLine "Line " & (StdIn.Line - 1) & ": " & strthis will number all the lines in the log (but not on screen).Note: You must execute the TFILTER.VBS with CSCRIPT and not WSCRIPT, (STDIN and STDOUT are not available via WSCRIPT). Link to comment Share on other sites More sharing options...
jaclaz Posted March 8, 2006 Share Posted March 8, 2006 Here's a TEE like method which doesn't require 3rd party programs, it uses VBS!Yep, but it is also possible by using a "pure" .BAT, see my previously posted link:http://www.robvanderwoude.com/tee.htmlTEE.BAT, Version 2.01 for Windows NT 4 / 2000 / XP@ECHO OFF:: Check Windows versionIF NOT "%OS%"=="Windows_NT" GOTO Syntax:: Keep variables localSETLOCAL:: Check command line argumentsSET Append=0IF /I [%1]==[-a] (SET Append=1SHIFT)IF [%1]==[] GOTO SyntaxIF NOT [%2]==[] GOTO Syntax:: Test for invalid wildcardsSET Counter=0FOR /F %%A IN ('DIR /A /B %1 2^>NUL') DO CALL :Count "%%~fA"IF %Counter% GTR 1 (SET Counter=GOTO Syntax):: A valid filename seems to have been specifiedSET File=%1:: Check if a directory with the specified name existsDIR /AD %File% >NUL 2>NULIF NOT ERRORLEVEL 1 (SET File=GOTO Syntax):: Specify /Y switch for Windows 2000 / XP COPY commandSET Y=VER ¦ FIND "Windows NT" > NULIF ERRORLEVEL 1 SET Y=/Y:: Flush existing file or create new one if -a wasn't specifiedIF %Append%==0 (COPY %Y% NUL %File% > NUL 2>&1):: Actual TEEFOR /F "tokens=1* delims=]" %%A IN ('FIND /N /V ""') DO (> CON ECHO.%%B>> %File% ECHO.%%B):: DoneENDLOCALGOTO:EOF:CountSET /A Counter += 1SET File=%1GOTO:EOF:SyntaxECHO.ECHO Tee.bat, Version 2.10 for Windows NT 4 / 2000 / XPECHO Display text on screen and redirect it to a file simultaneouslyECHO.ECHO Usage: some_command ³ TEE.BAT [ -a ] filenameECHO.ECHO Where: "some_command" is the command whose output should be redirectedECHO "filename" is the file the output should be redirected toECHO -a appends the output of the command to the file,ECHO rather than overwriting the fileECHO.ECHO Written by Rob van der WoudeECHO http://www.robvanderwoude.comECHO Modified by Kees CouprieECHO http://kees.couprie.orgECHO and Andrew Cameron Of course it can be simplified and included in the same "main" batch file....jaclaz Link to comment Share on other sites More sharing options...
har-vas Posted March 11, 2006 Author Share Posted March 11, 2006 Hi again. First of all, thank you all for your ideas. Now I will stop dealing with my unattended CD (3 weeks of full work is enough) and I will restart the improvements at my next format. But I thought as a proper act to give my feedback:To Gunsmokingman: I was ready to test your solution, but finally I didn't, because I saw a simpler method posted by MHz. I see that you know very well to code in vbs and write more precise scripts (with more checks, better error catching etc), but personally I am in the beginning of the road so I prefer to go step-by-step. I will keep your posts as a reference and maybe I will re-bother you for an explanation.To MHz: With your help, I finally made possible to have all my programs being executed from the CD. Your code has worked excellent. I understood that the problem was with what the script was considering as the current directory. These 5 lines fixed my .vbs. Thank you.To Jaclaz: Finally, with this version of tee command, I managed to have it worked. Thanks for the link. I used your syntax and the log file was being created, having inside of it all the screen's output. But another problem came up. The error messages or (more precisely) the stderr stream is not being logged. I see only the standard output. At this moment, I don't remember if the stderr was being showed on the screen, but I think no. Maybe this command filters all the input it takes and gives as the final output (duplicated in the screen and the file) only the stdout stream. But this is not exactly what I need. I want a log file with the full output of my script including any errors. Is it possible to improve the code in the tee.bat so the stderr stream is also being logged?To Yzowl: I have also tried your solution, but with the same results as above (again, I don't remember if the stderr was being showed on the screen). Any error messages are hidden (the counting of the lines is very cool though). It would be very useful if you added to your .vbs support for the stderr stream (at least in the log file). Link to comment Share on other sites More sharing options...
gunsmokingman Posted March 11, 2006 Share Posted March 11, 2006 That good and congrates to your successfull scripting.Here is a link to a place that taught me alot about VBSscripting. The Hey, Scripting Guy!Here is a link so you can read more about the send key method.SendKeys Method Link to comment Share on other sites More sharing options...
jaclaz Posted March 11, 2006 Share Posted March 11, 2006 (edited) Another few (semi-random) ideas:http://www.teaser.fr/~amajorel/stderr/http://www.faqs.org/faqs/msdos-programmer-...section-11.htmlhttp://www.codeproject.com/dialog/quickwin.aspWouldn't something similar to this work?:@Echo OFFdel myboth.txt >nulSET NEXTCOMMAND=VOLFOR %%A in (c d e f g h i j k l m n o p q r s t u v x y z) Do (ECHO %NEXTCOMMAND% %%A: >>MYBOTH.TXT%NEXTCOMMAND% %%A: >>MYBOTH.TXT 2>&1)FOR /F "tokens=1* delims=" %%A in (MYBOTH.TXT) DO ECHO %%Aor this:@Echo OFFdel myboth.txt >nulSET NEXTCOMMAND=VOLFOR %%A in (c d e f g h i j k l m n o p q r s t u v x y z) Do (ECHO %NEXTCOMMAND% %%A: >MYBOTH.TXT%NEXTCOMMAND% %%A: >>MYBOTH.TXT 2>&1type myboth.txt)In the above example I am using the VOL command on all letters as if the drive letter exist, the otput is STDOUT, otherwise it is STDERR...jaclaz Edited March 11, 2006 by jaclaz 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