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 8770819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:38:05+00:00 2026-06-13T17:38:05+00:00

I want to first rename an existing file ‘My program old’ to ‘My program

  • 0

I want to first rename an existing file ‘My program old’ to ‘My program v2’ but only if ‘My program v2’ doesn’t already exist.

Then I want to rename ‘My program’ to ‘My program old’ but only if ‘My program old’ doesn’t already exist.

And then I want to install ‘My program’ from the installer but only if ‘My program’ doesn’t already exist.

I would be very grateful for any guidance !

  • 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-06-13T17:38:06+00:00Added an answer on June 13, 2026 at 5:38 pm

    I would give a try to something like this. In the ssInstall stage of the CurStepChanged event, which occurs just before the installation process starts, just check if the file doesn’t exist with the FileExists function, and if not, then just call the RenameFile function, which will silently fail if the source file doesn’t exist, so you don’t need to care if the source file exists. In the [Files] section you can then use the onlyifdoesntexist flag for your last requirement. You can follow the commented version of this script if you want:

    [Setup]
    AppName=My Program
    AppVersion=1.5
    DefaultDirName={pf}\My Program
    
    [Files]
    Source: "My program"; DestDir: "{app}"; Flags: onlyifdoesntexist
    
    [Code]
    function GetFileName(const AFileName: string): string;
    begin
      Result := ExpandConstant('{app}\' + AFileName);
    end;
    
    procedure CurStepChanged(CurStep: TSetupStep);
    begin
      if (CurStep = ssInstall) then
      begin
        if not FileExists(GetFileName('My program v2')) then
          RenameFile(GetFileName('My program old'), GetFileName('My program v2'));
        if not FileExists(GetFileName('My program old')) then
          RenameFile(GetFileName('My program'), GetFileName('My program old'));
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my project i want to first view country in combobox then selecting country
I'm making a query to a MongoDB and I only want the first object.
I have a file I need to rename to that of an existing file.
I have hundreds of file of same format. I want to rename the files
Is it safe to call rename(tmppath, path) without calling fsync(tmppath_fd) first? I want the
I have a map and I want the first column i.e (*it).first to be
I have an object which I first want to rotate (about its own center)
I have a annoying problem .. I want my first 4 items in a
Given 2 html sources, I want to first extract the main content out of
This is very basic magento question i guess. I want to first get all

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.