Modifying InfoPath manifest.xsf file from script (2/5)

Part 2 of 5: Unpacking the XSN

To unpack XSN one should use extract.exe utility. It can be found in the %SystemRoot%system32 directory or in the Microsoft Cabinet Software Development Kit. For the command usage details just run “extract /?”.

In this part we will also introduce several auxiliary functions that will be extensively used throughout the entire discussion topic.

var ExtractExeLocation = "%SystemRoot%\SYSTEM32";

var ExtractExe = Combine(ExtractExeLocation, "extract.exe");


function Combine(dir, file)


      return dir + "\" + file ;



function QuoteStr(string)


      return (""" + string + """);



function Exec(string, flagWait)


      if (flagWait == null)

            flagWait = true;

      var WScriptShell = WScript.CreateObject("WScript.Shell");

      return WScriptShell.Run(string, 0, flagWait);



function ExtractFilesFromXSN(xsnInputPath, outputDirectory)


      var Parameters;


      // add the location to place extracted files,

      // a flag "/Y" that prevents prompting before overwriting

      // an existing file, and a flag "/E" that orders to

      // extract all files

      if (outputDirectory != null)

            Parameters = " /Y /E /L " + QuoteStr(outputDirectory);



            + Parameters

            + " " + QuoteStr(xsnInputPath), true);



Now we have a tool to unpack XSN. All of the InfoPath form template files are accessible for changing. In the next part of the series we will be modifying the manifest itself.

Comments (3)

  1. Ken Brubaker says:

    How to programmatically extract/manipulate/combine an InfoPath Template (XSN) file.

  2. Chandrashekhar Bhadane says:

    Nice Article 🙂

    Another simple way to extract XSN file is,

    expand -F:* "C:Old XSNTesting.xsn" "C:ExtractedXSN"

    Above command will extract Testing.XSN file to C:ExtractedXSN folder.

Skip to main content