Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 734359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:21:51+00:00 2026-05-14T07:21:51+00:00

I want to run a batch file, which I do via the following: <CustomAction

  • 0

I want to run a batch file, which I do via the following:

<CustomAction Id='InstallFilter' FileKey='install' ExeCommand='' Execute='deferred'  />

<InstallExecuteSequence>
    <Custom Action='InstallFilter' Before='InstallFinalize' />
</InstallExecuteSequence>

This will execute the batch file, but it runs in C:\Windows\System32 (or something like that). I want it to run in the directory that the file is found in. It won’et let me specify a Directory attribute with a FileKey attribute. How can I tell the installer to run out of a specific directory, preferably by the directory ID.

Also, when I try to uninstall my app with script, I get an error message saying “There is a problem with the Windows Installer package. A program required for the install to complete could not be run.” This makes sense, as by the time the script gets run, the files have been removed. The question is:

  1. How do I specify that my action should only be run on install, not uninstall?

  2. How do I uninstall this current copy?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:21:52+00:00Added an answer on May 14, 2026 at 7:21 am

    The installer is running as the TrustedInstaller user (an admin) in elevated mode. By default, cmd.exe working folder when elevated is C:\Windows\System32. There’s no way (or at least I don’t know of one) to force the working folder for elevated cmd.exe to be different. (Consider the security implications of running elevated cmd -c some.cmd from random folder)

    You script can take the folder it’s located in and change the current folder to it like this:

    setlocal
    pushd %~dp0
    
    rem ... script logic ...
    
    popd
    endlocal
    

    You can look up the different conditions that will allow you to specify when your custom action needs to execute in @Cheeso answer to his own question how to run custom action on uninstall only. (Don’t want to duplicate that information unnecessarily)

    Update: If NOT INSTALLED doesn’t work for you specific scenario, try NOT REMOVE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run a batch file which contain command arp -d * (
I want to run my perl script< ftp_files_copy.pl> on windows through batch file<Run_perl_script.bat> at
I want to search a file in the current directory from which the batch
Got this batch file which does exactly what I want, however I don't fully
I want to run a batch file through java program. The batch file itself
I have a batch file which is in a directory and must be run
I want to run this as a batch rather than through the command line:
I want to run the following jquery code on every page in my website.
I wanted to run a .cmd file from Java. I have something which works
I'd like to request some help in creating a Batch file to run on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.