Jump to content

Yzöwl

Patron
  • Posts

    4,113
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United Kingdom

Everything posted by Yzöwl

  1. Probably not but since I'm not aware of all of the formats I cannot be sure whether any add " [A|P]M" to the end!
  2. If you can guarantee that each delimiter is positioned in those exact locations within the time variable, for all languages/formats then I can see its merits!
  3. You could always use your script to do that for you! Example.cmd @ECHO OFF & SETLOCAL FOR /F "TOKENS=1-5 DELIMS=0123456789" %%A IN ("%TIME%") DO CALL :SUB %%A%%B%%C%%D%%E GOTO :EOF :SUB FOR /F "TOKENS=1-4 DELIMS=%1" %%A IN ("%TIME%") DO ( ECHO=SET "HH=%%A" SET "MM=%%B" SET "SS=%%C" SET "TH=%%D")
  4. Try this revision of your script with a few, (compared to jaclaz's version), changes: @echo off setlocal enableextensions cls :: Get the start time :: ------------------ call :GetTime StartHour StartMins StartSecs REM Use ping with [num] to create approx [num-1] running command ping -n 8 127.0.0.1 1>nul cls :: Get the finish time :: ------------------- call :GetTime StopHour StopMins StopSecs :: Calculate elapsed time :: ---------------------- call :Elapsed %StartHour% %StartMins% %StartSecs% %StopHour% %StopMins% ^ %StopSecs% Hours Minutes Seconds elsecs echo Hours=%hours% Minutes=%minutes% Seconds=%seconds% Elapsed secs=%elsecs% :: Display outcomes :: ---------------- echo.&echo.&echo.&echo.&echo. echo Start time = %StartHour%:%StartMins%:%StartSecs%. echo Stop time = %StopHour%:%StopMins%:%StopSecs%. echo. echo Elapsed seconds = %ElSecs% echo. echo Elapsed time = %Hours% hrs %Minutes% mins %Seconds% secs. endlocal goto :EOF :: Subs :: ---- :GetTime set vbs=%temp%\tmp.vbs ( echo ThisTime=Time echo WScript.Echo Hour(ThisTime^) ^&" "^& ^ Minute(ThisTime^) ^&" "^& ^ Second(ThisTime^) )>%vbs% for /f "tokens=1-3" %%a in ('cscript //nologo %vbs%') do ( set %1=%%a set %2=%%b set %3=%%c ) del %vbs% goto :EOF :Elapsed set /a ElapsedSecs=3600*%4+60*%5+%6-(3600*%1+60*%2+%3) if %ElapsedSecs% LSS 0 set /a ElapsedSecs=%ElapsedSecs%+(24*3600) set /a hh=(%ElapsedSecs%/3600) set /a mm=(%ElapsedSecs%/60)-60*%hh% set /a ss=%ElapsedSecs%-60*(%ElapsedSecs%/60) set "hh=10%hh%"&set "mm=10%mm%"&set "ss=10%ss%" set %7=%hh:~-2%&set %8=%mm:~-2%&set %9=%ss:~-2% SHIFT set "%9=%ElapsedSecs%" goto :EOF
  5. What's wrong with using SHIFT in that position? @ECHO OFF SETLOCAL ENABLEEXTENSIONS CALL :SubName input1 input2 input3 input4 input5 output1 output2 output3 output4 output5 PAUSE GOTO :EOF :SubName ECHO=[%6], [%7], [%8], [%9] SHIFT ECHO=[%9]The last line echo's parameter 10 as parameter 9.
  6. Using Windows Command Script Example.cmd @ECHO OFF&SETLOCAL (SET H_=) FOR /F %%# IN ('HOSTNAME') DO (SET H_=%%#) IF DEFINED H_ (NET USE O: \\%H_:~,7%AB\folder$)
  7. Saved as a bookmark for a couple of years and used up until a day or so ago, what happened to http://www.mse360.com/ fantastic search engine?
  8. Your if is bad written because you don't have good parenthesis. You need make every command go inside one set of parenthesis, but that doesn't matter, because you ignore my posts, so I am wasting my time telling you. Good luck figuring it out. IF EXIST "D:\1.EXE" (START "" /WAIT "D:\1.EXE" "C:\2.EXE") Well I disagree here, the code you've quoted was mine and was given because it was believed to be correct for the task which was intended. It appears from that example that C:\2.exe is intended to be run regardless of whether or not %CDROM%\1.exe exists, (it is found on both sides of the ELSE statement). For that reason the parentheses are closed correctly.
  9. Within a Command Prompt Window: FOR /F "TOKENS=*" %# IN (C:\PCLIST.TXT) DO @UPTIME.EXE %#
  10. Outbreaker, please be careful not to push my wrong buttons! I produced in answer to a very specific problem you had a code snippet, this was completely my work and was exactly the solution you required. You have created a distributable script based around my code, and it's fair to say that you could not have done so without that code. You did not really credit me in the topic, which I ended up having to close because of your actions. Now you have the cheek to tell me that it was my responsibility to credit myself and then you expect me to further fix the rest of the code you've included!
  11. For now I'm going to comment only on three things! You do not need to use the $OEM$ structure in order to add to the StartUp Directory. There are some errors in your batch files. I really do not appreciate the fact that you took some of my exclusive code, (that which I'd already informed you was not available elsewhere), used it against my advice, ruined it, made it freely available and didn't even bother offering credit. (in a way I'm glad because you've spoiled my efforts so much I'd be embarrassed to have my name along side it.)
  12. My suggestion would be that you provide that script in order that we have the opportunity to fix, adjust accordingly or rewrite it.
  13. Would you like to clarify this statement! Outbreaker, you appear to be asking many questions on these boards, this is not a problem, however you provide very little, incorrect or no information to the Members in order for them to help you. Then once they provide a response you reply nagatively towards it, saying you cannot do it or it doesn't work. Please play the game, provide us with correct details of what you are doing/have done and the percentage rate of potential positive solutions will increase accordingly; Thank you!
  14. Actually if you look they are not my instructions at all, it is the exact same structure you posted last time, (which I corrected), the only difference is that you've changed 'Autowpi.exe' for '1.exe', 'application.exe' for '2.exe' and 'SHUTDOWN -r -t 0' for '2.exe'.Looking at what you've posted I'm assuming that this will do the same thing: IF EXIST "%CDROM%\1.EXE" (START "" /WAIT "%CDROM%\1.EXE") "C:\2.EXE" In order for that and the other examples we've given you to work you need to ensure that you have defined the %CDROM% variable; (maestrodellaves has previously given you one way to do so).
  15. My guess is that they want to create a calculator type application using Visual Basic 2008. The problem is that they have no idea how to do it so they want someone else to start them off! I'm feeling especially generous today so think of it as your birthday.
  16. I would doubt that it is given your new remit, not only can it's usefulness be impacted by the host OS, the major reason for it was due to the fact you stipulated CD-ROM drive, without that stipulation I'd not have ever suggested it. I'm fairly certain that the mistake you made was not in the Topic Title, but in the method you employed to get others to perform for you. Topic Closed!
  17. Okay, I'm starting to get tired of this now! Outbreaker, you asked for, in both the Title of this Topic and the first post, a solution specifically for a problem with files on CD-ROMS. It appears to me that people have made an effort to provide you with solutions to match your request and all you have done is change their scripts to do something else and give your critique on them. For example, the script above has taken a unique piece of code I produced for you, (I would go as far as to say that the method I used will very likely have not appeared anywhere else on the web), and ruined it. My first response in the Topic actually gives you what you've got around to requesting later on, it simply used a variable named %CDROM% and name CD-ROM, when it checked all drives not just optical ones! Please ask for a soluion and accept its responses; if the solution doesn't work as is that's fair enough but do not change it, badly, to do something completely different and then criticize it. By the way, I see no reason to have my script altered in order to change the default message of 'No Instance(s) Available' for your preferred text string 'File Not Found'. If you wish to use a script for something else either start a New Topic or politely request that the Topic Title is change to suit the new parameters and thank/apologise to those who have thus far helped with the previous remit.
  18. I would suggest that you post exactly the content of your version of someone elses script before claiming that it doesn't work. What about the two versions I posted, do they not work?
  19. This should do as you requested: @ECHO OFF&SETLOCAL (SET IF_=PATHTO\SOME NAME.EXT) (SET IS_=%%MYOWNCHARACTERS%%) (SET LN_=347) FOR %%# IN (IF LN) DO IF NOT DEFINED %%#_ GOTO :EOF IF NOT EXIST "%IF_%" GOTO :EOF FOR %%# IN ("%IF_%") DO (SET OF_=%%~dpn#_NEW%%~x#) TYPE NUL>"%OF_%" (SET/A PL_=LN_-1) MORE +%PL_% "%IF_%"|FINDSTR/VG:"/" "%IF_%">>"%OF_%" ECHO=^<DATA Type="xsd::string"^>%IS_%^</DATA^>>>"%OF_%" MORE +%LN_% "%IF_%">>"%OF_%" Just change: Line 2 to the input file name Line 3 to the characters you wish to insert. (remembering to escape any 'poison' characters) Line 4 to the line number you're wishing to add your text to. Line 11 any further changes to the existing lines text. (once again remembering to escape any 'poison' characters)
  20. You think that's being clever… Nobody mentioned WMIC! @ECHO OFF&SETLOCAL ENABLEEXTENSIONS (SET CDROM=) FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%# IN (`WMIC DATAFILE WHERE^ "FSNAME='CDFS' AND PATH='\\OEM\\RUNONCE\\' AND FILENAME='AUTO SETUP' AND EXTENSION='BAT'"^ GET Name /VALUE^|FIND "="`) DO SET "CDROM=%%~d#"&SET "FPATH=%%#" IF NOT DEFINED CDROM GOTO :EOF REM PUT YOUR COMMANDS BENEATH HERE ECHO=%%CDROM%%=%CDROM% CALL "%FPATH%"
  21. This would be my suggestion, (although the cdrom variable isn't guaranteed to be a CD-ROM). bat_file.cmd @ECHO OFF SETLOCAL (SET CDROM=) (SET MYBAT=OEM\RunOnce\Auto Setup.bat) FOR /F %%# IN ('MOUNTVOL^|FINDSTR [C-Z]:\\') DO CALL :SUB %%# IF NOT DEFINED CDROM ECHO=Correct CD-ROM Drive not found! GOTO :EOF :SUB (SET CDROM=%1) IF EXIST "%CDROM%%MYBAT%" CALL "%CDROM%%MYBAT%"<Edit /> Fixed
  22. As already mentioned, either provide the full correct and actual batch file you wish to be searched or don't expect a working solution. The only suggestion I can make from the extremely poor examples you've provided is to search for and change any lines containing XY. As you can understand removing lines from a file which contain a string of two characters is not what I'd consider safe, especially as we haven't seen the entire file. This is what I mean! findstr/vc:" XY." /c:"\XY." yourbat.cmd>yournewbat.cmd If your next response doesn't provide us with the information we've requested, I will close this topic!
  23. All you need to do then is navigate to the folder first! CD /D X:\PathTo\FolderWithFilesIn DEL file1.ext file4.ext file7.ext
  24. Also, you'll note that you've made no provision for the fact that it would be good practice to verify whether Winamp or AIMP are installed first. (or at the very least check that the AIMP and Winamp directories exist in %ProgramFiles%.) If they aren't there then it would be pointless creating folder structures and placing files there!
  25. I'd suggest you don't confuse your script with concatenation!I would also suppose that using an if else is not required, by rebooting on failure as your first command, the two other commands wouldn't run anyhow IF NOT EXIST %CDROM%\Autowpi.exe SHUTDOWN -r -d p:4:2 -t 0 %CDROM%\Autowpi.exe %SYSTEMDRIVE%\application.exeIf for some reason the commands start running before the supposedly immediate reboot, you could add START /WAIT before SHUTDOWN!
×
×
  • Create New...