Window .bat file

B

Thread Starter

Bhargav Purohit

i am using one software that runs on particular date. so every time when i have to open that software i need to change my pc date on which i have installed that software . so i have created one ".bat" file that changes my computer date and then open my software . and is working. now my question is, is it possible first to store current date, then to change date to that software date, then open software and then again restore current date that was previously stored...?

.bat file that i created is as follow,that changes date to 11/11/2011 and open software, say software.exe.

date=11-11-2011
"C:\Program Files\software.exe"

another question is, while running .bat file it don't closes until i close that software opened or i manually close that window.

thanks in advance.
 
Just purchase the rights to run this program and you will not need to cheat it every time. :)

> i am using one software that runs on particular date. so every time when i
> have to open that software i need to change my pc date on which i have
> installed that software....
 
SET BEFOREDATE=%date:~4,2%-%date:~7,2%-%date:~10,4%
date 01-03-07
START /WAIT s:\TeamViewer_Setup.exe
ping -n 10 127.0.0.1 > NUL 2>&1
date %BEFOREDATE%

save above script in bat file and execute it.
 
B

Bhargav Purohit

Thanx ... i have done same and its working..

but now my requirement changed. with starting my sw, some its services starts. and i want to restore my original date after this service starts..

and can you help from where you found that %date:~4,2% will give us month digit and so on.. is there any book that you can suggest me to get hands on all this..

thanks in advance..
 
B

Bhargav Purohit

Here is the solution:
First create shortcut for your software and rename it to Desired name eg. SWNAME.

paste this shortcut to C:\WINDOWS...
suppose you need to wait till your service, say, SERVICENAME.exe starts...

and create .bat file with following code...

@echo off
set currentDate=%date:~4,2%-%date:~7,2%-%date:~12,2%
date 11-11-2011
IF %date:~7,2%==11 start SWNAME
@echo off
echo Solution By Bhargav Purohit
:waitt
tasklist /FI "IMAGENAME eq SERVICENAME.exe" 2>NUL | find /I /N "SERVICENAME.exe">NUL
if "%ERRORLEVEL%"=="0" GOTO end
if "%ERRORLEVEL%"=="1" GOTO waitt
:end
echo wscript.sleep 2000 > WAIT.vbs
wscript.exe WAIT.vbs
date=%currentdate%
exit

With Best regards,
Bhargav Purohit
 
Typically Windows problem.

- running software without having a valid license
- Using unusable cmd.exe with BAT files

Tip: Learn Powershell instead
Better Tip: Learn programming in C
Even better Tip: Use Open Source Solutions, but do not forget to learn C. You will need it anyway.
 
Top