Jump to content

run exe from parent directory


 Share

Recommended Posts

Check "Run" in the helpfile. Look at the working directory parameter.

actuaaly I did that before I ask the question.

I need an example on how to run an exe from parent directory. Thank you anyway.

can anybody give me an example?

Link to comment
Share on other sites

I am using ShellExecute for more parameters etc.

ShellExecute ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] )

filename The name of the file to run (EXE, .txt, .lnk, etc). 

parameters [optional] Any parameters for the program. Blank ("") uses none. 

workingdir [optional] The working directory. Blank ("") uses the current working directory. 

verb [optional] The "verb" to use, common verbs include:
  open = (default) Opens the file specified. The file can be an executable file, a document file, or a folder
  edit = Launches an editor and opens the document for editing. If "filename" is not a document file, the function will fail
  print = Prints the document file specified. If "filename" is not a document file, the function will fail
  properties = Displays the file or folder's properties 

showflag [optional] The "show" flag of the executed program:
  @SW_HIDE = Hidden window
  @SW_MINIMIZE = Minimized window
  @SW_MAXIMIZE = Maximized window

Good Luck

This world is crazy

Link to comment
Share on other sites

I am using ShellExecute for more parameters etc.

ShellExecute ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] )

filename The name of the file to run (EXE, .txt, .lnk, etc). 

parameters [optional] Any parameters for the program. Blank ("") uses none. 

workingdir [optional] The working directory. Blank ("") uses the current working directory. 

verb [optional] The "verb" to use, common verbs include:
  open = (default) Opens the file specified. The file can be an executable file, a document file, or a folder
  edit = Launches an editor and opens the document for editing. If "filename" is not a document file, the function will fail
  print = Prints the document file specified. If "filename" is not a document file, the function will fail
  properties = Displays the file or folder's properties 

showflag [optional] The "show" flag of the executed program:
  @SW_HIDE = Hidden window
  @SW_MINIMIZE = Minimized window
  @SW_MAXIMIZE = Maximized window

Good Luck

I succeeded by using:

ShellExecute ( "abc.exe" , "" , "../../" )

Thanks!!!

Link to comment
Share on other sites

Hey,

This function will return the parent directory (it's messy but it works right?), so all you need to do is call the _ParentDir() function on the WorkingDir parameter ;)

#include <Constants.au3>

ConsoleWrite(_ParentDir() & @CRLF)

Func _ParentDir()
    $iPID = Run(@ComSpec & " /c cd .. & cd", @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    While 1
        $sOutput = "" & StdoutRead($iPID) & StderrRead($iPID)
        If @error Then ExitLoop
    WEnd
    Return $sOutput
EndFunc   ;==>_ParentDir
Edited by JamesBrooks
Link to comment
Share on other sites

#cs ================================================================
    Heres my contribution to the topic, Fugly but functional ;)
    ================================================================
#ce;
ConsoleWrite(@SCRIPTFULLPATH & @LF)
ConsoleWrite("Parent Directory relative to script."& @LF & @TAB)
ConsoleWrite(_PathTrace() & @LF)
ConsoleWrite("As above but with trailing slash '\'."& @LF & @TAB)
ConsoleWrite(_PathTrace(1,0) & @LF)
ConsoleWrite("Parent of Parent directory."& @LF & @TAB)
ConsoleWrite(_PathTrace(2) & @LF)
ConsoleWrite(@AUTOITEXE & @LF)
ConsoleWrite("The directory of your exe/Interpreter."& @LF & @TAB)
ConsoleWrite(_PathTrace(0,1,@AUTOITEXE) & @LF)
ConsoleWrite("Parent directory relative to your exe/Interpreter."& @LF & @TAB)
ConsoleWrite(_PathTrace(1,1,@AUTOITEXE) & @LF)
ConsoleWrite("alternate directory delim '/' example."& @LF & @TAB)
ConsoleWrite(_PathTrace(2,1,"x:/bin/env/dev/AK47.exe",47) & @LF)
; Example, execute a program setting its working dir to the scripts parent directory
RunWait("CMD.exe /c TITLE Notice working dir? && CD && PAUSE",_PathTrace())
#cs ================================================================
 Trace backward in a path string and return the relative path.
    Depth ~ 1 = "..\" , 2 = "..\..\" etc
 Trail ~ Strip trailing delimeter? 1 = strip | 0 = keep
 RTarget ~ Full file path to extract a relative directory from.
 Delim ~ Ascii value to use as directory delimeter default is "\"
    ================================================================
#ce;
FUNC _PathTrace($Depth = 1,$Trail = 1,$RTarget = @SCRIPTFULLPATH,$Delim = 92)
RETURN StringLeft($RTarget,StringInStr($RTarget,Chr($Delim),0,-$Depth -1) - $Trail)
ENDFUNC

wtfpl-badge-1.png

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...