Need script's CurrentDirectory.. not process's 
Author Message
 Need script's CurrentDirectory.. not process's

Using WshShell.CurrentDirectory property in VBScript but get the process's
current directory.  Can someone tell me how to get the script's current
directory?

TIA
Bob



Sun, 17 Jul 2005 06:37:52 GMT  
 Need script's CurrentDirectory.. not process's
wscript.echo wscript.scriptfullname
    gives you the path and script name.

Using Replace or Split (or quite a few other options) you can massage that
data as needed.  something like
x = Replace(wscript.scriptfullname,wscript.scriptname,"") to just return the
whole path without the script name, etc.....

Joe


Quote:
> Using WshShell.CurrentDirectory property in vbscript but get the process's
> current directory.  Can someone tell me how to get the script's current
> directory?

> TIA
> Bob



Sun, 17 Jul 2005 06:57:52 GMT  
 Need script's CurrentDirectory.. not process's

Quote:

> Using WshShell.CurrentDirectory property in vbscript but get the process's
> current directory.  Can someone tell me how to get the script's current
> directory?

Hi

Well, the process current directory is the script's current directory as well.
But if you mean the directory where the script is placed, here is a couple of
methods to obtain it:

Set oFSO = CreateObject("Scripting.FileSystemObject")
WScript.Echo oFSO.GetParentFolderName(WScript.ScriptFullName)

' or
sFullName = WScript.ScriptFullName
WScript.Echo Left(sFullName, InStrRev(sFullName, "\"))

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and a ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Sun, 17 Jul 2005 07:00:03 GMT  
 Need script's CurrentDirectory.. not process's
Hi Torgeir,

Thanks for the info.  I neglected to mention that I'm running the script
from an hta file.  Your methods run fine from a .vbs file but I get nothing
when I run them from my hta file.  Any Ideas?

Thanks,
Bob



Quote:

> > Using WshShell.CurrentDirectory property in vbscript but get the
process's
> > current directory.  Can someone tell me how to get the script's current
> > directory?

> Hi

> Well, the process current directory is the script's current directory as
well.
> But if you mean the directory where the script is placed, here is a couple
of
> methods to obtain it:

> Set oFSO = CreateObject("Scripting.FileSystemObject")
> WScript.Echo oFSO.GetParentFolderName(WScript.ScriptFullName)

> ' or
> sFullName = WScript.ScriptFullName
> WScript.Echo Left(sFullName, InStrRev(sFullName, "\"))

> --
> torgeir
> Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and a ONLINE version of the 1328 page
> Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Mon, 18 Jul 2005 00:42:59 GMT  
 Need script's CurrentDirectory.. not process's
Hi Joe,

Thanks for the info.  I neglected to mention that I'm running the script
from an hta file.  Your methods run fine from a .vbs file but I get the
directory that the wscript process is running from, returned when I run them
from my hta file.  Any Ideas?

Thanks,
Bob

Quote:
> wscript.echo wscript.scriptfullname
>     gives you the path and script name.

> Using Replace or Split (or quite a few other options) you can massage that
> data as needed.  something like
> x = Replace(wscript.scriptfullname,wscript.scriptname,"") to just return
the
> whole path without the script name, etc.....

> Joe



> > Using WshShell.CurrentDirectory property in vbscript but get the
process's
> > current directory.  Can someone tell me how to get the script's current
> > directory?

> > TIA
> > Bob



Mon, 18 Jul 2005 00:44:41 GMT  
 Need script's CurrentDirectory.. not process's

Quote:

> Thanks for the info.  I neglected to mention that I'm running the script
> from an hta file.  Your methods run fine from a .vbs file but I get nothing
> when I run them from my hta file.  Any Ideas?

For HTA:

Set oFSO = CreateObject("Scripting.FileSystemObject")
sScriptPath = Replace(location.pathname,"%20"," ")
MsgBox oFSO.GetParentFolderName(sScriptPath)

' as well as
sScriptPath = Replace(location.pathname,"%20"," ")
MsgBox Left(sScriptPath, InStrRev(sScriptPath, "\"))

If you are using trusted frames/iframes then use top.location.pathname instead.

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and a ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Mon, 18 Jul 2005 07:19:15 GMT  
 Need script's CurrentDirectory.. not process's
Torgeir,

Thank you so much!  I've been banging my head against that one all day!

Best regards,
Bob



Quote:

> > Thanks for the info.  I neglected to mention that I'm running the script
> > from an hta file.  Your methods run fine from a .vbs file but I get
nothing
> > when I run them from my hta file.  Any Ideas?

> For HTA:

> Set oFSO = CreateObject("Scripting.FileSystemObject")
> sScriptPath = Replace(location.pathname,"%20"," ")
> MsgBox oFSO.GetParentFolderName(sScriptPath)

> ' as well as
> sScriptPath = Replace(location.pathname,"%20"," ")
> MsgBox Left(sScriptPath, InStrRev(sScriptPath, "\"))

> If you are using trusted frames/iframes then use top.location.pathname
instead.

> --
> torgeir
> Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and a ONLINE version of the 1328 page
> Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Mon, 18 Jul 2005 10:20:52 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. can't set CurrentDirectory property

2. Need to 'sleep' process

3. 'Poke'ing and 'peek'ing other process's memory in VB6

4. processing another page's HTML in a script

5. How can I get the PID of the script's process

6. innerHTML doesn't process style or script?

7. 'Remote Scripting Error: Page invoked does not support remote scripting

8. how do I say 'not'

9. Type 'IADsUser' is not defined

10. 'In process' versus 'Out of process'.

11. Process 'running' or 'not responding'

12. Need 'SaveAs' button on IE Toolbar

 

 
Powered by phpBB® Forum Software