args Path, Name
local hwnd = win.handle("c=TTOTAL_CMD")
local Slash
if(select(Path, 2) == "\\") do
	Slash = "Script works only in directory tree, not network or special folders"
	messagebox("ok error", Slash, "TreeDown Script")
	quit
endif
if(file.isfolder(Path ++ Name) && Name) do			
	win.sendmessage(hwnd, 0x400+51, 2003, 0)			
	quit
endif
if(not file.isfolder(Path ++ Name)) do					
	if(length(Path) == 3) do
		Path = select(Path, 2)
		Slash = "Last folder in root visited. Go to the next drive?"
		if(messagebox("yesno warning", Slash, Path ++ " root") == 7)
			quit
		win.sendmessage(hwnd, 0x400+51, 2051, 0)		
		win.sendmessage(hwnd, 0x400+51, 2001, 0)		
			quit
	endif
	Path = remove(Path, -1)
	Name = file.nametype(Path)
	Path = file.folder(Path)
endif
for(1)
;Sub_TreeDownCmd - имя скрипта TreeDownCmd 
	Slash = runfile.Subs\Sub_TreeDownCmd(Path, Name)
	if(not Slash) do										
		Slash = revindex(Path, "\")
		if(Slash == 0) do
			Path = select(Path, 2)
			Slash = "Last folder in root visited. Go to the next drive?"
			if(messagebox("yesno warning", Slash, Path ++ " root") == 7)
				quit
			win.sendmessage(hwnd, 0x400+51, 2051, 0)		
			win.sendmessage(hwnd, 0x400+51, 2001, 0)		
				quit
		endif
		Name = file.nametype(Path)
		Path = file.folder(Path)
	else
		tc.cd(hwnd, Slash)
		keys {home}
		quit
	endif
endfor