Simple run application from parent dir Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
nappies
Posts: 5
Joined: 07 Feb 2018, 14:59

Simple run application from parent dir

19 Feb 2018, 15:25

Hi Dear All!

I just need run script which launches many applications at once and one of them should be in the parent folder. I can not use the absolute path because I'm using this folder with apps on different computers. And I wanted to create a startup with a relative path.

Here script:
C:\Apps\Graphics\Scripts\Script.exe

And i want to make run for search here:
C:\Apps\Everything.exe

I learned to run applications from the same folder as the script, but from the parent does not. And I did not find any examples. Help me please) It started from the same place

Code: Select all

Run, %a_scriptdir%/Everything.exe 
User avatar
boiler
Posts: 16917
Joined: 21 Dec 2014, 02:44

Re: Simple run application from parent dir  Topic is solved

19 Feb 2018, 16:34

This will run the file in a folder two levels up from the script directory:

Code: Select all

Run, %A_ScriptDir%\..\..\Everything.exe
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Simple run application from parent dir

19 Feb 2018, 16:37

maybe see also splitpath and setworkingdir

Code: Select all

C1=%a_scriptfullpath%
stringsplit,a,c1,`\
c=%a1%\%a2%
msgbox,%c%\everything.exe
return
User avatar
boiler
Posts: 16917
Joined: 21 Dec 2014, 02:44

Re: Simple run application from parent dir

19 Feb 2018, 16:51

@garry: That approach could work, but by using a1 and a2, you that assumes that it will always be one folder up from the root level. To make it relative to the current directory no matter how deep you are (i.e., truly be choosing parent directories), then you would need to remove the appropriate number of levels from the end of the full path rather than build it up from the beginning of the path.
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Simple run application from parent dir

20 Feb 2018, 03:05

@boiler : Thank you , you go 2 paths back , was thinking he wants C:\Apps
example to see where you are ( if possible go 2 paths back , otherwise you get C:\ )

Code: Select all

v=%A_ScriptDir%\..\..\
setworkingdir,%v%
run,%comspec% /k cd   ;- see path where you are
return
nappies
Posts: 5
Joined: 07 Feb 2018, 14:59

Re: Simple run application from parent dir

20 Feb 2018, 14:42

Thank you lot guys! For such detailed and varied examples!You are amazing! All work fine now!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, rc76 and 201 guests