Open disk in this window

I have a script that I adapted from somewhere around here. I mounts a network share and then opens it.

set serverIP to "XXX.XXX.XXX.XXX"
set ShareName to "HOTFOLDERROOT"
	set ping_result to (do shell script "ping -c 1 -q " & serverIP)
end try
tell application "Finder"
	if "100% packet loss" is not in ping_result then
		if (list disks) does not contain ShareName then
			mount volume "smb://" & serverIP & "/" & ShareName
		end if
	end if
	open disk ShareName
end tell

The mounted volume then opens in a new window. Cool, but . . . I would like the volume to open in the current finder window. Something like “open disk ShareName in current window”.

Any ideas?



In place of open disk ShareName, try something like

set theTarget to ShareName
tell application "Finder" to set target of front Finder window to theTarget

Edit: Since the line I suggested replacing is already in a Finder tell block, you obviously should omit the tell application “Finder” to part.

Further Edit: Don’t know what I was thinking: since ShareName is already a reference to the desired Finder window target, just substitute the single line

set target of front Finder window to ShareName

for open disk ShareName