Skip to main content
Solved

Open App Script fail


Forum|alt.badge.img+9

Hello I am pushing out the new Google Drive File Stream app. The app installs correctly but it does not pop up and prompt the user to login after installing. So I am trying to create a script that will open the app. The issue is that it worked on the test computer and the first 5 machines it hit. Then it started failing. Here is the script I am using.

open -a /Applications/Google Drive File Stream.app

Any ideas why this is not working.

Here is the error message.

xecuting Policy Open Drive File Stream
Running script Open Drive File Stream...
Script exit code: 1
Script result: LSOpenURLsWithRole() failed for the application /Applications/Google Drive File Stream.app with error -10810.<br/>
Error running script: return code was 1.

Best answer by cbrewer

You might want to try running the open command as the logged in user. Be default your script will be running it as root.

Here's an example:

#!/bin/bash

loggedInUser=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");'`
su -l $loggedInUser -c "open /Applications/Google Drive File Stream.app/"
View original
Did this topic help you find an answer to your question?

3 replies

Forum|alt.badge.img+15
  • Esteemed Contributor
  • 719 replies
  • Answer
  • October 16, 2017

You might want to try running the open command as the logged in user. Be default your script will be running it as root.

Here's an example:

#!/bin/bash

loggedInUser=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");'`
su -l $loggedInUser -c "open /Applications/Google Drive File Stream.app/"

Forum|alt.badge.img+4

Thanks Cbrewer, your script helped me get part of the job done.

Is there a way to hide or "run silently" so that the app window does not open? I am using this with a security app called zscaler, which is supposed to run without any user interaction. If users see this window open unexpectedly multiple times, it might cause panic/issues.


KyleEricson
Forum|alt.badge.img+16
  • Valued Contributor
  • 444 replies
  • May 8, 2018

When I use this to run this I get this error: Script result: match: Connection invalid
This is to enable OneDrive finder integration.
Thoughts?

#!/bin/bash
loggedInUser=`python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");'`
su -l $loggedInUser -c 'pluginkit -e use -i com.microsoft.OneDrive-mac.FinderSync'

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings