![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | File.Exists Function Using VB2008 SP1 on Vista Ultimate x64 SP1 I have a service that is supposed to be polling a location on another server using a simple If File.Exists (xyz.file) then Return True Else Return False End If I have found that if the Share is mapped to the computer where the service is running such as "X:\filename" the service is not finding the file at the location even though it exists. HOWEVER, if I change the logic to be "\\UNC\Share\filename" the service finds the file and can return a valid value. Am I missing something as to why I cannot find a file on a mapped drive but I can using a UNC name? Thanks J |
My System Specs![]() |
| | #2 (permalink) |
| | Re: File.Exists Function Mapped network drive is only available to logged in user, be it mapped with user logon script, or manully mapped and saved by windows user profile. A winodws services runs without requirement of user being logged in, even the account used to run the service can be a real user account. So, yes, you should use UNC path with windows services. "Smurfman-MSDN" <smurfman@xxxxxx> wrote in message news:F6447B79-D1BF-4DAB-8919-1D0B3CE2E6BD@xxxxxx Quote: > Using VB2008 SP1 on Vista Ultimate x64 SP1 > > I have a service that is supposed to be polling a location on another > server > using a simple > > If File.Exists (xyz.file) then > Return True > Else > Return False > End If > > I have found that if the Share is mapped to the computer where the service > is running such as "X:\filename" the service is not finding the file at > the > location even though it exists. > > HOWEVER, if I change the logic to be "\\UNC\Share\filename" the service > finds the file and can return a valid value. > > Am I missing something as to why I cannot find a file on a mapped drive > but > I can using a UNC name? > > Thanks > J |
My System Specs![]() |
| | #3 (permalink) |
| | Re: File.Exists Function Thanks Norman, I will add that I found that UNC still only works if I hard code the username and password of a user that can access the particular share on the network. J "Norman Yuan" wrote: Quote: > Mapped network drive is only available to logged in user, be it mapped with > user logon script, or manully mapped and saved by windows user profile. A > winodws services runs without requirement of user being logged in, even the > account used to run the service can be a real user account. So, yes, you > should use UNC path with windows services. > > "Smurfman-MSDN" <smurfman@xxxxxx> wrote in message > news:F6447B79-D1BF-4DAB-8919-1D0B3CE2E6BD@xxxxxx Quote: > > Using VB2008 SP1 on Vista Ultimate x64 SP1 > > > > I have a service that is supposed to be polling a location on another > > server > > using a simple > > > > If File.Exists (xyz.file) then > > Return True > > Else > > Return False > > End If > > > > I have found that if the Share is mapped to the computer where the service > > is running such as "X:\filename" the service is not finding the file at > > the > > location even though it exists. > > > > HOWEVER, if I change the logic to be "\\UNC\Share\filename" the service > > finds the file and can return a valid value. > > > > Am I missing something as to why I cannot find a file on a mapped drive > > but > > I can using a UNC name? > > > > Thanks > > J > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: File.Exists Function It's not the password that is the problem - mapped files only exist for a LOGGED on user. Services start before ANY user logs on, so there are NO mapped files. You must use UNC forms. It's that simple. Bob "Smurfman-MSDN" <smurfman@xxxxxx> wrote in message news:31B4C0E9-F711-45BA-BB7F-E30782924135@xxxxxx Quote: > Thanks Norman, > I will add that I found that UNC still only works if I hard code the > username and password of a user that can access the particular share on > the > network. > > J > > "Norman Yuan" wrote: > Quote: >> Mapped network drive is only available to logged in user, be it mapped >> with >> user logon script, or manully mapped and saved by windows user profile. A >> winodws services runs without requirement of user being logged in, even >> the >> account used to run the service can be a real user account. So, yes, you >> should use UNC path with windows services. >> >> "Smurfman-MSDN" <smurfman@xxxxxx> wrote in message >> news:F6447B79-D1BF-4DAB-8919-1D0B3CE2E6BD@xxxxxx Quote: >> > Using VB2008 SP1 on Vista Ultimate x64 SP1 >> > >> > I have a service that is supposed to be polling a location on another >> > server >> > using a simple >> > >> > If File.Exists (xyz.file) then >> > Return True >> > Else >> > Return False >> > End If >> > >> > I have found that if the Share is mapped to the computer where the >> > service >> > is running such as "X:\filename" the service is not finding the file at >> > the >> > location even though it exists. >> > >> > HOWEVER, if I change the logic to be "\\UNC\Share\filename" the service >> > finds the file and can return a valid value. >> > >> > Am I missing something as to why I cannot find a file on a mapped drive >> > but >> > I can using a UNC name? >> > >> > Thanks >> > J >> |
My System Specs![]() |
| | #5 (permalink) |
| | Re: File.Exists Function Excellent! Thanks a bunch guys. "Bob Milton" wrote: Quote: > It's not the password that is the problem - mapped files only exist for a > LOGGED on user. Services start before ANY user logs on, so there are NO > mapped files. You must use UNC forms. It's that simple. > Bob > > "Smurfman-MSDN" <smurfman@xxxxxx> wrote in message > news:31B4C0E9-F711-45BA-BB7F-E30782924135@xxxxxx Quote: > > Thanks Norman, > > I will add that I found that UNC still only works if I hard code the > > username and password of a user that can access the particular share on > > the > > network. > > > > J > > > > "Norman Yuan" wrote: > > Quote: > >> Mapped network drive is only available to logged in user, be it mapped > >> with > >> user logon script, or manully mapped and saved by windows user profile. A > >> winodws services runs without requirement of user being logged in, even > >> the > >> account used to run the service can be a real user account. So, yes, you > >> should use UNC path with windows services. > >> > >> "Smurfman-MSDN" <smurfman@xxxxxx> wrote in message > >> news:F6447B79-D1BF-4DAB-8919-1D0B3CE2E6BD@xxxxxx > >> > Using VB2008 SP1 on Vista Ultimate x64 SP1 > >> > > >> > I have a service that is supposed to be polling a location on another > >> > server > >> > using a simple > >> > > >> > If File.Exists (xyz.file) then > >> > Return True > >> > Else > >> > Return False > >> > End If > >> > > >> > I have found that if the Share is mapped to the computer where the > >> > service > >> > is running such as "X:\filename" the service is not finding the file at > >> > the > >> > location even though it exists. > >> > > >> > HOWEVER, if I change the logic to be "\\UNC\Share\filename" the service > >> > finds the file and can return a valid value. > >> > > >> > Am I missing something as to why I cannot find a file on a mapped drive > >> > but > >> > I can using a UNC name? > >> > > >> > Thanks > >> > J > >> > >> > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Copy File to users home drives if a certain file exists | VB Script | |||
| if a file exists | PowerShell | |||
| If file exists loop | PowerShell | |||
| is there an 'exists-item' function? | PowerShell | |||
| BUG: Redirecting function contents to a file truncates function lines at the width of the console | PowerShell | |||