New topic: Createprocess() & Shellexecute Directory Issues.
<http://forums.realsoftware.com/viewtopic.php?t=46939> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message lukus001 Post subject: Createprocess() & Shellexecute Directory Issues.Posted: Thu Feb 14, 2013 4:26 am Joined: Sat Jul 16, 2011 2:45 pm Posts: 50 Hey guys, I have tried both CreateProcess() and ShellExecute() to launch a program and both return error codes 267 / 2 respectively (directory /file does not exist). The Program /Directory 100% does exist - not only was it copied from explorer, I can cut and paste it into cmd.exe and it will load / launch. I have tried changing directories, tried launching other programs, tried various combinations of directories /command line variations etc and it seems windows refuses to acknowledge the directory? This is on windows 8 if that changes anything. Is there any particular reason why realstudio in combination with this API wouldn't work? I am completely lost as to how to launch a simple program . Folderitem.launch is not a viable option because i need to set the "current directory" of the launched application for it to load properly. If i place my built real studio application in the "current directory" needed (because it inherits the current directory) it will work, but that is not a viable solution because it regularly changes and there is more than one application that needs launching. Any help much appreciated Top kermit Post subject: Re: Createprocess() & Shellexecute Directory Issues.Posted: Thu Feb 14, 2013 5:25 am Joined: Mon May 30, 2011 12:56 am Posts: 606 Quote:Folderitem.launch is not a viable option Yes it is. Quote: i need to set the "current directory" of the launched application why? if you know the right path to the file, you can do myFolderItem = GetFolderItem(theFullPath) after that, does myFolderItem.exists return true? If no, the path is wrong. If yes, then myFolderItem.launch should work just fine You shouldnt normally be forcing the launched EXE to 'think' it is running in another location. Quote:If i place my built real studio application in the "current directory" needed (because it inherits the current directory) it will work So are you NOT supplying the full path to the required file? That will only work if the program you want to laucnh exists on the windows 'PATH' environment variable. (Places where it looks for exectuables if someone forgets to say where the program lives) Quote:that is not a viable solution because it regularly changes That sounds suspect... Top lukus001 Post subject: Re: Createprocess() & Shellexecute Directory Issues.Posted: Thu Feb 14, 2013 5:40 am Joined: Sat Jul 16, 2011 2:45 pm Posts: 50 kermit wrote:You shouldnt normally be forcing the launched EXE to 'think' it is running in another location. .. So are you NOT supplying the full path to the required file? That will only work if the program you want to laucnh exists on the windows 'PATH' environment variable. (Places where it looks for exectuables if someone forgets to say where the program lives) I think you misunderstood. Every application has a "current directory" value which is irrelevant to where the application is actually located or one's ability to load that application, but affects that application's relative references to files or directories. Processmonitor will show "application: C:\fulladdress to executable.exe + commandline vars" & "currentDirectory: C:\myrealstudioapp_directory" The problem is, that the application I want to load requires access to certain files relative to it's location or it will close, and for it to have access to those files it's "current directory" value has to be set to the directory the executable was located. This is not my application, this is not something I can alter, it is out of my control regardless of whether that is or isn't normal behavior. The problem with folderitem.launch is that it does not allow one to set the "current directory" value, the launched process then inherits the parent processes' directory which of course will not work for the sub process and it will self terminate. I will clarify, folderitem.launch DOES load the application but the application will self terminate without the correct "current directory" value set, which folderitem.launch does not facilitate. Thus, I require CreateProcess() or ShellExecute() both of which seem to dislike accepting the directory even though it's valid Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
