|
Answer» Hello,
I would like to know how to querry a registery value, meaning check for the value of a given key and if the ky is equal to abcde call a certain program.
And also the same for the running processes, if notepad.exe is running call a certain program.
Thank You
AlmnIf your MACHINE supports it, try using TASKLIST and filtering the RESULTS thru FIND:
Code: [Select]tasklist | find "notepad.exe" > NUL & if not errorlevel 1 echo Notepad is executing
Note: Not all OSes support the TASKLIST command.
Need more info on the registry request. The hive and the key would be helpful.
8-)Thanks ,
The key would be "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run"
and the hive would be "Kernel"
Thank You
AlmnDoes this work for you?
Code: [Select]set k=HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run set v=Kernel set d=abcde reg query %k% /v %v%|findstr /i "%v%.REG_SZ.%d%">NUL&&echo.call a certain programIn case the search string "%v%.REG_SZ.%d%" is not correct run reg query %k% /v %v% by itself to see what the reg function returns and MAKE adjustments as necessarily.
A simple reg query %k% /v %v%|find /i "%d%">NUL&&... may also do it for you. Remove the /i switch for case sensitive comparison.
More info about conditional execution using && or || is available @ http://dostips.cmdtips.com/DtCodeSnippets.php
Hope this helps
|