Chad Franks
asked on
Need script to ask for user input and end up modifying xml file.
I have an xml file I use to pass to my powershell script to created folders, shares and my IIS website. However I have to manually go in an edit my xml input file. I wanted to create a script/batch file to ask the user for input and then modify the xml file.
This is what I have so far:
xml file:
here is my batch file:
It will change the first line of the XML file but nothing else. I think my logic/syntax may be wrong with the !newline.
Any help would be greatly appriciated
This is what I have so far:
xml file:
<?xml version="1.0"?>
<item>
<application_env>test</application_env>
<application_name>app-test</application_name>
<application_fqdn>app-test.company.com</application_fqdn>
<framework_version>40</framework_version>
<managedPipelineMode>Integrated</managedPipelineMode>
<apppoolidentity>yes</apppoolidentity>
<application_id>app\svc-test</application_id>
<application_pw>#@$$#</application_pw>
<application_developers>App-Web-DEV</application_developers>
</item>
here is my batch file:
@echo off
setlocal EnableDelayedExpansion
set /p Application_env=App Env:
set /p Application_name=App Name:
set /p Application_FQDN=App FQDN:
set /p Framework_ver=Framework version:
set managedPipelineMode=Integrated
set apppoolidentity=yes
set /p application_id=AppPool ID:
set /p application_pw=AppPool PW:
set /p application_developers=App Developers:
(for /F "delims=" %%a in (input.xml) do (
set "line=%%a"
set "newLine=!line:application_env>=!"
if "!newLine!" neq "!line!" (
set "newLine=<application_env>%application_env%</application_env>"
)
echo !newLine!
set "newLine=!line:application_name>=!"
if "!newLine!" neq "!line!" (
set "newLine=<application_name>%application_name%</application_name>"
)
)) > newFile.xml
It will change the first line of the XML file but nothing else. I think my logic/syntax may be wrong with the !newline.
Any help would be greatly appriciated
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window