Jody Davis
asked on
How can i have cmd dialog box not show during batch script execution?
I created the following script to create a fake reg key, if the key isn't present - install software. If the key is there, fall out and end the execution.
The script works just fine. My challenge is when it executes, i get the dialog box pop up - which i do NOT want to be displayed.
Again, the script works fine - but how can i edit the script so i DO NOT receive the notification dialog box as shown in the attachment? (prefer to leave it as a .cmd script if possible). Thanks!
@echo off
rem queries if fake regkey is present
reg query "HKEY_LOCAL_MACHINE\SOFTWA RE\DotNetC heck"
if %errorlevel%==1 (goto Install) else (goto End)
REM If errorlevel returns value 1, key is not present and prgm will create key and install .net3.5
:Install
REG ADD HKLM\SOFTWARE\DotNetCheck
dism /online /quiet /enable-feature /featurename:NetFx3 /All /Source:\\ds-dfs01\sxs /LimitAccess
:End
DialogBoxWishToGoAway.png
The script works just fine. My challenge is when it executes, i get the dialog box pop up - which i do NOT want to be displayed.
Again, the script works fine - but how can i edit the script so i DO NOT receive the notification dialog box as shown in the attachment? (prefer to leave it as a .cmd script if possible). Thanks!
@echo off
rem queries if fake regkey is present
reg query "HKEY_LOCAL_MACHINE\SOFTWA
if %errorlevel%==1 (goto Install) else (goto End)
REM If errorlevel returns value 1, key is not present and prgm will create key and install .net3.5
:Install
REG ADD HKLM\SOFTWARE\DotNetCheck
dism /online /quiet /enable-feature /featurename:NetFx3 /All /Source:\\ds-dfs01\sxs /LimitAccess
:End
DialogBoxWishToGoAway.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not sure you can suppress the CMD window totally. At a minimum you can keep it minimized like:
cmd /c START /MIN c:\folder\test.bat
I remember something about running a script in silent mode. Google search brought me to this:
https://stackoverflow.com/questions/411247/running-a-cmd-or-bat-in-silent-mode
https://stackoverflow.com/questions/411247/running-a-cmd-or-bat-in-silent-mode
ASKER
1. The script is being pushed by our 3rd party software solution's distribution function. Long story short - this is the only way i can push a script so we use their functionality.
2. I'll check those URLs out - thanks.
3. I'll test that way out as well, thanks.
4. I'll check that URL out too, thanks.
i'll update the thread tomorrow. thanks everyone
2. I'll check those URLs out - thanks.
3. I'll test that way out as well, thanks.
4. I'll check that URL out too, thanks.
i'll update the thread tomorrow. thanks everyone
thumbs up
ASKER
I guess another piece of it is - if the window shows - I can deal with that. But with the syntax I used, the dialog box/cmd window STAYS open, I had to close it manually.
If I could have it run with those commands and make it close itself when the task completes, that would be good enough for me. For it to stay displayed when it runs, that's the biggest problem for me. How can we make it go away once complete, perhaps?
If I could have it run with those commands and make it close itself when the task completes, that would be good enough for me. For it to stay displayed when it runs, that's the biggest problem for me. How can we make it go away once complete, perhaps?
is your final line in the batch file ?
exit
exit
I have a very small batch file that I use when my print server hangs up:
net stop spooler
Pause "Print Services stopped"
net start spooler
Pause "Print Services started"
quit
Window pops up, I see the commands, then window disappears.
net stop spooler
Pause "Print Services stopped"
net start spooler
Pause "Print Services started"
quit
Window pops up, I see the commands, then window disappears.
ASKER
I've tried quit, end and exit. None of them work. The first part is a reg key query, and that's what appears to stay up in a cmd window. It disappears after 60seconds, but that's too much for user systems.
I use the following:
reg query "HKEY_LOCAL_MACHINE\SOFTWA RE\DotNetC heck"
and a new cmd window pops up during the execution of the entire script. It shows the following:
ERROR: The system was unable to find the specified registry key or value.
The operation completed successfully
Any idea on how i can suppress this? i have @echo off at the beginning. The script is as follows:
@echo off
rem queries if fake regkey is present
reg query "HKEY_LOCAL_MACHINE\SOFTWA RE\DotNetC heck"
if %errorlevel%==1 (goto Install) else (goto End)
REM If errorlevel returns value 1, key is not present and prgm will create key and install .net3.5
:Install
REG ADD HKLM\SOFTWARE\DotNetCheck
dism /online /quiet /enable-feature /featurename:NetFx3 /All /Source:\\ds-dfs01\sxs /LimitAccess
:End
HELP! :)
I use the following:
reg query "HKEY_LOCAL_MACHINE\SOFTWA
and a new cmd window pops up during the execution of the entire script. It shows the following:
ERROR: The system was unable to find the specified registry key or value.
The operation completed successfully
Any idea on how i can suppress this? i have @echo off at the beginning. The script is as follows:
@echo off
rem queries if fake regkey is present
reg query "HKEY_LOCAL_MACHINE\SOFTWA
if %errorlevel%==1 (goto Install) else (goto End)
REM If errorlevel returns value 1, key is not present and prgm will create key and install .net3.5
:Install
REG ADD HKLM\SOFTWARE\DotNetCheck
dism /online /quiet /enable-feature /featurename:NetFx3 /All /Source:\\ds-dfs01\sxs /LimitAccess
:End
HELP! :)
I'm not sure I'm following everything that you are describing, seems like you may have a few different issues, but as far as the REG QUERY. If you don't want to see any output from that command, which you don't since you are just checking the rrrorlevel afterwards, then you can do:
»bp
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\DotNetCheck">NUL 2>&1
»bp
ASKER
That suppressed the following: ERROR: The system was unable to find the specified registry key or value.
- but did not suppress "The operation completed successfully" - any idea how to suppress that as well?
- but did not suppress "The operation completed successfully" - any idea how to suppress that as well?
I don't know where that is coming from. I guess if the only other thing in the BAT is the DISM, then it comes from that.
You could do the same thing there, but if it throws an error you won't see that either...
»bp
You could do the same thing there, but if it throws an error you won't see that either...
»bp
I would use ECHO and PAUSE statements to troubleshoot this like:
=== BEGIN
:Install
echo.
echo BEFORE reg add
echo.
pause
REG ADD HKLM\SOFTWARE\DotNetCheck
echo.
echo AFTER reg add
echo BEFORE dism
echo.
pause
dism /online /quiet /enable-feature /featurename:NetFx3 /All /Source:\\ds-dfs01\sxs /LimitAccess
echo.
echo AFTER dism
echo BEFORE end
echo.
pause
:End
echo.
echo AFTER end
echo THE END
echo.
pause
=== END
Add throughout the BAT to see what is happening when. This should show you where the error is being generated.
=== BEGIN
:Install
echo.
echo BEFORE reg add
echo.
pause
REG ADD HKLM\SOFTWARE\DotNetCheck
echo.
echo AFTER reg add
echo BEFORE dism
echo.
pause
dism /online /quiet /enable-feature /featurename:NetFx3 /All /Source:\\ds-dfs01\sxs /LimitAccess
echo.
echo AFTER dism
echo BEFORE end
echo.
pause
:End
echo.
echo AFTER end
echo THE END
echo.
pause
=== END
Add throughout the BAT to see what is happening when. This should show you where the error is being generated.
ASKER
Ended up using one of the freeware solutions in the link to hide my command prompt window. thanks guys!
~bp