Skip to content

Commit f3bca35

Browse files
nm777jimthedev
authored andcommitted
Example XML file, incremented version, and added looping to process more than one scriptData/licenseData XML element. (#8)
1 parent 064c497 commit f3bca35

File tree

3 files changed

+107
-22
lines changed

3 files changed

+107
-22
lines changed

labtech_decode_scriptxml/Program.cs

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static int Main(string[] args)
6363
string[] arrValue = listArg.ToArray();
6464
string argValue = String.Join("=", arrValue);
6565

66-
/* Map arguments to designaed local variables */
66+
/* Map arguments to designated local variables */
6767
if (argLabel == "--input")
6868
{
6969
inputPath = argValue;
@@ -150,25 +150,41 @@ static int Main(string[] args)
150150
XmlNodeList scriptData = inputXMLdoc.GetElementsByTagName("ScriptData");
151151
XmlNodeList licenseData = inputXMLdoc.GetElementsByTagName("LicenseData");
152152

153-
/* Decode the gzipped compressed string */
154-
string scriptDataString = GunzipString(scriptData[0].InnerText);
155-
string licenseDataString = GunzipString(licenseData[0].InnerText);
156-
157-
/* Write new string to the XML node */
158-
scriptData[0].InnerText = "";
159-
licenseData[0].InnerText = "";
160-
161-
/* Generate a new fragment from the decoded XML */
162-
XmlDocumentFragment scriptDecodedNode = inputXMLdoc.CreateDocumentFragment();
163-
XmlDocumentFragment licenseDecodedNode = inputXMLdoc.CreateDocumentFragment();
164-
scriptDecodedNode.InnerXml = scriptDataString;
165-
licenseDecodedNode.InnerXml = licenseDataString;
166-
167-
/* Replace the original node with the decode node */
168-
XmlNode scriptDataParent = scriptData[0].ParentNode;
169-
XmlNode licenseDataParent = licenseData[0].ParentNode;
170-
scriptDataParent.ReplaceChild(scriptDecodedNode, scriptData[0]);
171-
licenseDataParent.ReplaceChild(licenseDecodedNode, licenseData[0]);
153+
/* Loop through each scriptData element and decode it */
154+
for (int i = 0; i < scriptData.Count; i++)
155+
{
156+
/* Decode the gzipped compressed string */
157+
string scriptDataString = GunzipString(scriptData[i].InnerText);
158+
159+
/* Write new string to the XML node */
160+
scriptData[i].InnerText = "";
161+
162+
/* Generate a new fragment from the decoded XML */
163+
XmlDocumentFragment scriptDecodedNode = inputXMLdoc.CreateDocumentFragment();
164+
scriptDecodedNode.InnerXml = scriptDataString;
165+
166+
/* Replace the original node with the decode node */
167+
XmlNode scriptDataParent = scriptData[i].ParentNode;
168+
scriptDataParent.ReplaceChild(scriptDecodedNode, scriptData[i]);
169+
}
170+
171+
/* Loop through each licenseData element and decode it */
172+
for (int i = 0; i < scriptData.Count; i++)
173+
{
174+
/* Decode the gzipped compressed string */
175+
string licenseDataString = GunzipString(licenseData[i].InnerText);
176+
177+
/* Write new string to the XML node */
178+
licenseData[i].InnerText = "";
179+
180+
/* Generate a new fragment from the decoded XML */
181+
XmlDocumentFragment licenseDecodedNode = inputXMLdoc.CreateDocumentFragment();
182+
licenseDecodedNode.InnerXml = licenseDataString;
183+
184+
/* Replace the original node with the decode node */
185+
XmlNode licenseDataParent = licenseData[i].ParentNode;
186+
licenseDataParent.ReplaceChild(licenseDecodedNode, licenseData[i]);
187+
}
172188

173189
/* Find the File nodes */
174190
XmlNodeList filesNodes = inputXMLdoc.SelectNodes("LabTech_Expansion/PackedScript/File");

labtech_decode_scriptxml/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
35+
[assembly: AssemblyVersion("1.0.0.1")]
36+
[assembly: AssemblyFileVersion("1.0.0.1")]

sample/MultiScriptExport.xml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<LabTech_Expansion
2+
Version="105.244"
3+
Name="LabTech Script Expansion"
4+
Type="PackedScript">
5+
<PackedScript>
6+
<NewDataSet>
7+
<Table>
8+
<ScriptId>738</ScriptId>
9+
<FolderId>3</FolderId>
10+
<ScriptName>Wake On Lan*</ScriptName>
11+
<ScriptNotes>This script allows you to schedule a Wake on Lan.</ScriptNotes>
12+
<Permission>0,</Permission>
13+
<EditPermission>1</EditPermission>
14+
<ComputerScript>1</ComputerScript>
15+
<LocationScript>0</LocationScript>
16+
<MaintenanceScript>0</MaintenanceScript>
17+
<FunctionScript>0</FunctionScript>
18+
<LicenseData>H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/Ih4/L6b5ssmfZm129PjN9So/2n18l38+frVenlTrZZvXRzuP73p/PT59typqvJMffTefLfNmll2P0qf5NF9M8jrdeTBK93Z2d9O9R/d2Hu0cpC+/eHzXe+fx62ldrNqfzOumqJYAHn6g33++LmZH2d7e7qfT/Xx798GD+9u7u/nOdnbwcHf73vTB3sGD+zvnD893zfv8wuO7/pB+4+T/AdeRiILiAAAA</LicenseData>
19+
<ScriptData>H4sIAAAAAAAEAN2TTQrCMBCF94J36AVKm2iaFkpB/EMQFAT3YxshUFNJp+DxbWKqsQsP4CrzvZcMMw+Sn0ot77gChGI6CYL8xa2FHtcP1GDcjRR11QbRYBxBw02g0J62rZsL1J7wanbuL8lGFYRmScJ4yuI8+na+rm87WRVAKUnKuQgJ5ywkRMQhpBkJZyWnKWfxNbuSoYt9YIeP/OlduxOK+3udRYl2kjxyldM3nbK8q4znkb8tGW1PRzwb8XzEzAum0ViYGMzptGWjUKpOGP1dO+/Q7uVN2idD6ZydqoRCsMv0ro9+JJ8UfsRCf8TC0r/OZWD3EZ7STZ1oFwMAAA==</ScriptData>
20+
<ScriptVersion>1296657850</ScriptVersion>
21+
<ScriptGuid>a2216c4e-1775-11e0-a891-3c728750f9f1</ScriptGuid>
22+
<ScriptFlags>1</ScriptFlags>
23+
<Parameters></Parameters>
24+
</Table>
25+
</NewDataSet>
26+
<ScriptFolder>
27+
<NewDataSet>
28+
<Table>
29+
<FolderID>3</FolderID>
30+
<ParentID>0</ParentID>
31+
<Name>Actions</Name>
32+
<GUID>62da1b4f-7ca5-465c-ae8e-49f96763c80e</GUID>
33+
</Table>
34+
</NewDataSet>
35+
</ScriptFolder>
36+
</PackedScript>
37+
<PackedScript>
38+
<NewDataSet>
39+
<Table>
40+
<ScriptId>6511</ScriptId>
41+
<FolderId>3</FolderId>
42+
<ScriptName>Uninstall Trend Micro OfficeScan</ScriptName>
43+
<ScriptNotes>Auto Created Script</ScriptNotes>
44+
<Permission>1,2,3,4,5,6,9,11,500,</Permission>
45+
<EditPermission>1,2,3,4,5,6,9,11,500,</EditPermission>
46+
<ComputerScript>1</ComputerScript>
47+
<LocationScript>0</LocationScript>
48+
<MaintenanceScript>0</MaintenanceScript>
49+
<FunctionScript>0</FunctionScript>
50+
<LicenseData>H4sIAAAAAAAEAFWPzQrCMBCE74LvkAdoaFL6R1kCouJFQVT0vCZbCEga0hbs29sWhXpYlpnh22HhaDW5lnbYoYLb4ElJiOcNl95tm951FJSAeKFg//Y2TAypBxlHrcEhYhsf7IslIhpH5iyrkrRKS3Y+QbwA4KqD9d2dQmsbN13+N775obdGPeuilEYjF4XUXErKOZYouBCZyHLEsab+8TMA8fKf9eoD5Tai4N8AAAA=</LicenseData>
51+
<ScriptData>H4sIAAAAAAAEAO2ZUW/aMBDH3yftO1iaeJoCcSBpi1gkFqBDhVI1sL0gTSYxkzXjIMe07NvPCQkNqLiVGoul2lN858SKf/nf+Q46fsDJWvSQQO7HDwB0dnacGtLsbwVHyeyAYBrGoJFP3CGOVlhgXvBd02iBaMGxW+y7vIlEzIWdxqHj4K7rDQndxfLiEoYBMswLGBgQYsdAl8g0TNM2bQchEzrLfJX0gfSdG8WXzpbzBV7vd9ENRPYC2SjzDzYstYeh61idRsEs7hK6tclySQLsB4jVOo3MWbzFOgLTPLJbR7ZdYBRx4ZpyD8k183kRE4RtcOLfj7O5STwiK5I+kg+zmSELMRMo3aCcLZpFTE9kFKgsBSrYvFKwmjEaBb/BMuLgHq+iB0T/E7NUwFJKhP0C0/HXsY/5A+YguUjBaSEHq0QOWo4CXRyAEFOZhQrstDCzymZmnS0+eyRGC4pzicVaeDWrpDFldO5wpeHJMQvBmAQ80guvVSV40DYV9MSKklhg9jynZOFs9BZedqWC8wVeax5t/2jF5bwfXExwEcuiTCuvi0rxglDB69vNaDz3J4Ppj+59f54mtDSfze88IyBUprnbqRfx9dzbcDmZF+rzMYmDertLafQIZoywWCB6oqxLyovXQHfbad0jz6FoKR4Rz2udlvJbXFYpNSrPlRRmcqzsedbrdS3HyVWlmCmQWa0TkktkXbODXNhy+CRtaRyJW3oO5S0dBYF/3n+QtkGFQV6r55o3Gd/Npv37Ya/2vJYTcNnooB4vvZU5X3F5IqhLbmAq1cG8rvfLgelKArD0DuZ8Xd8qJniLA9DY7mryunSATR61P9cojh8jHn4RC8w/OU1TD9DSWxydUWu3TvM82uibwZTevrS0Kk1VX778u5/bHiBCcVhKpQlL72TOltiKzfL+QAX+zPP6vq8nIKvV1yjpaUpZpXcyWiNTXWgchF3JnN5Pl/F8GA66w1G/p4dd6d3Ge4tCq/Ry/61R2CxDXbeTKRje+tPuSJe0/rk2ScXtLPn9DMLK7ewP5L843RM1Tx4AAA==</ScriptData>
52+
<ScriptVersion>1</ScriptVersion>
53+
<ScriptGuid>bf781dca-071c-11e6-a8a0-005056aa016f</ScriptGuid>
54+
<ScriptFlags>0</ScriptFlags>
55+
<Parameters></Parameters>
56+
</Table>
57+
</NewDataSet>
58+
<ScriptFolder>
59+
<NewDataSet>
60+
<Table>
61+
<FolderID>3</FolderID>
62+
<ParentID>0</ParentID>
63+
<Name>Actions</Name>
64+
<GUID>62da1b4f-7ca5-465c-ae8e-49f96763c80e</GUID>
65+
</Table>
66+
</NewDataSet>
67+
</ScriptFolder>
68+
</PackedScript>
69+
</LabTech_Expansion>

0 commit comments

Comments
 (0)