Open App Script fail

lpadmin
Contributor

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.

1 ACCEPTED SOLUTION

cbrewer
Valued Contributor II

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 solution in original post

3 REPLIES 3

cbrewer
Valued Contributor II

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/"

discounteggroll
New Contributor III

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
Valued Contributor II

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'
Read My Blog: https://www.ericsontech.com