BatchPatch Forums Home › Forums › BatchPatch Support Forum › Batch file to Output
- This topic has 6 replies, 2 voices, and was last updated 6 years, 8 months ago by Phil.
-
AuthorPosts
-
February 28, 2018 at 8:21 pm #8859PhilParticipant
I have setup a small batch file with output to the console to check and see if a couple functions of the OS are enabled. I would like to use batchpatch to remotely deploy this batch file and record the output to a log on the local workstation I’m running this from.
I used the Deploy Software/patch/script/regkey etc and it ran the batch file with no issues. I then check the box to retrieve the console output and it will no longer work and there is no output.
Is there more I need to do?
February 28, 2018 at 8:26 pm #10185dougModeratorThat checkbox is not compatible with all scripts, hence the note below the checkbox that explains it ‘may cause a deployment to fail/error in some cases.’ If you share your script, I might be able to help get it to work.
-Doug
February 28, 2018 at 8:42 pm #10186PhilParticipant@echo off
REM Run Command to see if bitlocker is On
SETLOCAL ENABLEDELAYEDEXPANSION
SET count=1
FOR /F “tokens=* USEBACKQ” %%F IN (
manage-bde -status c:
) DO (SET var!count!=%%F
SET /a count=!count!+1
)
REM %var7% contains status
REM If statment to see if it is enabled
echo.%var7%|findstr /C:”Fully Encrypted” >nul 2>&1
if not errorlevel 1 (
REM The drive is already fully Encrypted
ECHO The drive is already fully Encrypted
CALL :TurnOnProtection
) else (
REM The drive is not Fully Encrypted
ECHO The drive is not Fully Encrypted
CALL :SetOwner
)
GOTO :EOF
:SetOwner
REM This will set the owner of Bit Locker
ECHO Set Owner
SET count=1
FOR /F “tokens=* USEBACKQ” %%F IN (
manage-bde -tpm -takeownership XXXXX
) DO (SET var!count!=%%F
SET /a count=!count!+1
)
CALL :TurnOnProtection
:TurnOnProtection
REM This will turn on Bit Locker
ECHO Add C To Bit Locker
SET count=1
FOR /F “tokens=* USEBACKQ” %%F IN (
manage-bde -protectors -add -rp c:
) DO (SET var!count!=%%F
SET /a count=!count!+1
)
ECHO Turn On Bit Locker
SET count=1
FOR /F “tokens=* USEBACKQ” %%F IN (
manage-bde -on c:
) DO (SET var!count!=%%F
SET /a count=!count!+1
)
exit /b 0
:EOF
ENDLOCAL
exit /b 1
February 28, 2018 at 8:43 pm #10177PhilParticipantHi Doug,
Here’s the script I’m working with. Let me know what you think.
Thanks,
Phil
February 28, 2018 at 9:33 pm #10178dougModeratorThanks, Phil. Unfortunately I don’t think we’ll be able to make this compatible with the ‘retrieve console output’ option in this version of BP. Realistically it probably needs to be re-written in powershell or vbscript or similar to get it working right now. However, Scott thinks he just figured out why it’s not working as-is with the current code, so I think we probably ought to be able to get this working in the next version of BP.
-Doug
February 28, 2018 at 9:35 pm #10179PhilParticipantThanks for taking a look. I will see what I can do with PS.
February 28, 2018 at 11:42 pm #10180dougModeratorNo problem. Also FYI Scott did get it working after altering/updating some of our code, so the fix will be included in the next release.
-Doug
-
AuthorPosts
- You must be logged in to reply to this topic.