Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-09-07
7
Medium Priority
?
2,258 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
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Six Sigma Control Plans
Screencast - Getting to Know the Pipeline

972 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