Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9140165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:28:51+00:00 2026-06-17T09:28:51+00:00

When my application is using an app.manifest, and the line below is set as

  • 0

When my application is using an app.manifest, and the line below is set as shown

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

the code

textBox1.Text = Path.Combine(Application.StartupPath, "setupws.exe");

returns "\\server\myApp\setupws.exe"

If I change the requestedExecutionLevel to "asInvoker", or remove the app.manifest altogether, it returns "F:\myApp\setupws.exe". Which is what I need.

Is there a way to get Application.StartupPath to behave the way I want and still use requireAdministrator?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:28:51+00:00Added an answer on June 17, 2026 at 9:28 am

    I can’t think of any way to change the response you’re getting, but you can always try to remap back the UNC to local – to do this, you’ll need to call out to the underlying Win32 calls (C dll calls) using “Platform Invoke”, or “PInvoke”; the syntax for referring to a win32 call looks a bit like:

    [DllImport("mpr.dll", CharSet=CharSet.Auto, SetLastError=true)]
    [return:MarshalAs(UnmanagedType.Bool)]
    public static extern bool WNetGetConnection(
        [MarshalAs(UnmanagedType.LPTStr)] string localName, 
        [MarshalAs(UnmanagedType.LPTStr)] StringBuilder remoteName, 
        ref int length);
    

    (What this is doing is mapping the unmanaged call/types to their managed equivalents, as well as telling the compiler “Hey, there’s code outside of this stuff that I’m going to call”)

    WNetGetConnection is a fairly ho-hum Windows function: give it a drive letter, and you’ll get back a UNC path, if it’s mapped to one. We’ll cycle through the “known drive letters”, feeding each one in turn to this call, and if we get any partial matches with the returned UNC name and the path we’re trying to “reverse map”, we’ll replace the UNC part of the path with the corresponding drive letter and we’re done:

    public string GetLocalPathForUnc(string uncName)
    {
        var mapped = Environment.GetLogicalDrives().Select(drive => 
        {
            drive = drive.Substring(0,2);
            var buffer = new StringBuilder(0xff);
            int length = 0xff;
            WNetGetConnection(drive, buffer, ref length);
            return new {Drive = drive, Unc = buffer.ToString()};
        });
        var match = mapped
                .Where(ob => 
                     !string.IsNullOrWhiteSpace(ob.Drive) && 
                     !string.IsNullOrWhiteSpace(ob.Unc))
            .FirstOrDefault(ob => uncName.ToLowerInvariant().StartsWith(ob.Unc.ToLowerInvariant()));
        return uncName.Replace(match.Unc, match.Drive);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an android app using code from a normal java application. In
How to block installation of other application using device administrator app in android. How
In my application I am using in app billing (Android). I want to fetch
I am writing an app to connect to a third party application using REST
I developed an iPhone application using PhoneGap everything works fine, I sent the app
I am creating an application using Core Data. But When I run my app
I'm using in-app purchase in my application and storing the products in PurchaseDatabase as
Im currently developing an In-House Enterprise application. I will publish the app using Apple
am using the application in this link http://www.jeasyui.com/tutorial/app/crud2.php .I have added one more column
I have an application that runs using as AsInvoker manifest, this uses ProcessStartInfo to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.