1

Here is my code :

@echo off

for /f "tokens=2*" %%a in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\NCR\APTRA\Aggregate 
Installer\Inventory\Aggregate\APTRA Self-Service Support" /f 06.04.01') do set "AppPath=%%~b"
echo %AppPath%

cmd /k

So when we run this batch file command prompt will open, so my requirement is when i click on Enter we need to break the FOR LOOP as the command prompt is not getting closed, Could any one please help me out ?

manikanth
  • 17
  • 1
  • 6
  • 1
    I know how to [break out of `for` loops](https://stackoverflow.com/a/37041525), but I do not understand your question. What are you trying to achieve exactly? – aschipfl Jul 14 '17 at 08:41
  • There may be no need to break out of the loop if your registry search pattern was more specific. _you appear to know the exact location of that data in advance_. Could you please show us the exact key, value and data content you are trying to parse. – Compo Jul 14 '17 at 09:31
  • When we run that batch file command prompt screen will come showing the message 1 Match Found ! And with the location C:pangaea\batchfile , so when i click enter button that should close But this is repeating C:pangaea\batchfile C:pangaea\batchfile C:pangaea\batchfile C:pangaea\batchfile C:pangaea\batchfile even though i press enter, I couldnt attach the screen shot to show you – manikanth Jul 14 '17 at 09:46
  • With that code this is repeating with for loop C:pangaea\batchfile, C:pangaea\batchfile, C:pangaea\batchfile I wanted to close the cmd with enter button with that code in short to say ! – manikanth Jul 14 '17 at 09:48
  • I wanted to get out of that output after the command prompt opens with the enter key ! – manikanth Jul 14 '17 at 09:51

2 Answers2

0

try with goto:

@echo off

for /f "tokens=2*" %%a in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\NCR\APTRA\Aggregate 
Installer\Inventory\Aggregate\APTRA Self-Service Support" /f 06.04.01') do (
 set "AppPath=%%~b"
 goto :break
)
:break
echo %AppPath%

cmd /k
npocmaka
  • 55,367
  • 18
  • 148
  • 187
  • Yes, When i try to run this code command prompt not opening ! running and closing at the same time , But Command prompt needs to open that should show the message and when we click on enter than that needs to close – manikanth Jul 14 '17 at 07:05
0

Use the pause command, it will hold the console screen if there is no error.