Nologic Posted December 24, 2004 Share Posted December 24, 2004 Well if you use AutoIt you have these available to you -@SEC Seconds value of clock. Range is 00 to 59@MIN Minutes value of clock. Range is 00 to 59@HOUR Hours value of clock in 24-hour format. Range is 00 to 23@MDAY Current day of month. Range is 01 to 31@MON Current month. Range is 01 to 12@YEAR Current four-digit year @WDAY Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday.@YDAY Current day of year. Range is 1 to 366 (or 365 if not a leap year) Link to comment Share on other sites More sharing options...
Incroyable HULK Posted December 24, 2004 Author Share Posted December 24, 2004 Well thank's guys... AutoIT and VBS would be great solutions but the problem is that I am compiling my .cmd into .exe@gunsmokingmanIf I use your code, I get nothing returned... Only the title will show Link to comment Share on other sites More sharing options...
Yzöwl Posted December 24, 2004 Share Posted December 24, 2004 You should be able to either query the registry; or write to temp file the long or short date format, then parse it for use in the batch before deleting the temp. This would then take the format straight from the HKCU and be non language specific. Link to comment Share on other sites More sharing options...
Tsunami Posted December 24, 2004 Share Posted December 24, 2004 You should be able to either query the registry; or write to temp file the long or short date format, then parse it for use in the batch before deleting the temp. This would then take the format straight from the HKCU and be non language specific.It looks easier than it is. The problem is that the format of the date can be anything. There's a preset list in Windows, where you can select things from, but you can put things in there yourself too. So you never know what the format is on the user's machine. I have the following batch code, which returns the year on my comp, but I'm not sure if it will work on other comps. It still needs a check for two or four digits too.@ECHO OFFSET KEY="HKCU\Control Panel\International"FOR /F "delims= skip=2 tokens=1" %%S IN ('REG QUERY %KEY% /V sDate') DO SET S=%%SIF "%S:~0,9%" == " sDate" SET SEP=%S:~17%FOR /F "delims= skip=2 tokens=1" %%S IN ('REG QUERY %KEY% /V sShortDate') DO SET S=%%SIF "%S:~0,14%" == " sShortDate" SET SDATE=%S:~22%FOR /F "delims=%SEP% tokens=1,2,3" %%S IN ("%SDATE%") DO ( SET S=%%S SET T=%%T SET U=%%U)FOR /F "delims=%SEP% tokens=1,2,3" %%S IN ("%DATE%") DO ( IF "%S:~0,1%" == "y" SET YEAR=%%S IF "%T:~0,1%" == "y" SET YEAR=%%T IF "%U:~0,1%" == "y" SET YEAR=%%U)IF %YEAR% LSS 100 SET YEAR=20%YEAR%ECHO %YEAR%PAUSEEXIT@Incroyable HULK: Yes, that's what I meant with the two/four digit check. I just edited so it will check if %YEAR% is less than 100, and if it is, it will add 20 at the beginning. So it should fully work now. Link to comment Share on other sites More sharing options...
Incroyable HULK Posted December 24, 2004 Author Share Posted December 24, 2004 Yep... your code is working but only returns 04 when 2 digit...Maybe it is possible to add an IF statement just to check if there is only 2 caracters and if not it, 20 will be added at the beginning.Then we'll have to modify this one in 95 years! Link to comment Share on other sites More sharing options...
Nologic Posted December 25, 2004 Share Posted December 25, 2004 Okay now I got a silly question...why do you want the current date displayed any ways? I could to some degree understand the value of listing the files last modified date, or creation date.Heh or is this just some thing to pull the wool over management\end user's eye's to make them think the scripts are always current? Link to comment Share on other sites More sharing options...
Tsunami Posted December 25, 2004 Share Posted December 25, 2004 He just wants to display the current year in the title of the RunOnceEx window, so he doesn't have to update this every year... Link to comment Share on other sites More sharing options...
Nologic Posted December 25, 2004 Share Posted December 25, 2004 Okay maybe I should phrase it...as I don't get the reasoning for having it there in the first place.I'm just puzzled is all. Link to comment Share on other sites More sharing options...
Incroyable HULK Posted December 25, 2004 Author Share Posted December 25, 2004 I was asked to put the year after the name of our departement in most of my creations... paperwork, etc.. It is just a standard format Link to comment Share on other sites More sharing options...
Nologic Posted December 26, 2004 Share Posted December 26, 2004 Well here is my answer to the problem and of course it involves AutoIt.It’s basically an AutoIt replacement for batch files normally used to perform GUIRunOnce & RunOnce operations.The script can spawn multiple independent RunOnceEx Dialogs, if one so desire…which I might add is very easy to do.The script can and does automate a lot of the normal hassle when confronting a project such as this. This ranges from auto numbering the registry keys, to combining text strings to lessen the amount of text one is required to punch into the script.This unlike many of my other scripts is not just simply altering a few user defined variables…in this one you have to actually get in and alter the true formation of the script. This really isn’t all that hard or difficult to understand, once you put your mind to it. Okay basic variables and functions, along with possible markers look like so:#Region - _CD( "" )$PATH = ""_Title ( "" )_Key ( "" , "" )_RunOnce()#EndRegionRegion Markers#Region - #EndRegionThen Region markers are a handy novelty for users of SciTE, this allows large chunks of code to be folded into a single line, of course with the ability to unfold it when so desired. These will not cause problems for other ASCII text editors, so they are harmless to leave in. That said feel free to remove any and all of them if you so choose.SciTE users may wish to open their “User Options” file and add the following lines, so that when opening a script that makes use of the Region markers, it is all folded and compact.fold.comment=1fold.on.open=1_CD( "" ) function_CD( "" )The _CD ( “” ) function is used to search out a file passed to it, to be used to define the drive the script will then use as its root. This can be used multiple times through out the script if more than one drive is required to install the desired applications.Passing the value of "WIN51" returns the drive letter which contains the Window’s XP installation disk. If the "WIN51" file was found to be on E drive the output would be: E:\_CD( "WIN51" )Passing the value of "boot.ini" Returns the drive letter which contains the operating system. If the "boot.ini" file was found to be on D drive the output would be: D:\_CD( "boot.ini" )$PATH = "" variable$PATH = ""This is used but by no means required, its single task is to help simplify directory path input. Its value is applied to every Key below it, till it is altered to a different path, or set to no path at all. That said this is concatenated (joined) with the value returned by the _CD( “” ) function.So if we passed the following values_CD( “WIN51” )$PATH = "Software\CD & DVD Tools\"And "WIN51" being passed to _CD( "" ) still returned E:\ We would be working with the below directory pathing information for all following Keys.E:\Software\CD & DVD Tools\Which would mean that we are working off the installation disk in a directory called "CD & DVD Tools, that is nested in side a directory called "Software".Now if we wanted to work from the drive the operating system resides on, and from within a folder called “Security Tools” that’s nested inside of a folder called “Install” we would then have to pass the following values_CD( "boot.ini" )$PATH = "Install\Security Tools\"Which would get us our planned result ofD:\Install\Security Tools\_Title ( "" ) function_Title ( "" )The _ Title ( “” ) function is used to label the window title of the RunOnceEx dialog. An example would be_Title ( "Installing Applications" )This would give the same effect as what’s shown in the image here.How ever to display what was requested in this thread one would use the following_Title ( "IT Departement " & @YEAR ) _Key ( "" , '' ) function_Key ( "" , '' )Now time to tackle the really difficult one. The main feature’s of this are to label a task to be listed in the RunOnceEx dialog, and to link together every process required to complete that task.The set of double quotes is used to pass the desired label for the task to the RunOnceEx dialog. So if we wanted to display the first task listed in the image here. The coding would then look like_Key ( "Preparing Installation…" , '' )Its here in the set of single quotes that things become more complex. Lets assume that our working path is stillE:\ Software\CD & DVD Tools\And that we are coding in everything for a completely updated Alcohol 120% installation. Our installation package is stored in a directory called “Alcohol 120%” currently nested inside the “CD & DVD Tools” directory. Now with the current directory path knowledge in mind, we need to added the folder “Alcohol 120%” and the installation package name. The current code would appear as_Key ( "Alcohol 120%" , 'Alcohol 120%\Alcohol_Setup.exe' )Since we are wanting this application to install silently we need to apply its switch’s. Now when applying any thing prior or post to the path and file name, the path and file name must be encapsulated in matching carots, as is the case when applying DOS commands or switches. Now updating the code would result in the following_Key ( "Alcohol 120%" , '^Alcohol 120%\Alcohol_Setup.exe^ /qn' )Now in this example we also have another installation package that needs to be executed to update the hardware support. To add any additional process simply requires that each process be separated with the pipe symbol “|”. The updated code appears below_Key ( "Alcohol 120%" , ’^Alcohol 120%\Alcohol_Setup.exe^ /qn|^Alcohol 120%\UpDate.exe^ /S' )Lastly to complete this task we need to merge a registry file, in order to have the applications registration information entered. The code follows the prior routine, hence the code revision_Key ( "Alcohol 120%" , ’^Alcohol 120%\Alcohol_Setup.exe^ /qn|^Alcohol 120%\UpDate.exe^ /S|REGEDIT /S ^Alcohol 120%\register.reg^’ )Now you can have up to 9999 _Key’s in a group, and each _Key can have up to 9999 process spawned from it. In most extreme case’s this will be enough, should there be a cause for more entries then one can always edit the source code to reflect this need.Keep in mind that file and folder names should not include pipes, single or double quotes, doing so will break the script.Transformations are now possible please check example files to see how to go about it. _RunOnce() function_RunOnce()This simply forces the execution of all keys entered under RunOnceEx, then resets the numbering of the _Key function to 0001.So fill it in how you like, compile it and forget it. UpdateSwapped out the orginal purpose of the single quotes, and instead replaced with carots "^". Then swapped out orginal purpose of second set of double quotes in _Key with single quotes. Link to comment Share on other sites More sharing options...
maxXPsoft Posted December 26, 2004 Share Posted December 26, 2004 from a .cmd you canECHOGoing on that we can ECHO out a vbs file then run it and retrieve the Year from thatworks compiled alsoI've seen it but can't remember where right now.Perhaps a vbs expert can help Link to comment Share on other sites More sharing options...
Incroyable HULK Posted December 27, 2004 Author Share Posted December 27, 2004 Thank you guys for all your efforts!The only problem I have is that my .cmd will be converted to .exe and I cannot have any external file dependency...Anyway, I trully appreciate all your efforts! Thank's again Link to comment Share on other sites More sharing options...
Nologic Posted December 28, 2004 Share Posted December 28, 2004 Well I'm changing the code around for the autoit script...got some thing thats performing transformations fine...I'll have to post an example of how to go about it...which shouldn't be a big deal at all.Then all thats needed is to buff up the CD routine...which I've gotten some code from MHz that does a good job thus far...but may seek to improve upon that as well.Any ways it will shortly be a full RunOnce batch file replacement. Link to comment Share on other sites More sharing options...
Shotgun Posted January 6, 2005 Share Posted January 6, 2005 Check this post: http://www.msfn.org/board/index.php?showto...ndpost&p=117846 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