Skip to main content

Locate Script Path

Hi Brian,is it possible to find out at which path the script is running, so I can save the value in a variable.Thanks
 

Brian Element Mon, 05/08/2017 - 07:33

Hi tme and welcome to the site.

Are you talking about the project folder, there is a command that will return the path of your project which would generally be where the script is running.  You can find it with the following command:

Current = Client.WorkingDirectory()

Let me know if I understood what you are looking for.

Thanks

Brian

tme Mon, 05/08/2017 - 09:36

Thank you for the quick response, but this is not what I'm talking about. I want to save the directory of my IDEA-script in a variable not the working directory of my IDEA-project. I have a folder structer with several scripts. There is also one start script, where you can navigate to other scripts dependent of your choise. If I distribute this folder structure with the scripts to a user, it should be possible to run the script and navigate through all scripts. I don't want to pretend a fixed directory where all scripts have to be. That's why I want to save the directory of the script in a variable to handel the navigation dynamicly.

Brian Element Mon, 05/08/2017 - 10:42

Hi tme,

I don't know of a way to do this.  My only suggestion is create your folder structure under the project folder so that someone can put it in any project, you would then have the folder structure and just add the project path to it.  

Brian

tme Wed, 05/10/2017 - 05:00

Hi brian,
this is no solution for me, but thank you very much for the fast response. If I have a solution, I will communicate it here.
tme

wisonix Wed, 09/27/2017 - 09:28

Hi, I am from Berlin (Germany).
Because I have the same problem, I've tried some VB-script-tips from the web:
 
Solution 1: with WScript..

Set fso = CreateObject("Scripting.FileSystemObject")

WScript.Echo fso.GetParentFolderName(WScript.ScriptFullName)

 
Solution 2: with WScript...
 

With WScript

MyPath = Replace(.ScriptFullName&":", .ScriptName&":", "")

.Echo MyPath

End With

 
Solution 3: without WScript...
 
 Set fso = CreateObject("Scripting.FileSystemObject")
 sPath = fso.GetFolder(".") & "\"
 
 
My problem(s): Solution 1 + 2 doesn't work, because WScript is deactivated on our Laptops...
and Solution 3 doesn't work sure (the result is not ever correct).
 
wisonix

 
 

 

AndreBorges Sun, 09/08/2019 - 13:12

I have the same question. 
For example I have my .iss file saved on desktop, and my goal is to obtain the path of this file, something like "C:\Users\xxx\Desktop\".
at this time I only can get the name of the current IDEA project when I run both codes that I share below:
MsgBox Client.WorkingDirectory()
Set WScript = CreateObject("WScript.Shell")
 
MsgBox WScript.CurrentDirectory
any of you have solved this issue?

Brian Element Sun, 09/08/2019 - 14:47

In reply to by AndreBorges

Would something like this work for you?


Sub Main
	Dim objShell As Object
   	Dim strPath As String

   	Set objShell = CreateObject("Wscript.Shell")
   		strPath = objShell.SpecialFolders("Desktop")
   		MsgBox strPath
   	Set objShell = Nothing
End Sub

AndreBorges Mon, 09/09/2019 - 10:41

In reply to by Brian Element

thank you for the prompt reply Brian.
If fact what I want is to get the  .iss File path. (Your code only will work if I have my file saved on desktop)
 
what I expected is something similiar to what we have in VBA:
Application.ActiveWorkbook.Path
 
thanks,
André

klmi Mon, 09/09/2019 - 10:53

I suggest to use a special *. ini file were the path is set manually. Your macros could read that file and use the given path.
edit: I use the path of the Local Library to save that *.ini file. You will get that path with Client.LocalLibraryPath(). When the script runs for the first time and doesn't find that *.ini file a dialog to set the paths is shown.

The website encountered an unexpected error. Try again later.