Heaventools

   English English  Deutsch Deutsch

home  products  resource tuner console  sample scripts library

Add or Replace an UAC Manifest for Windows User Access Control

This code shows the way you can edit or add a manifest to the compiled executable file. You can specify whether to replace the existing manifest, or add a new manifest resource to the executable file that doesn't have one.

To demonstrate this functionality, we have prepared a sample script and a test application. After installing Resource Tuner Console on your computer, you can find the "Demo Scrips" folder within the RTC installation directory, containing the test application DemoApp1.exe in the "\Src" folder.

The script will perform the following operations:

  • Add an application manifest to the DemoApp1.exe file.
  • Add icons from .ICO and .PNG files located in the "\Src" folder. This operation is optional and can be commented out if not needed.

The resulting modified file will be saved in the directory named "\Release".
You can review the changes made to the Resource Tree in the log filertc.log.

Note: Ensure that there are no line breaks in the script code, as VBScript requires the entire command to be on one line.

Edit XML Manifest

Sub Main
  PEFileProxy.PostDebugString "PE file header checksum updating is enabled." 
  PEFileProxy.UpdateCheckSum = True

  PEFileProxy.PostDebugString "The creation of a backup copy is disabled." 
  PEFileProxy.CreateBackUp = False
  
  'Set Language to default value
  LangID = 0 
  
  'Retrieve and output CodePage a log file
  CodePage = ScriptUnit.CodePageFromLangID(LangID)
  PEFileProxy.PostDebugString "CodePage value for English-US: " & CStr(CodePage)

  ' Open the file for editing.
  ' Once the file is opened successfully, check if the file contains resources.
  ' If not, create the necessary resources.

  If (PEFileProxy.OpenFileEx (".\src\DemoApp1.exe", True)) Then

    'Add XML Manifest

    PEFileProxy.PostDebugString "Add/edit XML Manifest..."
    ResourcesProxy.ChangeManifest EXE_MANIFEST, LangID, CREATE_IF_NOT_EXIST, 
".\src\exe_manifest.xml"

'------ Optional operations: Add or Replace Icons (for demo purposes) ------------

    PEFileProxy.PostDebugString "Change/add the full Vista icon set (10 icons)..."
    ResourcesProxy.ChangeIcon "", LangID, CREATE_IF_NOT_EXIST, REPLACE_IF_ITEM_EXISTS, 
".\src\vista_iconset.ico"

    PEFileProxy.PostDebugString "Sorting out the icons..."
    ResourcesProxy.SortGroupIcon "", True

    'Build and output the Resource Tree to show the changes made to the resources

    PEFileProxy.PostDebugString ""
    PEFileProxy.PostDebugString "Resource Tree built by RTC:"
    ResourcesProxy.ResourceTreeToLog
    PEFileProxy.PostDebugString ""
    
'--------------------------------------------------------------------------------

    'Save and close file
    PEFileProxy.PostDebugString "Saving the file as a new file..."
    PEFileProxy.SaveAsNewImage ".\release\DemoApp1.exe"

    PEFileProxy.PostDebugString "Closing the file..."
    PEFileProxy.CloseFile

  Else
    'Issue a warning in case of error
    PEFileProxy.PostDebugString "Error when opening this file."
  End If

End Sub

To view the changes made to the test EXE and DLL files, you can open them using Resource Tuner GUI.


SAMPLE SCRIPTS LIBRARY

Upon installing Resource Tuner Console, you will find the Demo Scripts folder nested within the RTC installation directory. This folder contains 12 subdirectories, each featuring script examples and sample executable files.

All the sample scripts are ready to run. To execute a sample script, simply select one of the .BAT files located within the respective Demo folders. When executed, the script will apply changes to the test EXE file. The resulting modified file will be created in a directory named Release, which resides in the same directory as the script.

 

The Complete Illustrated Step-by-Step Guide To Using Scripts

 Download Resource Tuner Console and learn how it can make you more productive.