Incroyable HULK Posted December 24, 2004 Share Posted December 24, 2004 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. Link to comment Share on other sites More sharing options...
SiMoNsAyS Posted December 24, 2004 Share Posted December 24, 2004 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..... Link to comment Share on other sites More sharing options...
Incroyable HULK Posted December 24, 2004 Author Share Posted December 24, 2004 Sort off... I'd like to trim the result to only display the yearwith your command I get:2005 21:44:48,84 Link to comment Share on other sites More sharing options...
Alanoll Posted December 24, 2004 Share Posted December 24, 2004 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% Link to comment Share on other sites More sharing options...
Incroyable HULK Posted December 24, 2004 Author Share Posted December 24, 2004 Ah crap! 2005 was the text already present in my title! What I get with:SET %TIME%=TIME /TIS21:44:48,84 Link to comment Share on other sites More sharing options...
Incroyable HULK Posted December 24, 2004 Author Share Posted December 24, 2004 If I go with:SET DATE = %DATE:~0,3%I get:2004-12-23 Link to comment Share on other sites More sharing options...
SiMoNsAyS Posted December 24, 2004 Share Posted December 24, 2004 (edited) @Alanoll didn't know about that...@Incroyable HULK so your code must look like...forget about it Edited December 24, 2004 by SiMoNsAyS Link to comment Share on other sites More sharing options...
Incroyable HULK Posted December 24, 2004 Author Share Posted December 24, 2004 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! Link to comment Share on other sites More sharing options...
Alanoll Posted December 24, 2004 Share Posted December 24, 2004 (edited) 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, 2004 by Alanoll Link to comment Share on other sites More sharing options...
Incroyable HULK Posted December 24, 2004 Author Share Posted December 24, 2004 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% Link to comment Share on other sites More sharing options...
Alanoll Posted December 24, 2004 Share Posted December 24, 2004 so useSET YEAR=%DATE:~0,3% Link to comment Share on other sites More sharing options...
Incroyable HULK Posted December 24, 2004 Author Share Posted December 24, 2004 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 Link to comment Share on other sites More sharing options...
Alanoll Posted December 24, 2004 Share Posted December 24, 2004 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. Link to comment Share on other sites More sharing options...
gunsmokingman Posted December 24, 2004 Share Posted December 24, 2004 (edited) 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, 2005 by gunsmokingman Link to comment Share on other sites More sharing options...
Tsunami Posted December 24, 2004 Share Posted December 24, 2004 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 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