CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    Apr 2010
    Posts
    17

    Programmatic way to run a program as administrator in Windows 7

    Hi

    I have created a VB6 dll named 'PDFConversion.dll' and wanted to register in windows7.
    But it fails with access denied error. How do I register it as administrator(ie. Run as administrator') programmatically without the user having to right-click the .dll and say Run As Administrator.
    So on double clicking the dll user should be prompt with the admin user name and password if he is not as admin user (Same as when he right click and select run as administrator' option). I am using vb6

    Thanks
    Minu

  2. #2
    Join Date
    Apr 2009
    Posts
    394

    Re: Programmatic way to run a program as administrator in Windows 7

    use an install package...



    Good Luck

  3. #3
    Join Date
    Apr 2010
    Posts
    17

    Re: Programmatic way to run a program as administrator in Windows 7

    Thanks for the reply
    Could you please specify which install package and how to create it.

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Programmatic way to run a program as administrator in Windows 7

    Quote Originally Posted by minums View Post
    So on double clicking the dll user should be prompt with the admin user name and password if he is not as admin user (Same as when he right click and select run as administrator' option). I am using vb6
    You cannot "run" a dll file! It is just an application extension which helps to make your program work.

  5. #5
    Join Date
    Apr 2010
    Posts
    17

    Re: Programmatic way to run a program as administrator in Windows 7

    Yes, i mean to say register the dll

  6. #6
    Join Date
    Apr 2010
    Posts
    17

    Re: Programmatic way to run a program as administrator in Windows 7

    Actually what i do now is, run cmd.exe with the option
    'run as admin' and register the dll with command "regsvr32<space> dll path.
    These process i need to do programatically so that the user need not do all such stuffs.
    Last edited by minums; June 24th, 2010 at 02:04 AM.

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Programmatic way to run a program as administrator in Windows 7


  8. #8
    Join Date
    Apr 2010
    Posts
    17

    Re: Programmatic way to run a program as administrator in Windows 7

    What to be done with this?

  9. #9
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Programmatic way to run a program as administrator in Windows 7

    Use a trusted installer
    Always use [code][/code] tags when posting code.

  10. #10
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Programmatic way to run a program as administrator in Windows 7

    If your application runs as administrator, it could call the RegisterServer() procedure of your dll.
    So it is registered by an administrative process.
    Works only if your program is running with administration rights.

  11. #11
    Join Date
    Apr 2010
    Posts
    17

    Re: Programmatic way to run a program as administrator in Windows 7

    My application runs in power user platform not administrator

  12. #12
    Join Date
    Apr 2010
    Posts
    17

    Re: Programmatic way to run a program as administrator in Windows 7

    I have installed Visual Studio Installer. Is that trusted installer? how to use it?
    How installer address my requirement?
    Please tell me

  13. #13
    Join Date
    Apr 2009
    Posts
    394

    Re: Programmatic way to run a program as administrator in Windows 7

    Yes it is, it is the replacement to the PDW, its version, if you have the right one is 1.1. How to use it? Read the documentation that came with it! By using an installer to install your program/dll/etc. It will install the object to where it belongs and if it needs to be registered, it will do it for you. No need to mess with the registry or regsrv32. It puts you or your user just a double click away from having the program/dll/etc installed on the machine and ready for use. Reboot may be required



    Good Luck

  14. #14
    Join Date
    Apr 2010
    Posts
    17

    Re: Programmatic way to run a program as administrator in Windows 7

    Thanks for your reply
    Actually i have a software with the basic installation done. as the part of customization, we make changes in code. This can be dll change, exe or DB changes. All these changes are given as upgrade. Can i use this installer to do the same?
    While upgrading all the dll's will be simply registered with DLLSelfRegister function. Now i just want to register a dll in client machine instead of installing the software. So on a double click the registration should take the path of 'Run as administrator'
    For this which function should i use instead of DLLSelfRegister.

  15. #15
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Programmatic way to run a program as administrator in Windows 7

    No, but that's why ClickOnce Deployment was invented. Unfortunately, after VB6.

    Read up on VS2010 ClickOnce Deployment.

    You can deploy an app, and have it automatically download updates.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured