Unable to map drive in VS2005 over Vista

I

itaymaya

After migrating from XP to Vista, the following piece of code
Process.Start("subst", drive + " " + path);
as well as
DefineDosDevice(0, drive, path); // importing kernel32.dll
simply stopped mapping drives.

The funny thing is that running "subst [drive] [path]" from command
line performs this mapping.

Any Ideas?
 
J

Jesse Houwing

* (e-mail address removed) wrote, On 25-7-2007 13:12:
After migrating from XP to Vista, the following piece of code
Process.Start("subst", drive + " " + path);
as well as
DefineDosDevice(0, drive, path); // importing kernel32.dll
simply stopped mapping drives.

The funny thing is that running "subst [drive] [path]" from command
line performs this mapping.

Any Ideas?

Could be UAC, try disabling it or run the application as an
administrator to see if that solves it.

Jesse
 
I

itaymaya

Running as administrator didn't solve it, but disabling UAC did.
Thanks.
However, I'd rather modify my own exe file than changing destination
platform.

Jesse Houwing :
* (e-mail address removed) wrote, On 25-7-2007 13:12:
After migrating from XP to Vista, the following piece of code
Process.Start("subst", drive + " " + path);
as well as
DefineDosDevice(0, drive, path); // importing kernel32.dll
simply stopped mapping drives.

The funny thing is that running "subst [drive] [path]" from command
line performs this mapping.

Any Ideas?

Could be UAC, try disabling it or run the application as an
administrator to see if that solves it.

Jesse
 
J

Jesse Houwing

* (e-mail address removed) wrote, On 30-7-2007 15:40:
Running as administrator didn't solve it, but disabling UAC did.
Thanks.
However, I'd rather modify my own exe file than changing destination
platform.

Jesse Houwing :
* (e-mail address removed) wrote, On 25-7-2007 13:12:
After migrating from XP to Vista, the following piece of code
Process.Start("subst", drive + " " + path);
as well as
DefineDosDevice(0, drive, path); // importing kernel32.dll
simply stopped mapping drives.

The funny thing is that running "subst [drive] [path]" from command
line performs this mapping.

Any Ideas?
Could be UAC, try disabling it or run the application as an
administrator to see if that solves it.

There are ways in Vista to elevate the privileges of your application
temporarily. You can do this in your .NET application using a few
P/Invokes, there is no API in the framework itself for now.

Basically you have two options

1) Run the whole application as Administrator with elevated security.
You need to create an application manifest to get this to work. See:
http://www.frameworkx.com/frameworkx/contentblogdetail.aspx?blog=56&id=530

2) Elevate the security when you need the specified functionality. You
will have to restart the process in order to accomplish this. See"
http://www.codeproject.com/vista-security/UAC_Shield_for_Elevation.asp

Jesse
 
G

Guest

I might have useful information that may or may not be related. It
may very well me UAC interfering, depending on how your
script/programs runs. Read this Knowledge Base article here:

http://support.microsoft.com/kb/937624/en-us

That article specifically addresses the NET USE command and UAC.
Microsoft provides a registry setting to counter that specific issue with
NET USE, but it will not help when the SUBST command is used to assign a UNC
path to a drive letter.

I uncovered a similar issue with the SUBST command and UAC enabled:

1. Log into Vista as an Admin, by default you are running everything
under the filtered security token.

2. Double-click the Command Prompt shortcut. This is the Limited
Prompt running under the filtered security token.

3. Right-click the Command Prompt shortcut, and select Run as Admin.
This is the Admin Prompt, running under the full administrator
security token.

4. OPTIONAL: In the Admin Prompt, issue the command COLOR 47.
This will make it easier to distinguish the two prompts.

5. In the Limited Prompt, use the SUBST command to assign a drive
letter to a UNC path. For Example: SUBST Q: \\Machine\Share\Path

6. In the Limited Prompt, issue the command Dir Q:\
EXPECTED RESULTS: A directory listing appears.
ACTUAL RESULTS: A directory listing appears.

7. In the Admin Prompt, issue the command Dir Q:\
EXPECTED RESULTS: A directory listing appears.
ACTUAL RESULTS: The system cannot find the path specified.

The same thing happens in reverse, if you use SUBST under an Admin
Prompt, it cannot be accessed under the Limited Prompt.

I called Microsoft about this issue last week and spent over 6 hours
on two different phone calls showing various members of their Network
team how the issue works. They all wanted to know about my network
and everything else. Noe fo that matters. It's really simple, UAC
doesn't hand off the substitutions between the two security tokens.

I received a voice mail message yesterday that it is a known issue
(though I can't find it in the Knowledge Base). And, if it will EVER
be addressed, it will be in Vista Service Pack 1. There was no
commitment that it will ever be addressed. Microsoft might not fix
this issue at all, if they consider Net Use is a viable workaround.

If your program uses the SUBST command, and later prompts the user
for UAC access, then subsequently the elevated process attempts to
access the substituted drive letter, it would appear as if the substitution
didn't work at all.

Hope this helps!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top