Skip navigation.
 
mlRe: Permissions problem after NSTask application launch
FROM : David Darby
DATE : Tue Apr 19 01:24:35 2005

Dear Sherm

Thanks a lot! Your intuition was correct. It was due to a "File not
found" error, not permissions. By adding:

[task setCurrentDirectory:path];

the directories are found correctly.

The full working code is now:

- (void)awakeFromNib
{
   [self launchStudentVersion];
}

- (void)launchStudentVersion
{
  NSTask* task = [[NSTask alloc] init];
  NSMutableArray* args = [NSMutableArray array];
  NSBundle* appBundle = [NSBundle mainBundle];
 
  // set arguments
  NSString* firstCmd;
  NSString* cmd1 = @"/MyApp.app/Contents/MacOS/MyApp";
  NSString* cmd2 = @"-student";
  NSString* path = [[appBundle bundlePath]
stringByDeletingLastPathComponent];
 
  // set working directory to application's directory
  [task setCurrentDirectory:path];
  firstCmd = [path stringByAppendingString:cmd1];
  [task setLaunchPath:firstCmd];
 
  [args addObject:firstCmd];
  [args addObject:cmd2];
 
  [task setArguments:args];
  [task launch];
 
  [NSApp terminate:self];
}

Thanks for your assistance.

David Darby
Em <email_removed>

Related mailsAuthorDate
mlPermissions problem after NSTask application launch David Darby Apr 18, 06:15
mlRe: Permissions problem after NSTask application launch Sherm Pendley Apr 18, 06:43
mlRe: Permissions problem after NSTask application launch David Darby Apr 19, 01:24