NiCE Library remove Configuration WriteAction

NiCE.Library.W.Remove.Configuration.WA (WriteActionModuleType)

WriteAction to removes the Configuration File nice_base.env from a Windows Computer.

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.BaseData

Member Modules:

ID Module Type TypeId RunAs 
GetFolder ProbeAction Microsoft.Windows.ScriptPropertyBagProbe Default
RemoveFolder WriteAction System.CommandExecuter Default
WriteCompleted WriteAction NiCE.Library.W.Write.Event2.WA Default

Source Code:

<WriteActionModuleType ID="NiCE.Library.W.Remove.Configuration.WA" Accessibility="Public" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TargetSystem" type="xsd:string"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="GetFolder" TypeID="Windows!Microsoft.Windows.ScriptPropertyBagProbe">
<ScriptName>NiCELibraryGetBaseFolder.vbs</ScriptName>
<Arguments/>
<ScriptBody><Script>'-------------------------------------------------------------------------------
'* VBScript Name: NiCELibraryGetBaseFolder.vbs
'* Description :
'-------------------------------------------------------------------------------
'Declare Global Constants

'Constants used for event logging
Option explicit
SetLocale("en-us")

Const CommonAppData = &amp;H23&amp;

Const QUOTE = """"

' Declare Global Variables
Dim oAPI, oBag, bPropertyBagCreated
Dim g_szNiCEBaseDir
Dim g_objFSO, g_WshShell, g_objShell

'Start by setting up API object and creating a discovery data object.
Set oAPI = CreateObject("MOM.ScriptAPI")
Set g_objFSO = CreateObject("Scripting.FileSystemObject")
Set g_WshShell = WScript.CreateObject("WScript.Shell")
Set g_objShell = CreateObject("Shell.Application")

'******************************************************************
' MAIN
'******************************************************************
'First check ProgramData
g_szNiCEBaseDir = RemoveSlash(g_WshShell.ExpandEnvironmentStrings("%ProgramData%")) &amp; "\NiCE\conf\nice_base.env"
If g_objFSO.FileExists(g_szNiCEBaseDir) Then
Set oBag = oAPI.CreatePropertyBag()
Call oBag.AddValue("Path", RemoveSlash(g_WshShell.ExpandEnvironmentStrings("%ProgramData%")) &amp; "\NiCE")
oAPI.AddItem(oBag)
bPropertyBagCreated = true
Else
'Next Check ALLUSERSPROFILE + \Application Data
g_szNiCEBaseDir = RemoveSlash(g_WshShell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")) &amp; "\Application Data\NiCE\conf\nice_base.env"

If g_objFSO.FileExists(g_szNiCEBaseDir) Then
Set oBag = oAPI.CreatePropertyBag()
Call oBag.AddValue("Path", RemoveSlash(g_WshShell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%")) &amp; "\Application Data\NiCE")
oAPI.AddItem(oBag)
bPropertyBagCreated = true
Else
'Last try. Check CommonAppData'
Dim objFolder, objFolderItem
Set objFolder = g_objShell.Namespace(CommonAppData)
Set objFolderItem = objFolder.Self
g_szNiCEBaseDir = RemoveSlash(objFolderItem.Path) &amp; "\NiCE\conf\nice_base.env"
If g_objFSO.FileExists(g_szNiCEBaseDir) Then
Set oBag = oAPI.CreatePropertyBag()
Call oBag.AddValue("Path", RemoveSlash(objFolderItem.Path) &amp; "\NiCE")
oAPI.AddItem(oBag)
bPropertyBagCreated = true
End If
End If
End If

If bPropertyBagCreated = False Then
Set oBag = oAPI.CreatePropertyBag()
Call oBag.AddValue("Path", "")
oAPI.AddItem(oBag)
End If

oAPI.ReturnItems()


'******************************************************************
' Subs and Functions
'******************************************************************
'==================================================================================
' Function: RemoveSlash
' Purpose: removes the last char of a string if it a forward or backward slash
'==================================================================================
Function RemoveSlash(Path)
Dim szLastChar
szLastChar = Right(Path,1)
If szLastChar = "\" OR szLastChar = "/" Then
removeSlash = Left(Path,Len(Path)-1)
Else
removeSlash = Path
End If
End Function</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</ProbeAction>
<WriteAction ID="RemoveFolder" TypeID="System!System.CommandExecuter">
<ApplicationName/>
<WorkingDirectory/>
<CommandLine>RD /S /Q "$Data[Default='']/Property[@Name='Path']$"</CommandLine>
<TimeoutSeconds>300</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
</WriteAction>
<WriteAction ID="WriteCompleted" TypeID="NiCE.Library.W.Write.Event2.WA">
<EventInformations>13312;Information;The removal of the data folder for Computer '$Config/TargetSystem$' was completed. The Output is $Data[Default='']///*[local-name()="StdOut"]$$Data[Default='']///*[local-name()="StdErr"]$</EventInformations>
<EventError>$Data[Default='']///*[local-name()="StdErr"]$</EventError>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="WriteCompleted">
<Node ID="RemoveFolder">
<Node ID="GetFolder"/>
</Node>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.BaseData</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>