Move file during shutdown

This is a discussion on Move file during shutdown within the Windows Programming forums, part of the Platform Specific Boards category; I have a program located here: c:\Program\test.exe THe last thiing the program does is to reboot the computer. However, I ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    41

    Move file during shutdown

    I have a program located here:
    c:\Program\test.exe

    THe last thiing the program does is to reboot the computer. However, I have another program test2.exe. Before the computer shuts down I want test.exe to be deleted. Also, test2.exe shall take the place of test.exe, that is, the same directory and the name shall change to test.exe.

    Is there some runonce thing I can use in Windows for this matter ?

  2. #2
    Registered User
    Join Date
    Oct 2005
    Posts
    12
    Hmm.. Here is an easy way to do it.
    Put this in the end of test.exe:

    system("start rename.exe");
    this will start the rename.exe and since the test.exe is done running this will be exited.

    Inside rename.exe:
    system("del test.exe");
    system("ren test2.exe test.exe");

    This should delete test.exe and rename test2.exe -> test.exe.

    then u can run test.exe again:P Im not sure what you are coding so kinda hard to help:P but u get the idea and im sure u can figure this out urself
    Last edited by Tuborgrules; 11-07-2005 at 03:57 AM.

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    41
    Thanks for the help. One problem. The system call doesn't return until the task is completed and returns to it. That is, the rename.exe need to return to the system call. However, it cannot remove test1.exe if it still is running.

    Do you have any idea to avoid this?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 04:39 AM
  2. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 08:01 PM
  3. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 09:19 PM
  4. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21