Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB6 FileSystemObject works with UNC but not with mapped drives on Win7 PC

Posted on 2010-09-07
7
Medium Priority
?
2,243 Views
Last Modified: 2012-05-10
This is happening on a customer site. I'm trying to use FileSystemObject on a Win7 PC to see if a file exists. If I use the mapped drive, a good filename returns false, UNC returns true.  I also tried an old method:
 Dir(CStr(Filename)) <> ""
Same results.

I tested this at home and I don't have a problem. Yet, I have a workgroup based network.
The customer's Win7 PC is on a domain. I do have administrative rights on that domain but mapped drive still fails. Note: UAC is turned off.

They never had a Vista PC. Just starting to deploy Win7. Previous version (Win XP) does not have the problem.

Looks like some type of Win7 rights issue, but not sure.




Function lbf_FileExist(strFileName As String) As Boolean
Dim ofso
Set ofso = CreateObject("Scripting.FileSystemObject")
        ' Check for file and return appropriate result
        If ofso.FileExists(strFileName) Then
               lbf_FileExist = True
        Else
               lbf_FileExist = False
        End If

End function

Open in new window

0
Comment
Question by:askolits
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 21

Expert Comment

by:Ivano Viola
ID: 33623764
IF the script runs as administrator, then Administrator (the user) does not see the mapped drives as it runs as a different user. The mapped drives are only for currently logged in user. UNC paths work just find as long as the path exists.
0
 
LVL 6

Expert Comment

by:Cesar Aracena
ID: 33623768
How are you mapping the drive? Windows 7 has some strange behaviors when dealing with "normal" mapped drives sometimes. Try and map it from the server's user's policies (bat file) to see if the error continues.
0
 

Author Comment

by:askolits
ID: 33626618
ivanoviola: "The mapped drives are only for currently logged in user. UNC paths work just find as long as the path exists. " 
 Well it's mapped for both types of users and the issue happens both times.
 
Caracena:"Try and map it from the server's user's policies (bat file) to see if the error continues. "

I'll ask the network admin to look at this posibility.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

Expert Comment

by:Ivano Viola
ID: 33627177
"Well it's mapped for both types of users and the issue happens both times....."
I'm not sure what you mean when you say that.

My point was that if the script runs "As Administrator" while logged in as Joe Blow, the script will not see Joe Blow's mapped drives. That's why it fails.
0
 

Author Comment

by:askolits
ID: 33627439
Hmm... Maybe.
I logged in as myself and I am an administrator and it failed. But I didnlt actualy use the "Administrator" username. I'll have to try it and see.
 
0
 
LVL 21

Expert Comment

by:Ivano Viola
ID: 33627550
I've run into similar problems when programs that need to run "As Administrator", and use a mapped drive, fails to run correctly. When I change the drive mapping in the config file to a UNC path, all is good.

I think the same problem is happening to your script.
0
 

Accepted Solution

by:
askolits earned 0 total points
ID: 33628090
Well, I am going to update my code to use UNC.
I did find some code that will provide the UNC for mapped drives. But, I will probably just used the UNC for now rather than add a bunch of code.
 
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question