0

I have the following batch script as variable in my powershell script.

$DataIntegrityCheck = @"
@ECHO OFF
SET SETTING_HOME=""
SET BACKUP_SET="ALL"
SET BACKUP_DEST="ALL"
SET CRC_MODE="DISABLE-CRC"
"@

How can I run this batch script?

Thank you in advance for any help.

2
  • 3
    why don't you set those EnvVars from inside powershell? Commented Apr 5, 2019 at 12:27
  • because the script is longer and does other things. Commented Apr 8, 2019 at 11:03

1 Answer 1

2

You don't need to execute that in batch to set environment variables, just use the Environment drive in :

$Env:SETTING_HOME = '""'
$Env:BACKUP_SET = '"ALL"'
$Env:BACKUP_DEST = '"ALL"'
$Env:CRC_MODE = '"DISABLE-CRC"'

about_Environment_Provider

Sign up to request clarification or add additional context in comments.

2 Comments

To have the same vars as in a batch you'll need to include the double quotes inside the single ones. Especially the 1st one won't be set at all.
@LotPings Good point, I usually use SET "VAR=VAL" in my scripts and missed what they were doing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.