register.xsh

Register .xsh extension to invoke XSharper

<?xml version="1.0" encoding="utf-8"?>
<xsharper xmlns="http://www.xsharper.com/schemas/1.0" requireAdmin="1">
    <versionInfo title="register" value="Register XSharper as default handler for .XSH file extension" Version="0.1.0.0" Copyright="(C) 2009 DeltaX Inc." />
    <set process="${=System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName}" />
    <set filename="${=string.Concat(Path.Combine(Path.GetTempPath(),Path.GetRandomFileName()),'.reg')}" />
    <try>
        <set cmdLine="${=${process}.Replace('\','\\')}" />
        <writetext to="${filename}" tr="expand trimStart multiline" encoding="ascii">

                REGEDIT4

                [HKEY_CLASSES_ROOT\.xsh]
                @="xshfile"
                "Content Type"="text/xml"
                
                [HKEY_CLASSES_ROOT\xshfile]
                @="XSharper Script"
                
                [HKEY_CLASSES_ROOT\xshfile\DefaultIcon]
                @="${cmdLine},1"
                [HKEY_CLASSES_ROOT\xshfile\Shell]
                [HKEY_CLASSES_ROOT\xshfile\Shell\Edit]
                [HKEY_CLASSES_ROOT\xshfile\Shell\Edit\Command]
                @="notepad.exe '%1'"
                [HKEY_CLASSES_ROOT\xshfile\Shell]
                [HKEY_CLASSES_ROOT\xshfile\Shell\Open]
                @="Execute"
                [HKEY_CLASSES_ROOT\xshfile\Shell\Open\Command]
                @="\"${cmdline}\" \"%1\" %*"
                [HKEY_CLASSES_ROOT\xshfile\Shell\OpenAndWait]
                @="Execute and wait"
                [HKEY_CLASSES_ROOT\xshfile\Shell\OpenAndWait\Command]
                @="\"${cmdline}\" //wait \"%1\" %*"
        </writetext>
        <shell>
                regedit
                <param>/s</param>
                <param>${filename}</param>
        </shell>
        <print>XSharper registration was successful</print>
    </try>
    <finally>
        <delete from="${filename}" />
    </finally>
    

</xsharper>