December 24, 200421 yr Once again I am requesting help for my batch file... all of this wouldn't happen if I had a computer BEFORE Windows 95 got out. All I want is the code to get the current year to my RunOnceEx title. I've been searching on the net and I found some variable like DATE/T and TIME/T but I'm stuck.This is what I want:REG ADD %KEY% /V TITLE /D "IT Departement %YEAR%" /fso this way, I wouldn't have to care to update the year in all my batch files.
December 24, 200421 yr well this is what i use on my programs.cmd, hope it helps...SET %TIME%=TIME /TECHO.ECHO.ECHO [ Estableciendo Variable "CDROM" ]FOR %%d 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 %%d\$OEM$\BioHaZaRD.nfo SET CDROM=%%dECHO Unidad %CDROM%, %TIME%ECHO.ECHO Instalando AveDesk 1.1 (En), %TIME%ECHO Por favor espera.....
December 24, 200421 yr Author Sort off... I'd like to trim the result to only display the yearwith your command I get:2005 21:44:48,84
December 24, 200421 yr i dunno how you're getting that, but if that's what's in variable %TIME%doSET YEAR = %TIME:~0,3%Will take characters 1 - 4 (2005) and save them in %YEAR%
December 24, 200421 yr Author Ah crap! 2005 was the text already present in my title! What I get with:SET %TIME%=TIME /TIS21:44:48,84
December 24, 200421 yr @Alanoll didn't know about that...@Incroyable HULK so your code must look like...forget about it Edited December 24, 200421 yr by SiMoNsAyS
December 24, 200421 yr Author If I use your code:SET %YEAR%=DATE /T:~0,3%REG ADD %KEY% /V TITLE /D "Service Informatique %YEAR%"/fI don't get anything returned!
December 24, 200421 yr try thisset YEAR=%DATE:~-4%%DATE% on my system isThu 12/23/2004and after the above SET command I getecho %YEAR%2004:~-4 gets the last 4 digits.Also remember SET %YEAR%=is NOT proper syntax. should beSET YEAR=Then to use YEAR you put the %'s on either side. Edited December 24, 200421 yr by Alanoll
December 24, 200421 yr Author I get this:2-23 I need the first 4 caracters not the last one...But this will give different results if the regional setting are set differently...Is there a way to get it for sure? Independent from the configurationEDIT: it works on my system with this code:set YEAR=%DATE:~0,4%
December 24, 200421 yr Author Yep! I edited my previous post... before I noticed there was a second page in my thread Anyway, it seems to me like a "dirty hack" because it won't work on all systems... depending on the date format in the regional settings
December 24, 200421 yr do you plan on servicing any that are set to US region?Everywhere else I believe uses the same. GO AMERICANS (US ones anyway)But that's the only DATE i know of on the system, without using VBS or something to get it directly form the system.
December 24, 200421 yr This Is What This Code Producesecho offcls color F8mode con: Cols=55 Lines=3Title What Year Is ItSET YEAR=%date:~10,10%echo.set /p = The Year Is %YEAR%Re-Edit Both Work Here@echo offcls color F2mode con: Cols=55 Lines=4Title What Year Is It Test 2SET YEAR=%date:~-4,10%echo.@echo The Year Is %YEAR%pause Edited October 26, 200520 yr by gunsmokingman
December 24, 200421 yr This is different for every system. It depends on the language and short date settings. %DATE% returns 24-12-04 on my system So a batch file isn't the best way to get the year from a system. After a little bit of searching I found that this returns the year in a VBS file:DatePart("yyyy", Date)But I don't know if it bothers you to set the title from the vbs file, and do the rest from the batch file, or if you want to pass the year from the vbs file to the batch file, and set it from there, or whatever
Create an account or sign in to comment