Announcement

Collapse
No announcement yet.

How to delete a specific file in Program Files?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to delete a specific file in Program Files?

    How to delete a specific file in Program Files

    File.Delete(_PROGRAMFILES.."\\Microvirt\\MEmu\\config.ini", false, false, true, nil);

    I want to delete only the config.ini

  • #2
    I believe that only an administrative account can delete files from Program Files. This means that your program should run with elevated privileges (i.e. run as administrator) to be able to do this.
    Bas Groothedde
    Imagine Programming :: Blog

    AMS8 Plugins
    IMXLH Compiler

    Comment


    • #3
      I'm running it as an administrator

      Comment


      • #4

        File.Delete(_ProgramFilesFolder.."\\Microvirt\\MEm u\\config.ini", false, false, true, nil );

        how to rightly suggest IP run as administrator

        Comment


        • #5
          Thanks for helping me!

          It worked, however I want him to delete the file that is in:
          C:\Program Files\Microvirt\MEmu


          But he is deleting in:
          C:\Program Files (x86)\Microvirt\MEmu

          Comment


          • #6
            You quoted Program Files in your TITLE and sample code

            Code:
            if System.Is64BitOS() then
            local sPath ="C:\\Program Files (x86)\\Microvirt\\MEmu"
            else
            local sPath ="C:\\Program Files\\Microvirt\\MEmu"
            end
            sFile = File.DoesExist(sPath.."\\config.ini"};
            if sFile then
            File.Delete(sFile, false, false, true, nil );
            end
            You are learning nothing and do NOT have a clue
            Please stop SPAMMING this forum

            Comment


            • #7
              Be more polite your ignorant.

              I am learning!

              I'm not doing SPAMMING

              Comment


              • #8
                Still gave error

                Attached Files

                Comment


                • #9
                  PF = Shell.GetFolder(SHF_PROGRAMFILES);
                  if File.DoesExist(PF.."\\config.ini") == true then
                  File.Delete(PF.."\\config.ini", false, false, false, nil);
                  end[/CODE]

                  Comment


                  • #10
                    Code:
                    PF = Shell.GetFolder(SHF_PROGRAMFILES);
                    if File.DoesExist(PF.."\\config.ini") == true then
                    File.Delete(PF.."\\config.ini", false, false, false, nil);
                    end

                    Comment


                    • #11
                      PHP Code:
                      if (System.Is64BitOS()) then
                      File
                      .Delete("C:\\Program Files\\Microvirt\\MEmu\\config.ini"falsefalsetruenil );
                      else
                      File.Delete("C:\\Program Files (x86)\\Microvirt\\MEmu\\config.ini"falsefalsetruenil );
                      end
                      error 
                      Application.GetLastError();
                      if (
                      error ~= 0then
                      Dialog
                      .Message("Error"_tblErrorMessages[error], MB_OKMB_ICONEXCLAMATION);
                      else
                      Dialog.Message("Info""File has been delete"MB_OKMB_ICONINFORMATION);
                      end 

                      Comment


                      • #12
                        Thank you I did almost like you and it worked.


                        if (System.Is64BitOS()) then
                        File.Delete("C:\\Program Files\\Microvirt\\MEmu\\config.ini", false, false, true, nil );
                        File.Delete("C:\\Program Files (x86)\\Microvirt\\MEmu\\config.ini", false, false, true, nil);
                        else
                        end
                        error = Application.GetLastError();
                        if (error ~= 0) then
                        Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
                        else
                        Dialog.Message("Info", "File has been delete", MB_OK, MB_ICONINFORMATION);
                        end

                        Comment


                        • #13
                          your script makes no sense .....
                          to delete the 2 ini files you don't have to check the architecture of the O.S.
                          2 lines of code were enough.....
                          as already recommended by Ip and Colc you have to study .....

                          Comment


                          • #14
                            I already studied! it makes sense yes, so much that i decided

                            Comment

                            Working...
                            X