• sp_configure 'Ole Automation Procedures', 0;

    go

    reconfigure;

    go

    sp_configure 'show advanced options', 0;

    go

    reconfigure;

    go

    This kind of feature disabling is dangerous, if you have other functionality on the server that relies on that,

    those will stop working.

    I would add code to check the configuration status first and at the end

    restore status whatever it was.