1.

Solve : how can i run batch when on a program exit?

Answer»

Hello there,

I need a batch file, that opens a dos program (or any other?) and runs a reg file, ok that's easy to do. But the problem is that I need to know when this program is closed and run another reg file. Can be done in one batch file, and how can I exactly monitor when this program is closed?

THANK you!@echo off
echo starting program 1
program1.exe
echo program 1 has finished
program2.exe
echo program 2 has finished

etc
Thanks but it doesn't help me, also when reg file is started it is asking for confirmation (do you want to add file into the registry...) how can i avoid that.

Thank you
Quote

Thanks but it doesn't help me,

Then please be more clear about this

Quote
But the problem is that I need to know when this program is closed and run another reg file.


Quote
also when reg file is started it is asking for confirmation (do you want to add file into the registry...) how can i avoid that


REG.EXE add adds new keys and VALUES to the Registry. You can add a VALUE to an existing key, add a new key with no values, or create a new key and a value beneath it. If you try to add a key or value that already exists, REG.EXE will warn you.

REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [/d Data] [/f]

*

KeyName [\\Machine\]FullKey

Machine Name of REMOTE machine - omitting defaults to the current machine. Only HKLM and HKU are available on remote machines

FullKey ROOTKEY\SubKey

ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]

SubKey The full name of a registry key under the selected ROOTKEY

*

/v The value name, under the selected Key, to add
*

/ve adds an empty value name for the key
*

/t RegKey data types:

[ REG_SZ, REG_MULTI_SZ, REG_DWORD_BIG_ENDIAN, REG_DWORD, REG_BINARY, REG_DWORD_LITTLE_ENDIAN, REG_NONE, REG_EXPAND_SZ ] If omitted, REG_SZ is assumed

*

/s Specify one charactor that you use as the separator in your data
string for REG_MULTI_SZ. If omitted, use "\0" as the separator
*

/d The data to assign to the registry ValueName being added
*

/f Force overwriting the existing registry entry without prompt

Examples:

REG ADD \\ABC\HKLM\Software\MyCo
Adds a key HKLM\Software\MyCo on remote machine ABC

REG ADD HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead
Adds a value (name: Data, type: REG_BINARY, data: fe340ead)

REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail
Adds a value (name: MRU, type: REG_MUTLI_SZ, data: fax\0mail\0\0)

REG ADD HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d %%systemroot%%
Adds a value (name: Path, type: REG_EXPAND_SZ, data: %systemroot%)
Notice: Use the double percentage ( %% ) inside the expand string

I thing he means Import Value from another Reg File (*.reg)
use this:
REG IMPORT "C:\YourRegFile.reg"

Here what you need..
..Untested..
------------------------------------------------------------------
@echo off
set Program=whatever.exe
start %program%
REG IMPORT "C:\YourRegFile.reg"
:loop
tasklist>log.txt
find /i "%Program%" log.txt
if errorlevel 1 (
REG IMPORT "C:\AnotherRegFile.reg"
exit
)
ping localhost -w 1000 -n 2
goto loop
-----------------------------------------------------------------


Discussion

No Comment Found