Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How could i develop a running-once application

How could i develop a running-once application

Scheduled Pinned Locked Moved C#
question
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    ginee
    wrote on last edited by
    #1

    Hi, How can i develop a application which can execute once and the executive file would be removed from device. Like: After program show a message, this executive file is removed. I got a straight way that after the application executes, deleting this application file. But how? Running program couldn't delete itself. Any suggestion is welcome. Thanks! Regards, ginee

    M D N 3 Replies Last reply
    0
    • G ginee

      Hi, How can i develop a application which can execute once and the executive file would be removed from device. Like: After program show a message, this executive file is removed. I got a straight way that after the application executes, deleting this application file. But how? Running program couldn't delete itself. Any suggestion is welcome. Thanks! Regards, ginee

      M Offline
      M Offline
      mav northwind
      wrote on last edited by
      #2

      Hi! I don't think that it is possible to delete a program that's running, but you could add an entry to HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce to delete the file at the next system start. Regards, mav

      1 Reply Last reply
      0
      • G ginee

        Hi, How can i develop a application which can execute once and the executive file would be removed from device. Like: After program show a message, this executive file is removed. I got a straight way that after the application executes, deleting this application file. But how? Running program couldn't delete itself. Any suggestion is welcome. Thanks! Regards, ginee

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        You can't delete the .EXE file if it's running, or any of it's loaded .DLL's for that matter. Your app would have to launch an external process, that handles changing out the executable you want to replace, then quit. This external process (.EXE) would have to wait for the original app to quit, then it could change out any of the files that it needs to upgrade or modify, then when done, launch the original app, then quit. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        1 Reply Last reply
        0
        • G ginee

          Hi, How can i develop a application which can execute once and the executive file would be removed from device. Like: After program show a message, this executive file is removed. I got a straight way that after the application executes, deleting this application file. But how? Running program couldn't delete itself. Any suggestion is welcome. Thanks! Regards, ginee

          N Offline
          N Offline
          Nick Parker
          wrote on last edited by
          #4

          A simple solution would be to use a batch file (.bat) to run your application. You could run the executable from within the batch file and when you have exited the main application it could delete the executable. I use something like the following to quickly write a test sample, compile it, run it and then delete it when the app is done:

          csc /target:winexe test.cs
          pause
          test.exe
          del test.exe

          - Nick Parker
          My Blog | My Articles

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups