batch file renaming and control flow

Hello experts.
I have two questions:
First, I have a batch file that in the process of running, renames a script like this:
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "path\bananatemp.xlsx" "banana_%%f-%%e-%%g.xlsx"
Which gives me the file name with the date in which the script was invoked.
I need it to include the hour as well (up to minute level in 24h format, so if I would the script on the 29th of October, at 14:32, the file name would be banana_29-10-15_14-32.xlsx).

The other thing has to do with the control of the script. the very last line in the script, opens the report that the script generated. As long the excel is open on any computer, the script keeps running in the background while not actually doing anything because as far as the OS is concerned, it gave the control to the excel file.
I need a way to open the report, and yet to return the control to the script so that it could terminate without closing the report... Is that possible?
LVL 9
David SankovskySenior SysAdminAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
The following script retrieves the time from WMI, because the format is neither user nor OS dependent, and generates the time stamp.
Then simply add
start "" 
(including the empty double quote pair) at the very beginning of the line that starts your report.
@echo off
setlocal enabledelayedexpansion
echo Getting system time ...
for /f "tokens=1-9" %%a in ('wmic.exe Path Win32_LocalTime Get Day^,DayOfWeek^,Hour^,Minute^,Month^,Quarter^,Second^,WeekInMonth^,Year ^| find /v ""') do (
	set /a Line += 1
	if "!Line!"=="1" (set VarA=%%a&set VarB=%%b&set VarC=%%c&set VarD=%%d&set VarE=%%e&set VarF=%%f&set VarG=%%g&set VarH=%%h&set VarI=%%i)
	if "!Line!"=="2" (set !VarA!=%%a&set !VarB!=%%b&set !VarC!=%%c&set !VarD!=%%d&set !VarE!=%%e&set !VarF!=%%f&set !VarG!=%%g&set !VarH!=%%h&set !VarI!=%%i)
)
for %%a in (Month Day Hour Minute Second) do (if !%%a! LSS 10 set %%a=0!%%a!)
set TimeStamp=%Day%-%Month%-%Year:~2%_%Hour%-%Minute%
echo Time stamp: %TimeStamp%
rename "path\bananatemp.xlsx" "banana_%TimeStamp%.xlsx"
start "" "C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE" /e "banana_%TimeStamp%.xlsx"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David SankovskySenior SysAdminAuthor Commented:
Excellend script!
Does exactly what I needed!! killed two birds with one stone!!
Thanks a lot :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.