Results 1 to 3 of 3

Thread: How to open folder and file in place with admin status

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default How to open folder and file in place with admin status

    Hello!

    I created a software that reads a file from a closed folder when it is started, but when it detects that the file and the folder don't exist, it creates a new one with predefined names.

    The problem is that the software is hold in the Crogram files (x86) folder, which is a place which require admin status for files and folder creation (and I don't know why I don't have that permission despite being administrator, but anyway). So what happens is that if I put the .exe plus .dll files in a common folder, the software runs ok, but when the software is put inside Program Files (x86), it doesn't open and the folder and the file is not created.

    How should I proceed in this case? Is there a function in Qt or C++ that ask the user for permission and, once the permission is given, it would open the folder and create the file?

    Thanks!


    Momergil

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to open folder and file in place with admin status

    I guess you have to run app as an administrator to get those permissions.

    Right click on the app and select 'run as administrator' (on w7, vista will have something similar but I can't tell atm).

  3. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to open folder and file in place with admin status

    One solution is to make sure your folder location is somewhere less restricted, like 'my documents' or similar. I think you can do this with desktop services:

    http://developer.qt.nokia.com/doc/qt...pservices.html

    use storageLocation() and enum QDesktopServices::ApplicationsLocation
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Replies: 3
    Last Post: 26th September 2011, 14:14
  2. Open file/folder in finder with selection
    By anjul.chauhan in forum Qt Programming
    Replies: 0
    Last Post: 20th June 2011, 07:10
  3. Replies: 3
    Last Post: 23rd May 2011, 14:36
  4. Multiplateform open folder in explorer
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 10th January 2011, 08:27
  5. Replies: 1
    Last Post: 20th December 2010, 21:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.