Get Script file path within script 
Author Message
 Get Script file path within script

HI,
I am new to vbs. Maybe it is an easy question:
Within my script test.vbs i want to know the path of the same file test.vbs.
How can I do this?

Thank you,
Sbastien



Wed, 06 Aug 2003 05:18:27 GMT  
 Get Script file path within script
The WScript object has a ScriptFullName property which seems like what you are
looking for, the full path name of the script.
http://msdn.microsoft.com/scripting/
Quote:
-----Original Message-----

HI,
I am new to vbs. Maybe it is an easy question:
Within my script test.vbs i want to know the path of the same file test.vbs.
How can I do this?

Thank you,
Sbastien
.



Wed, 06 Aug 2003 05:54:50 GMT  
 Get Script file path within script

Quote:

> HI,
> I am new to vbs. Maybe it is an easy question:
> Within my script test.vbs i want to know the path of the same file
> test.vbs.  How can I do this?

> Thank you,
> Sbastien

 set oFS = CreateObject("Scripting.FileSystemObject")
 sScriptPath oFS.GetParentFolderName(Wscript.ScriptFullName)

You have the documentation, right?  If not, you can get it here ...

Documentation

  http://msdn.microsoft.com/scripting/windowshost/wshdoc.exe
  http://msdn.microsoft.com/scripting/VBScript/download/vbsdoc.exe
  http://msdn.microsoft.com/scripting/vbscript/doc/jsFSOTutor.htm

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/



Wed, 06 Aug 2003 06:10:29 GMT  
 Get Script file path within script
Tom, Bob,
Thank you for your help. My problems are solved now.

I had downloaded the vbcript html help, but the 'search' tab doesn't seem to work.
EG:Even with 'Match similar words' checked and 'Search titles only' unchecked,
searching 'getparent' returns 'No Result Found' while 'getparentfoldername'
returns some results.

Thanks again,
Sbastien



Wed, 06 Aug 2003 08:05:26 GMT  
 Get Script file path within script


Quote:
> Tom, Bob,
> Thank you for your help. My problems are solved now.

> I had downloaded the vbcript html help, but the 'search' tab doesn't =
> seem to work.
> EG:Even with 'Match similar words' checked and 'Search titles only' =
> unchecked,=20
> searching 'getparent' returns 'No Result Found' while =
> 'getparentfoldername'=20
> returns some results.

Actually, I find this one easier:

set FSO = CreateObject("Scripting.FileSystemObject")
strCurPath = FSO.GetAbsolutePathName(".")

--
Jacob S. Nielsen
http://www.modular-juice.net



Mon, 11 Aug 2003 01:17:20 GMT  
 Get Script file path within script

Quote:

> Actually, I find this one easier:

> set FSO = CreateObject("Scripting.FileSystemObject")
> strCurPath = FSO.GetAbsolutePathName(".")

That gives you the current directory for the process that is executing the script.  That's NOT
always the same as the path of the script, depending on how the script is executed.

A really simple example: the script is executed via a shortcut (.lnk) with a completely different
working directory ("Start in:") than the directory the script lives in...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--



Mon, 11 Aug 2003 10:24:35 GMT  
 Get Script file path within script
What's wrong with using:

    fso.GetParentFolderName( WSCRIPT.ScriptFullName )

/Al


Quote:

> > Actually, I find this one easier:

> > set FSO = CreateObject("Scripting.FileSystemObject")
> > strCurPath = FSO.GetAbsolutePathName(".")

> That gives you the current directory for the process that is executing the
script.  That's NOT
> always the same as the path of the script, depending on how the script is
executed.

> A really simple example: the script is executed via a shortcut (.lnk) with

a completely different
Quote:
> working directory ("Start in:") than the directory the script lives in...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup instead.
> --



Mon, 11 Aug 2003 14:15:12 GMT  
 Get Script file path within script
Nothing --- that's exactly what Tom L. already posted on this thread...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> What's wrong with using:

>     fso.GetParentFolderName( WSCRIPT.ScriptFullName )

> /Al



> > > Actually, I find this one easier:

