Author Topic: DirExist() on network drive  (Read 3380 times)

cssyphus

  • Newbie
  • *
  • Posts: 30
DirExist() on network drive
« on: July 03, 2013, 02:10:51 pm »
This test fails (results in Not Exist message):

Code: Winbatch
If DirExist(`P:\Tech\Updates`) Then Message("Yes","Drive Exists")
Else Message('No','Not Exist')
 

However, if I open a cmd window the folder definitely exists.  Why does the above test fail?

The P: drive is mapped to an SMB share on a Linux box, as follows:

net use p: \\192.168.1.2\THESHARE

My script is being run on a Win7HP machine.  Everything else seems to work with this drive: Explorer, Word 2010, Excel 2010, DOS, etc.

I am running the script in debug mode inside the Winbatch Studio.


Deana

  • Wilson WindowWare Tech Support
  • Pundit
  • *****
  • Posts: 1183
  • WinBatch® can do it.
    • WinBatch Tech Support Database
Re: DirExist() on network drive
« Reply #1 on: July 03, 2013, 02:24:24 pm »
Are you logged in as an administrator? If so you have two user contexts: standard user and full admin. By default script run using WinBatch are manifested to run using the highest available user context, so if you are logged into an administrator account the script will run with full admin elevation.  Sometimes when you map the drive, using the standard user context , that drive is not seen by a script running in the administrator context.

Luckily, you can specify a different manifest for your scripts, by simply running the AsInvoker manifested version of WinBatch Studio located here: C:\Program Files (x86)\WinBatch\System\WinBatch_IF.EXE. Launch this version and load your script and test.

Reference: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/UAC+Mapped~Drives~Issue~with~UAC.txt
Deana F.
Technical Support
Wilson WindowWare Inc.