/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


Can Kace run req query scripts?

06/19/2017 1400 views

The script below is just an example of a req query script. If I try running the script from Kace, the script will always goto :two. If I run the script from the machine itself, then the script will goto  :one.

@echo off
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Symantec"
if %ERRORLEVEL% EQU 0 goto One
if %ERRORLEVEL% EQU 1 goto Two


:One
CLS
echo yes
pause
exit

:Two
CLS
ECHO No
pause
Exit


I have tried using running the script as local system, Credentials, and local user. Also tried using HKLM, HKLM64 to see if it will help, but still not having any luck.

KACE Agent = 6.4, do we know if they Req Query bugs have been fixed.

http://www.itninja.com/question/registry-script-fails-with-k1000


Answer Summary:
1 Comment   [ + ] Show comment

Comments

  • All pertinent data relative to the script has been replaced with '...'. The remarks are enough to follow along with installation program.



    ECHO %PROCESSOR_ARCHITEW6432%
    IF "%PROCESSOR_ARCHITEW6432%"=="AMD64" GOTO _Native

    ECHO "This is running from a 64bit command prompt, on a 64bit OS."
    REM Create log directory

    REM Install Corel Painter

    REM Turn off EULA from HKLM
    REG.EXE ADD ...

    REM Import Default User Key (Turn off EULA)
    REM Load Default User HIVE
    REG.EXE LOAD HKU\DEFAULT C:\Users\Default\NTUser.dat

    REM Turn off EULA within Default User hive
    REG.EXE ADD ...
    REM Import Registration (disable) settings, to prevent dialog from opening on Painter 2017 launch
    REG.EXE IMPORT ...

    REM Unload Default User HIVE
    REG.EXE UNLOAD HKU\DEFAULT

    REM End of 'normal' scripting, goto end of program (skipping native section).
    GOTO _END

    REM Start of script using any needed C:\Windows\Sysnative\[command] changes
    :_Native

    ECHO "This is running from a 32bit command prompt, on a 64bit OS."

    REM Create log directory

    REM Install Corel Painter

    REM Turn off EULA from HKLM
    C:\Windows\Sysnative\REG.EXE ADD ...

    REM Import Default User Key (Turn off EULA)
    REM Load Default User HIVE
    C:\Windows\Sysnative\REG.EXE LOAD HKU\DEFAULT C:\Users\Default\NTUser.dat

    REM Turn off EULA within Default User hive
    C:\Windows\Sysnative\REG.EXE ADD ...
    REM Import Registration (disable) settings, to prevent dialog from opening on Painter 2017 launch
    C:\Windows\Sysnative\REG.EXE IMPORT ...

    REM Unload Default User HIVE
    C:\Windows\Sysnative\REG.EXE UNLOAD HKU\DEFAULT

    REM End of native scripting, goto end of program.
    GOTO _END


    :_END

Answer Chosen by the Author

0
I see no reason why not but I use SCCM. One weird gotcha is sometime things are ran using CMD in c:\Windows\SysWOW64\CMD.exe and requires C:\Windows\Sysnative\REG.exe to be used in OS Deploy sequences to make sure it hits the correct part of the registry.

It's an idea ...
Answered 06/20/2017 by: mz6569
White Belt

  • That worked, by adding C:\Windows\Sysnative\REG.exe.

    Thanks for the answer and for teaching me something new..
    • Sounds like Kace is running your deployment via C:\Windows\Syswow64\cmd.exe.

      Open both C:\Windows\System32\cmd.exe and C:\Windows\Syswow64\cmd.exe side by side and run 'SET PROC' and compare the results.

      You'll see the addition of PROCESSOR_ARCHITEW6432 in syswow64\cmd.exe

      You also run a 'dir C:\windows\sysnative' in syswow64\cmd.exe. But it will fail on the other.

      C:\Windows\sysnative\ from the 32bit command prompt actually references C:\Windows\System32 if you were to look at it through explorer.

      I use PROCESSOR_ARCHITEW6432 as a check to allow me to create 1 script to run manually, during an OS deployment or a normal system push. Posting the code in another comment.


      Oddly enough, SCCM uses
      - C:\Windows\syswow64\cmd.exe during a OS Task Sequence.
      - C:\Windows\system32\cmd.exe when sending a push program.

      At one point I had to maintain 2 installer scripts for anything that required import/copy/etc in the hosts C:\Windows\System32 directory. Now I use the logic posted in my other comment to allow me to maintain only 1 installer script.

      Hope this helps with Kace management.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