Discussion:
Using relative path in HTA/HTML page
(too old to reply)
Christoph Dommermuth
2006-05-18 14:18:44 UTC
Permalink
Hi all,

I've tried to use the filesystem object in a HTA/html page. For that I've
used a relative path to the folder which I will copy to another location.
( "../res/test). Everytime I've got the error "Path not found". When the
folder is located in same folder like the *.htm It works.
What can I do? Is it possible to use relative path within the
FileSystemObject?

cheers,

christoph
maximillianx
2006-05-18 16:09:43 UTC
Permalink
Here's what I have used, and seems to work pretty well.

<script language="JavaScript">

var sFullPath = unescape(window.parent.location.pathname).substring(0,
unescape(window.parent.location.pathname).lastIndexOf("\\"));

</script>
Post by Christoph Dommermuth
Hi all,
I've tried to use the filesystem object in a HTA/html page. For that I've
used a relative path to the folder which I will copy to another location.
( "../res/test). Everytime I've got the error "Path not found". When the
folder is located in same folder like the *.htm It works.
What can I do? Is it possible to use relative path within the
FileSystemObject?
cheers,
christoph
Christoph Dommermuth
2006-05-18 16:30:26 UTC
Permalink
Thanks, Maximilian,

but with the window fuction i will only get the url?!
Is there a way to get the right path of the FileSystem like
C:\test\test1\test2?

chris
Post by maximillianx
Here's what I have used, and seems to work pretty well.
<script language="JavaScript">
var sFullPath = unescape(window.parent.location.pathname).substring(0,
unescape(window.parent.location.pathname).lastIndexOf("\\"));
</script>
Post by Christoph Dommermuth
Hi all,
I've tried to use the filesystem object in a HTA/html page. For that I've
used a relative path to the folder which I will copy to another location.
( "../res/test). Everytime I've got the error "Path not found". When the
folder is located in same folder like the *.htm It works.
What can I do? Is it possible to use relative path within the
FileSystemObject?
cheers,
christoph
ekkehard.horner
2006-05-18 16:55:37 UTC
Permalink
Post by Christoph Dommermuth
Hi all,
I've tried to use the filesystem object in a HTA/html page. For that I've
used a relative path to the folder which I will copy to another location.
( "../res/test). Everytime I've got the error "Path not found". When the
folder is located in same folder like the *.htm It works.
What can I do? Is it possible to use relative path within the
FileSystemObject?
[...]
Relatives pathes are resolved with regard to the "current directory". This
is dangerous, because the "current directory" depends on how you start which
kind of script. As maximillianx contribution implies, it's better to use a
stable starting point - e.g. the directory of the .hta/html (.vbs) file.

Something like

sBaseDir = CreateObject( "Scripting.FileSystemObject" )_
.GetParentFolderName( Mid( document.url, Len( "file://" ) + 1 ) ) + "\"

can be used with

sFSpec = "../res/test"
sFSpec = CreateObject( "Scripting.FileSystemObject" )_
.GetAbsolutePathName( sBaseDir + sFSpec )
Joe Fawcett
2006-05-18 17:59:06 UTC
Permalink
You can also experiment to see where the app thinks it is.
FSO.getFolder(".").Name
or use wscript.shell's currentDirectory
--
Joe
Post by ekkehard.horner
Post by Christoph Dommermuth
Hi all,
I've tried to use the filesystem object in a HTA/html page. For that I've
used a relative path to the folder which I will copy to another location.
( "../res/test). Everytime I've got the error "Path not found". When the
folder is located in same folder like the *.htm It works.
What can I do? Is it possible to use relative path within the
FileSystemObject?
[...]
Relatives pathes are resolved with regard to the "current directory". This
is dangerous, because the "current directory" depends on how you start which
kind of script. As maximillianx contribution implies, it's better to use a
stable starting point - e.g. the directory of the .hta/html (.vbs) file.
Something like
sBaseDir = CreateObject( "Scripting.FileSystemObject" )_
.GetParentFolderName( Mid( document.url, Len( "file://" ) + 1 ) ) + "\"
can be used with
sFSpec = "../res/test"
sFSpec = CreateObject( "Scripting.FileSystemObject" )_
.GetAbsolutePathName( sBaseDir + sFSpec )
Christoph Dommermuth
2006-05-18 18:51:13 UTC
Permalink
Thanks to all ... it works!

Cheers
Post by Joe Fawcett
You can also experiment to see where the app thinks it is.
FSO.getFolder(".").Name
or use wscript.shell's currentDirectory
--
Joe
Post by ekkehard.horner
Post by Christoph Dommermuth
Hi all,
I've tried to use the filesystem object in a HTA/html page. For that
I've used a relative path to the folder which I will copy to another
location.
( "../res/test). Everytime I've got the error "Path not found". When the
folder is located in same folder like the *.htm It works.
What can I do? Is it possible to use relative path within the
FileSystemObject?
[...]
Relatives pathes are resolved with regard to the "current directory". This
is dangerous, because the "current directory" depends on how you start which
kind of script. As maximillianx contribution implies, it's better to use a
stable starting point - e.g. the directory of the .hta/html (.vbs) file.
Something like
sBaseDir = CreateObject( "Scripting.FileSystemObject" )_
.GetParentFolderName( Mid( document.url, Len( "file://" ) + 1 ) ) + "\"
can be used with
sFSpec = "../res/test"
sFSpec = CreateObject( "Scripting.FileSystemObject" )_
.GetAbsolutePathName( sBaseDir + sFSpec )
asdf
2006-05-19 07:29:01 UTC
Permalink
Thanks to all ... it works!

*********************************

Good !
Post by Christoph Dommermuth
Thanks to all ... it works!
Cheers
Post by Joe Fawcett
You can also experiment to see where the app thinks it is.
FSO.getFolder(".").Name
or use wscript.shell's currentDirectory
--
Joe
Post by ekkehard.horner
Post by Christoph Dommermuth
Hi all,
I've tried to use the filesystem object in a HTA/html page. For that
I've used a relative path to the folder which I will copy to another
location.
( "../res/test). Everytime I've got the error "Path not found". When the
folder is located in same folder like the *.htm It works.
What can I do? Is it possible to use relative path within the
FileSystemObject?
[...]
Relatives pathes are resolved with regard to the "current directory". This
is dangerous, because the "current directory" depends on how you start which
kind of script. As maximillianx contribution implies, it's better to
use
Post by Christoph Dommermuth
Post by Joe Fawcett
Post by ekkehard.horner
a
stable starting point - e.g. the directory of the .hta/html (.vbs) file.
Something like
sBaseDir = CreateObject( "Scripting.FileSystemObject" )_
.GetParentFolderName( Mid( document.url, Len( "file://" ) + 1 ) ) + "\"
can be used with
sFSpec = "../res/test"
sFSpec = CreateObject( "Scripting.FileSystemObject" )_
.GetAbsolutePathName( sBaseDir + sFSpec )
Loading...