> > > set FSO = CreateObject("Scripting.FileSystemObject")
> > > strCurPath = FSO.GetAbsolutePathName(".")

> > That gives you the current directory for the process that is executing the
> script.  That's NOT
> > always the same as the path of the script, depending on how the script is
> executed.

> > A really simple example: the script is executed via a shortcut (.lnk) with
> a completely different
> > working directory ("Start in:") than the directory the script lives in...

> > --
> > Michael Harris
> > Microsoft.MVP.Scripting
> > --

> > Please do not email questions - post them to the newsgroup instead.
> > --



Mon, 11 Aug 2003 14:34:43 GMT  
 Get Script file path within script
Hi Michael and All,

but what is the parentfolder of the rootfolder, if you script is in the
root??????? I saw it working, but never use it. May be in the next relase,
it returns an error......  ;-)

Best regards,
Manfred Braun

(Private)
Lange Roetterstrasse 7
D68167 Mannheim
Germany


(Remove the anti-spam-underscore to mail me!)


Quote:
> Nothing --- that's exactly what Tom L. already posted on this thread...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup instead.
> --




Quote:
> > What's wrong with using:

> >     fso.GetParentFolderName( WSCRIPT.ScriptFullName )

> > /Al



> > > > Actually, I find this one easier:

> > > > set FSO = CreateObject("Scripting.FileSystemObject")
> > > > strCurPath = FSO.GetAbsolutePathName(".")

> > > That gives you the current directory for the process that is executing
the
> > script.  That's NOT
> > > always the same as the path of the script, depending on how the script
is
> > executed.

> > > A really simple example: the script is executed via a shortcut (.lnk)
with
> > a completely different
> > > working directory ("Start in:") than the directory the script lives
in...

> > > --
> > > Michael Harris
> > > Microsoft.MVP.Scripting
> > > --

> > > Please do not email questions - post them to the newsgroup instead.
> > > --



Tue, 12 Aug 2003 06:09:45 GMT  
 Get Script file path within script
set fso = createobject("scripting.filesystemobject")
msgbox fso.getparentfoldername("c:\foobar.vbs")

displays -> c:\

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--


Quote:
> Hi Michael and All,

> but what is the parentfolder of the rootfolder, if you script is in the
> root??????? I saw it working, but never use it. May be in the next relase,
> it returns an error......  ;-)

> Best regards,
> Manfred Braun

> (Private)
> Lange Roetterstrasse 7
> D68167 Mannheim
> Germany


> (Remove the anti-spam-underscore to mail me!)



> > Nothing --- that's exactly what Tom L. already posted on this thread...

> > --
> > Michael Harris
> > Microsoft.MVP.Scripting
> > --

> > Please do not email questions - post them to the newsgroup instead.
> > --



> > > What's wrong with using:

> > >     fso.GetParentFolderName( WSCRIPT.ScriptFullName )

> > > /Al



> > > > > Actually, I find this one easier:

> > > > > set FSO = CreateObject("Scripting.FileSystemObject")
> > > > > strCurPath = FSO.GetAbsolutePathName(".")

> > > > That gives you the current directory for the process that is executing
> the
> > > script.  That's NOT
> > > > always the same as the path of the script, depending on how the script
> is
> > > executed.

> > > > A really simple example: the script is executed via a shortcut (.lnk)
> with
> > > a completely different
> > > > working directory ("Start in:") than the directory the script lives
> in...

> > > > --
> > > > Michael Harris
> > > > Microsoft.MVP.Scripting
> > > > --

> > > > Please do not email questions - post them to the newsgroup instead.
> > > > --



Wed, 13 Aug 2003 09:06:13 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. VB Script - Can a running script derive it's own path

2. Using Script from within ActiveX Control (scripting control???)

3. Calling server-script from within client-script

4. calling a script from within a script?

5. CGI Script Call from within VB Script

6. Running a .vbs script from within a .vbs script

7. Calling server-script from within client-script

8. Script from within a script....

9. How to call a script within a script

10. Calling a script from within a script....

11. Calling a script from within a script....

12. Call another script within a script

 

 
Powered by phpBB® Forum Software