Issue running a script at the login screen with Casper Remote

jlbates
New Contributor

I have about 50 carts of Macbooks I'm trying to image and configure over the summer, one of the steps I wanted to add was a script that loged in the user in and run some scripts.

Here is part of the script that is not working with Casper Remote:

osascript <<EndOfMyScript
tell application "System Events"
keystroke "username"
keystroke return
delay 0.5
keystroke "password"
delay 0.5
keystroke return
end tell
EndOfMyScript

I can get it working if I deploy it locally or with Apple Remote Desktop but if I deploy it with Casper Remote it always gives me the same error.

Script Result: 43:65: execution error: An error of type -10810 has occurred. (-10810)

Anyone ever have this issue? I just want to automate some of the configuration so I can save some time.

Thank you,
Josh

1 ACCEPTED SOLUTION

nessts
Valued Contributor II

is this supposed to be typing a username and password in the loginwindow?
you cannot do that.
look at defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser username
defaults write /Library/Preferences/com.apple.loginwindow lastUser loggedIn
defaults write /Library/Preferences/com.apple.loginwindow lastUserName username

then you need to create a /etc/kcpassword file that has the proper permissions and the proper encrypted pw in it.
this can be done by logging in said user on another computer, and setting it to autologin and then grabbing the file.

then when you are done you can defaults delete the autologinuser and the kcpassword file

View solution in original post

5 REPLIES 5

nessts
Valued Contributor II

is this supposed to be typing a username and password in the loginwindow?
you cannot do that.
look at defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser username
defaults write /Library/Preferences/com.apple.loginwindow lastUser loggedIn
defaults write /Library/Preferences/com.apple.loginwindow lastUserName username

then you need to create a /etc/kcpassword file that has the proper permissions and the proper encrypted pw in it.
this can be done by logging in said user on another computer, and setting it to autologin and then grabbing the file.

then when you are done you can defaults delete the autologinuser and the kcpassword file

brandonusher
Contributor II

When you say you would like to run some scripts, do they have to be run when the user is logged in, or is it not user specific?

If it is not user specific then just push that out with Casper Remote instead of trying to login with a script first. That should work atleast.

As for not being able to login with pushing the script with Casper Remote, that may be because it tries to run it as your Casper Management user and it really comes down to being a GUI type script, because it is telling the GUI to do those actions.

Hope this helped.

@nessts: The login script works to login and out users when pushed out with Apples Remote Desktop. I even use a similar script whenever I need to batch login users.

jlbates
New Contributor

@nessts: Like usher.br said it works with ARD, just not with Casper Remote. Yea, that was my second option. I was going to try that if I could not get this to work. Thank you.

@usher.br: So here is what I need to do:

  1. Log user in.
  2. Run script that installs Kaspersky Agent. (Needs user to be logged in).
  3. Restart.
  4. Log user in.
  5. Run script to check if Kaspersky is updated and activated. ( Needs user to be logged in)

I figured thats why it did not work, It looks like im going to need to try Nessts method to get it working how I need it. I hate Kaspersky....

Again, thank you both for the response.

bentoms
Release Candidate Programs Tester

@jbates, IIRC if in Casper Admin.. If you tick "this application needs to be installed on the root volume at imaging" (something like that, it's in the 3rd tab), then Casper should login to the mac @ firstboot (using an account called Adobeinstall)... & Casper will then install Kaspersky whilst logged in.

Pretty sure that will work.

jlbates
New Contributor

Nessts idea worked great.

Thanks again for the help