Solved

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

Posted on 2010-09-07
7
2,194 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:ivanoviola
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:Caracena
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 21

Expert Comment

by:ivanoviola
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:ivanoviola
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

777 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