Silent Reg Query

Hi there,

I've wrote the following batch file, which does what I need it to do, the batch file is launched from Windows RemoteApp services (similar to Citrix XenApp), here's the script:

@echo off
reg query HKCU\Software\Microsoft\Office\Excel\Addins\GlobeSoftware.Atlas40
if %ERRORLEVEL% EQU 1 goto InstallReg if %ERRORLEVEL% EQU 0 goto runatlas
:InstallReg 
REGEDIT.EXE  /S  "%~dp0\GlobeSoftware.Atlas40.AIExcel.reg"
:runatlas 
O:\Atlas\Client\GlobeSoftware.Atlas40.AtlasClientServiceApp "sharedconfigpath=\\wgg-file-02\Atlas User Data\Shared Configuration AX Live 1"
O:\Atlas\Client\GlobeSoftware.Atlas40.AtlasClientServiceApp.exe 

exit

Open in new window

However when the batch file launches and does whatever it needs to do, it displays output in the cmd window, even after it's launched .exe that you can see in there, I need the cmd window to be completely silent and then close, once the .exe has started.

I either get the contents of the regs that the script has found or that the reg keys cannot be found, I need the script to be completely silent but still enter in the information in the batch file for which it depends on.

Many Thanks,
Alex.
ProjNetAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITCommented:
Try filename.bat > nul
0
oBdACommented:
Assuming the first call to AtlasClientServiceApp.exe just does some configuration and then returns control to the batch, try it like this:
@echo off
reg.exe query "HKCU\Software\Microsoft\Office\Excel\Addins\GlobeSoftware.Atlas40" >NUL 2>&1
if %ERRORLEVEL% EQU 1 (
	reg.exe import "%~dp0GlobeSoftware.Atlas40.AIExcel.reg"
)
O:\Atlas\Client\GlobeSoftware.Atlas40.AtlasClientServiceApp.exe "sharedconfigpath=\\wgg-file-02\Atlas User Data\Shared Configuration AX Live 1"
start O:\Atlas\Client\GlobeSoftware.Atlas40.AtlasClientServiceApp.exe

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Zac HarrisSystems Administrator Commented:
Here is a possible solution:

From your first script, call your second script with the following line:

wscript.exe invis.vbs run.bat %*

Open in new window


Actually, you are calling a vbs script with:

   
the [path]\name of your script
   
all the other arguments needed by your script (%*)

Then, invis.vbs will call your script with the Windows Script Host Run() method, which takes:

   
intWindowStyle : 0 means "invisible windows"
   
bWaitOnReturn : false means your first script does not need to wait for your second script to finish

Here is invis.vbs:

set args = WScript.Arguments
num = args.Count

if num = 0 then
    WScript.Echo "Usage: [CScript | WScript] invis.vbs aScript.bat <some script arguments>"
    WScript.Quit 1
end if

sargs = ""
if num > 1 then
    sargs = " "
    for k = 1 to num - 1
    	anArg = args.Item(k)
    	sargs = sargs & anArg & " "
    next
end if

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run """" & WScript.Arguments(0) & """" & sargs, 0, False

Open in new window

0
zalazarCommented:
You might try the following:
@echo off
reg query HKCU\Software\Microsoft\Office\Excel\Addins\GlobeSoftware.Atlas40 >nul 2>&1
if %ERRORLEVEL% EQU 1 goto InstallReg if %ERRORLEVEL% EQU 0 goto runatlas
:InstallReg 
REGEDIT.EXE /S "%~dp0\GlobeSoftware.Atlas40.AIExcel.reg" >nul 2>&1
:runatlas 
O:\Atlas\Client\GlobeSoftware.Atlas40.AtlasClientServiceApp "sharedconfigpath=\\wgg-file-02\Atlas User Data\Shared Configuration AX Live 1" >nul 2>&1
start O:\Atlas\Client\GlobeSoftware.Atlas40.AtlasClientServiceApp.exe 

Open in new window

0
ProjNetAuthor Commented:
Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.