Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UNC references 1

Status
Not open for further replies.

mdav2

Programmer
Aug 22, 2000
363
GB
I am launching my program using a shortcut with a unc. using the following convention:
\\server\directory\sub directory\executable

Actual link:
\\tr-dept-ser1\general5\glarch\glarch.exe

Is there any way of getting the UNC of where the executeable is located? I've read about looking for mapped drives and assigning a UNC but this isn't what I am after. Can anyone help?
 
Hi mdav,

This was discussed in a previous thread; however, I couldnt locate it.

VFP executables derive their locality from the path of which they are launched. For instance, if you goto Start Menu>Run and type:

\\tr-dept-ser1\general5\glarch\glarch.exe

SYS(16,1) and Application.ServerName both return
"\\tr-dept-ser1\general5\glarch\glarch.exe".

If you map J: to \\tr-dept-ser1\general5 and goto Start Menu>Run and type:

J:\glarch\glarch.exe

SYS(16,1) and Application.ServerName both return
"J:\glarch\glarch.exe". Jon Hawkins
 
mdav,

I know you stated that you didn't think that UNC was what you wanted, but I've used UNC in both directions - passing the UNC to get the drive letter and parsing thru the drive letters to get the UNC. The following may be of help to you.

Steve

** Figure out of we have access to M4Server
oNetwork=CreateObject("WScript.Network")
cc=oNetwork.EnumNetworkDrives
drcnt=0
arr_size=1
public array drive_list(arr_size,2)
do while .t.
drive_list(arr_size,1)=cc.item(drcnt)
drive_list(arr_size,2)=cc.item(drcnt+1)
drcnt=drcnt+2
if len(alltrim(cc.item(drcnt)))=0
exit
else
arr_size=arr_size+1
dime drive_list(arr_size,2)
endif
enddo
** Remove any pre-existing map to 'X:' just in case it's not M4Server
if ascan(drive_list,'X:')#0
oNetwork.RemoveNetworkDrive("X:",.t.)
endif
llNoGood=.f.
on error llNoGood=.t.
oNetwork.MapNetworkDrive("X:","\\M4Server\user1")
if llNoGood
** See if we can establish and FTP connection to M4Server
public FTPVal
do form ftp_m4 with 'TEST'
if FTPVal#0
=messagebox("Unable to establish connection to M4Server",16,"Program Terminating")
cancel
endif
release FTPVal
endif
on error

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top