Getting values from .vbs to CustomSettings.ini RRS feed

  • Question

  • I need some help getting CustomSettings.ini populated dynamically.

    There are a lot of hits out there when I search for using web services or vbs scripts but I'm failing to join the dots and actually populate a value.

    I am trying to get the computer name via the web service. I.e. the CustomSettings.ini value 'OSDComputerName'

    I have made a .vbs script that successfully queries a web service and then selects the appropriate value from the XML:

    <job id="MDTMenu_name">
    <script language="VBScript" src="..\ZTIUtility.vbs"/>
    <script language="VBScript" src="..\ZTIDataAccess.vbs"/>
    <script language="VBScript">
    Dim oService
    Dim oXML
    Set oService = New WebService
    oService.IniFile = "CustomSettings.ini"
    oService.SectionName = "asset_query"
    Set oXML = oService.Query
    ' Configure the namespace
    Dim ns
    ns = ""
    oXML.SetProperty "SelectionNamespaces", "xmlns:ns ='" & ns & "'"
    If oXML Is Nothing Then
    	oLogging.CreateEntry "Unable to call UserGetName web service.", LogTypeWarning
    	WScript.Echo "Not Found" & vbcrlf
    	WScript.Echo oXML.SelectSingleNode("/ns:AssetInfo/ns:ID").Text	
    	Dim OSDComputerName
    	OSDComputerName = oXML.SelectSingleNode("/ns:AssetInfo/ns:ID").Text	
    End If

    My CustomSettings.ini looks like this:


    I know I am missing some fundamentals but I can't seem to find any useful posts about how to actually link back my extracted XML values in my script to variables in my CustomSettings.ini.

    Any pointers appreciated!

    Thursday, January 16, 2014 4:21 AM

All replies

  • I've been using the webservice to acquire the computername based on its UUID in AD. Unfortunately the AD comuteraccount does not store the UUID by default. So you need the UUID to be stored. I approached this as a two step process.

    1. Deploy the computer. One of the last steps is a (powershell)script that sets the UUID in AD using the webservice
    2. Once the UUID is stored in AD, a (re)deploy uses the webservice to retreive the ComputerName utilising the UUID

    This works well for me. The one drawback is that it takes some time to have 100% UUID's stored, however, this is a one-time-per-computer issue only.

    If you like I can give you the scripts and a more elaborate explenation.

    Just let me know.

    I wrote a Wiki on PowerShell and webservice. Please find it here:



    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Thursday, January 16, 2014 8:54 AM
  • Well, your script needs to put the values back as MDT properties so they can be used by other scripts, a simple example looks like this:

    oEnvironment.Item("OSDCOMPUTERNAME") = OSDComputerName 


    oEnvironment.Item("OSDCOMPUTERNAME") = oXML.SelectSingleNode("/ns:AssetInfo/ns:ID").Text 
    More often you would just enumerate through all returns and store those as properties. Here is a good guide for ConfigMgr that also valid for MDT Lite Touch: 

    Regards / Johan Arwidmark Twitter: @jarwidmark Blog: FB:

    Thursday, January 16, 2014 10:19 AM
  • I tried to execute the script using a UserExit value in customsettings.ini:



    I modified my .wsf script appropriately to be a function and it works if I call the script directly however when i boot from start my customsettings.ini doesn't seem to be parsed at all because i get prompted for everything via the wizard (it's ignoring my SkipUserData=YES parameters etc).

    I wish there was some sort of log i could check but everything i have seen refers to a log in x:\MININT\* which doesn't exist on my system.  Neither is there anything in x:\windows\logfiles or x:\windows\system32\logs\

    Friday, January 17, 2014 6:24 AM
  • CustomSettings.ini is by default only referenced at the start of the Deployment Wizard in WinPE. You should re-parse it once the Task Sequence is running.

    For that you can do this:

    • Edit the TaskSequence
    • Go to the "Task Sequnce" tab
    • Find the first reference to "Gather Local Only" (usualy in the step "Initialization")
    • Edit that step by selecting it (you're on the "Properties Tab")
    • Change form "Gather olny local data" to "Gather local data and process rules"
    • In the "Rules file" field, enter "CustomSettings.ini" (without the quotes)
    • Apply the changes and close the TS

    That insures CS.ini gets parsed when the TS starts.

    Hope this helps,



    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Friday, January 17, 2014 7:16 AM
  • If you are using a function in a userexit, that function must return the value so the CustomSettings.ini can use.

    Function fGetComputerName()
    fGetComputerName = "PC00095"
    End Function

    To quickly simulate the CustomSettings.ini settings, and your userexit script, you should set up a rules simulation environment:

    1. On a client machine in the domain, install the ConfigMgr 2012 R2 Toolkit, start CMTrace and click Yes to associate .log files with it.
    2. Create a folder named C:\MDT.
    3. Copy the following files from your MDT 2012/2013 deployment share to C:\MDT


      plus any userexit script you are using.

    4. Create a batchfile named Gather.cmd with the following information

      if exist C:\MININT\Nul rd C:\MININT /s /q
      cscript.exe ZTIGather.wsf /debug:true

    5. In an elevated command prompt, navigate to C:\MDT, and run the Gather.cmd batch file, and review the C:\MININT\SMSOSD\OSDLOGS\ZTIGather.log file in CMTrace.

    Regards / Johan Arwidmark Twitter: @jarwidmark Blog: FB:

    Friday, January 17, 2014 9:37 AM
  • Thanks for these instructions Johan - they really helped a lot.

    I set up the test environment as you outlined and any reference to a function in my custom file 'ZTIMyScript.wsf' returned an error.

    I rewrote my code to be a straight .vbs file instead and now my function returns the value correct and customsettings.ini is picking it up properly.

    So the moral of the story is that .wsf doesn't work, or at least it didn't in my environment. I have seen examples on the web referencing .wsf files though so it could be possible.

    Thanks to all for the suggestions.

    • Edited by Bill Gayts Tuesday, January 21, 2014 2:09 AM
    Tuesday, January 21, 2014 2:09 AM
  • Yes, when calling a userexit, the environment is already loaded, and the script becomes part of the ZTIGather.wsf process.

    That why you only use .vbs script, the ZTIGather.wsf already includes the needed files.

    .wsf files are great when you want to call scripts outside of the ZTIGather.wsf process (which I first assumed you did).

    / Johan

    Regards / Johan Arwidmark Twitter: @jarwidmark Blog: FB:

    Tuesday, January 21, 2014 6:25 AM
  • Any MDT variables can be modified by using the oEnvironment object.

    I.e. oEnvironment.Item("VariableName")="My Value"

    All variables are strings and they support mixed case so for checking their value it is good practice to ucase or lcase them.

    The above is true for all MDT variables that are pre-defined. New variables can be created dynamically during the task sequence just by assigning a value to them. If they need to be created and accessed before the Task Sequence (i.e. at Wizard time) they need to be defined in the CustomSettings.ini file using the Properties= line in the Settings section. You will see that it includes an example called MyCustomProperty which can be removed if you want.

    Thursday, January 23, 2014 2:25 PM