Sample code for 30+ languages & platforms
Android™ Requires Chilkat v11.7.0+

Remove the Authenticode Signature from an MSI, PowerShell, or VBScript File

See more Code Signing Examples

Demonstrates how to remove the Authenticode signature from a Windows Installer package (.msi), a PowerShell file (.ps1, .psm1, .psd1), or a VBScript file (.vbs). Removing the signature from these file types requires Chilkat v11.7.0 or later.

Chilkat Android™ Downloads

Android™
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    boolean success = false;

    //  This example requires the Chilkat API to have been previously unlocked.
    //  See Global Unlock Sample for sample code.

    //  Starting in Chilkat v11.7.0, RemoveSignature can remove the Authenticode signature from
    //    - Windows Installer packages (.msi)
    //    - PowerShell scripts, modules, and data files (.ps1, .psm1, .psd1)
    //    - VBScript files (.vbs)
    //  in addition to EXE and DLL files.

    //  This example removes the signature from a signed PowerShell script.
    //  To remove the signature from an .msi or a .vbs, pass the path of that file instead.
    String path = "C:/someDir/Deploy.ps1";

    CkCodeSign codeSign = new CkCodeSign();

    //  The file is modified in place.  Keep a copy if the signed file is still needed.
    //  
    //  For a PowerShell or VBScript file, the signature comment block is removed from the end of the file.
    //  For an MSI, the digital signature stream and the extended signature stream (MsiDigitalSignatureEx)
    //  are removed from the package.
    success = codeSign.RemoveSignature(path);
    if (success == false) {
        Log.i(TAG, codeSign.lastErrorText());
        return;
        }

    Log.i(TAG, "The signature was removed.");

    //  The file is now unsigned, so VerifySignature returns false.
    CkJsonObject sigInfo = new CkJsonObject();
    boolean valid = codeSign.VerifySignature(path,sigInfo);
    Log.i(TAG, "has a valid signature: " + String.valueOf(valid));

  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}