arminius Posted June 15, 2008 Posted June 15, 2008 ok, I want to change the working directory from the @scriptdir, to somewhere else here is the code CODEWhile 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 ShellExecute("Good.au3", "", @C:\Documents and Settings\Bill\My Documents\Scripts\Screensaver, "Run") Case $msg = $Button_2 ShellExecute("Bad.au3", "", @ScriptDir, "Run") Case $msg = $Button_3 ShellExecute("Surreal.au3", "", @ScriptDir, "Run") EndSelect Wend buttons 2 and 3 are the old ones and they work, button 1 is what I wanna do, but it's not working, I looked through all the help file and the solution didn't jump out at me so your help is appritiated
herewasplato Posted June 15, 2008 Posted June 15, 2008 First, the working directory does not "help" the ShellExexute function "find" the file named "Good.au3" --- but you might actually already understand that. If you are changing from a marco like @ScriptDir to text, you need quotes around that text... and, seeing as how you have a path with a space in it, you may need to play with double quotes and single quotes. I'm the MSP atm. [size="1"][font="Arial"].[u].[/u][/font][/size]
MHz Posted June 15, 2008 Posted June 15, 2008 First, the working directory does not "help" the ShellExexute function "find" the file named "Good.au3" --- but you might actually already understand that.I am probably going to confuse you here . AFAIK, ShellExecute() tells the system shell to execute the file and when you tell the shell to use a working directory, then that is where it looks amongst other places associated in the registry and system path etc. It can can be similar to using Run() with @Comspec and setting a working directory with it so that @Comspec can find a filename (only) passed to it in the working directory that you passed to @Comspec using Run(). That is my current understanding of the working directory parameter used in ShellExecute() and the example below confirms the behavior. Example tested working on XP $file = 'test.cmd' $path = @TempDir FileDelete($path & '\' & $file) FileWrite($path & '\' & $file, _ '@echo off' & @CRLF & _ 'echo FilePath=%0' & @CRLF & _ 'echo WorkingDir=%cd%' & @CRLF & _ 'pause') ShellExecuteWait('"' & $file & '"', '', $path) Exit Func OnAutoItExit() FileDelete($path & '\' & $file) EndFuncoÝ÷ Ú«¨µ and output is FilePath="C:\Program Files\7-Zip\test.cmd" WorkingDir=C:\Program Files\7-Zip Press any key to continue . . .It seems to work in any directory that I choose including paths on a drive separate from the system drive so the behavior seems constant.
herewasplato Posted June 16, 2008 Posted June 16, 2008 ..I am probably going to confuse you here ...Thanks for your kind correction. Sadly, I don't know where I got that idea from.I stand corrected - well, I'm not actually standing :-) [size="1"][font="Arial"].[u].[/u][/font][/size]
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