Results 1 to 14 of 14

Thread: How do i run my program in administrator mode

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    .NET Framework
    .NET 4.5
    Join Date
    Nov 2008
    Posts
    481
    Reputation
    131

    How do i run my program in administrator mode

    I try to change this to requireAdministrator mode in app.manifest
    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

    but then it say clickonce doesnt support requireAdministrator, even if i uncheck clickonce, when i publish it come back on. How do i run my program in admin mode?

  2. #2
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    15,209
    Reputation
    2859
    "Publish" is ClickOnce, you can't use that with requireAdministrator.

    If the question is how do you deploy your application without ClickOnce, then there are several answers, this one for example: Microsoft Visual Studio 2017 Installer Projects - Visual Studio Marketplace
    [xcode=vb] code here [/xcode] - see bbcode list or use formatting buttons in posting editor.

    Visual Studio Community 2017

  3. #3
    .NET Framework
    .NET 4.5
    Join Date
    Nov 2008
    Posts
    481
    Reputation
    131
    Is there a way to run the program as admin after it was published?

  4. #4
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    15,209
    Reputation
    2859
    Startng a new Process with 'runas' Verb is possible, also for ClickOnce app.
    [xcode=vb] code here [/xcode] - see bbcode list or use formatting buttons in posting editor.

    Visual Studio Community 2017

  5. #5
    .NET Framework
    .NET 4.5
    Join Date
    Nov 2008
    Posts
    481
    Reputation
    131
    so what you are saying is, i need to make another program just to run this program as admin

  6. #6
    .NET Framework
    .NET 4.5
    Join Date
    Nov 2008
    Posts
    481
    Reputation
    131
    how do i refer to the clickonce app in the filename . The fullpath of the appref-ms file?

  7. #7
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    15,209
    Reputation
    2859
    Quote Originally Posted by Zexor View Post
    how do i refer to the clickonce app in the filename . The fullpath of the appref-ms file?
    clickonce exe path - Google-search > Reflection.Assembly.GetExecutingAssembly.Location
    [xcode=vb] code here [/xcode] - see bbcode list or use formatting buttons in posting editor.

    Visual Studio Community 2017

  8. #8
    .NET Framework
    .NET 4.5
    Join Date
    Nov 2008
    Posts
    481
    Reputation
    131
    right now i made a bat file with the appref-ms name in it and put that as filename and it work. If i put the ms file name in the filename field, it give me error.

  9. #9
    .NET Framework
    .NET 4.5
    Join Date
    Nov 2008
    Posts
    481
    Reputation
    131
    That would get your own location, but how do you get another clickone app's location?

  10. #10
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    15,209
    Reputation
    2859
    Have no idea (unless it was deployed in the same location) - I thought you were restarting your own app as admin.
    [xcode=vb] code here [/xcode] - see bbcode list or use formatting buttons in posting editor.

    Visual Studio Community 2017

  11. #11
    .NET Framework
    .NET 4.5
    Join Date
    Nov 2008
    Posts
    481
    Reputation
    131
    ah i guess that works too , i was using another app to start it as admin

  12. #12
    .NET Framework
    .NET 4.5
    Join Date
    Nov 2008
    Posts
    481
    Reputation
    131
    Ok I found out that if i use Reflection.Assembly.GetExecutingAssembly.Location to open the app, Update doesn't work anymore. I usually use Reflection.Assembly.GetExecutingAssembly.GetName.V ersion to get the version but now it gives me nothing. So i went back to using the bat file to run the appref-ms location.

  13. #13
    .NET Framework
    .NET 4.5
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    15,209
    Reputation
    2859
    I read somewhere that "check for update = before application starts" is set for update to happen before the new admin instance is started.
    For manual updating do it before you start the new admin ("non-network deployed") instance.

    Quote Originally Posted by Zexor View Post
    I usually use Reflection.Assembly.GetExecutingAssembly.GetName.V ersion to get the version but now it gives me nothing.
    Shouldn't be affected, don't know what you mean by "gives me nothing".
    [xcode=vb] code here [/xcode] - see bbcode list or use formatting buttons in posting editor.

    Visual Studio Community 2017

  14. #14
    .NET Framework
    .NET 4.5
    Join Date
    Nov 2008
    Posts
    481
    Reputation
    131
    I do manual Update when i am running the App, i dont like having that update window popup before the app runs. I use My.Application.Deployment.Update()

Similar Threads

  1. GUI runs while in debug mode but executable did not run...
    By dtvonly in forum VB.NET General Discussion
    Replies: 1
    Last Post: 08-26-2014, 7:01 PM
  2. How to run a setup.exe in passive mode?
    By Koz in forum Deployment
    Replies: 1
    Last Post: 12-30-2011, 3:46 PM
  3. Replies: 4
    Last Post: 08-01-2010, 7:36 AM
  4. Console app will not run in DOS Mode
    By evad4682 in forum Console Application
    Replies: 1
    Last Post: 12-29-2007, 7:46 AM
  5. Replies: 13
    Last Post: 09-26-2006, 6:14 PM

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
  •