pancwk Posted January 4, 2010 Share Posted January 4, 2010 I want to run a exe program from parent directory or parents parent directory. how to run exe from parent directory? Can anyone help me? Thanks! Link to comment Share on other sites More sharing options...
omikron48 Posted January 4, 2010 Share Posted January 4, 2010 Check "Run" in the helpfile. Look at the working directory parameter. Link to comment Share on other sites More sharing options...
pancwk Posted January 4, 2010 Author Share Posted January 4, 2010 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 More sharing options...
Sobiech Posted January 4, 2010 Share Posted January 4, 2010 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 More sharing options...
pancwk Posted January 4, 2010 Author Share Posted January 4, 2010 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 More sharing options...
omikron48 Posted January 4, 2010 Share Posted January 4, 2010 You normally use ShellExecute when you want to open files with their associated program. You use Run when you want to call programs directly. Run("notepad.exe") Run("notepad.exe", "C:\") Link to comment Share on other sites More sharing options...
James Posted January 4, 2010 Share Posted January 4, 2010 (edited) 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 January 4, 2010 by JamesBrooks Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Mobius Posted January 4, 2010 Share Posted January 4, 2010 #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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now