Jump to content

Move Up X Directories from @ScriptDir


 Share

Recommended Posts

Hi guys, I'm semi new to autoit and I can't seem to locate a function to move up X amount of directories. For instances say my script is in C:\test\test2\test3 and I want to run a file within C:\test\difFolder without explicitly declaring C:\test\difFolder, but rather only difFolder declared. So is there a way I could have the script go up 2 directories (regardless of the directories names) then switch to difFolder and execute a given file name?

Something like this...

$filename = 'myFile.exe'

$itsFolder = ''\difFolder\'

$newDir = dirUp(@ScriptDir, 2) ;assuming dirUp is the function name

$newDir = $newDir & itsFolder & $filename

Run($filename)

Edited by cardguy1000
Link to comment
Share on other sites

Hi guys, I'm semi new to autoit and I can't seem to locate a function to move up X amount of directories.  For instances say my script is in C:\test\test2\test3 and I want to run a file within C:\test\difFolder without explicitly declaring C:\test\difFolder, but rather only difFolder declared.  So is there a way I could have the script go up 2 directories (regardless of the directories names) then switch to difFolder and execute a given file name?

Something like this...

$filename = 'myFile.exe'

$itsFolder = ''\difFolder\'

$newDir = dirUp(@ScriptDir, 2) ;assuming dirUp is the function name

$newDir = $newDir & itsFolder & $filename

Run($filename)

<{POST_SNAPBACK}>

just use \..\

c:\windows\system\..\ = c:\windows\

Func dirUp($s_path, $i_times = 1)
    If $i_times = 0 Then Return $s_path
    $s_path &= '\..'
    For $i = 1 To $i_times
        $s_path &= '\..'
    Next
    Return $s_path
EndFunc  ;==>dirUp
Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

Hi guys, I'm semi new to autoit and I can't seem to locate a function to move up X amount of directories.  For instances say my script is in C:\test\test2\test3 and I want to run a file within C:\test\difFolder without explicitly declaring C:\test\difFolder, but rather only difFolder declared.  So is there a way I could have the script go up 2 directories (regardless of the directories names) then switch to difFolder and execute a given file name?

Something like this...

$filename = 'myFile.exe'

$itsFolder = ''\difFolder\'

$newDir = dirUp(@ScriptDir, 2) ;assuming dirUp is the function name

$newDir = $newDir & itsFolder & $filename

Run($filename)

<{POST_SNAPBACK}>

My question is why ? I'm not able to see the logic behind your request.

You know the name of the file but not the dir right ?

Why not just search for the file to get the path then execute it ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...