Posted on 11-11-2019 02:53 PM
Hello - last post on this topic I could find was from 2015.
Any way (Mojave and Higher) to disallow the "Reopen Windows When Logging Back In" across all Macs in a fleet?
I know the way this is controlled behind the scenes has changed over the years.
Thanks all!
Solved! Go to Solution.
Posted on 02-17-2020 08:19 AM
@strayer I ended up running the following through Outset:
#!/bin/sh
user=`ls -la /dev/console | cut -d " " -f 4`
sudo -u $user defaults write com.apple.loginwindow TALLogoutSavesState -bool false
and all works perfectly!
Posted on 02-09-2020 10:04 AM
I would be interested to know this as well.
Posted on 02-09-2020 10:53 PM
I believe this should do the trick
defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
Also, I haven't tested the older commands in the newer OS, but a combo of these may still be accurate as well..
defaults write com.apple.loginwindow TALLogoutSavesState -bool false
defaults write com.apple.loginwindow LoginwindowLaunchesRelaunchApps -bool false
Posted on 02-12-2020 08:00 AM
defaults write com.apple.loginwindow TALLogoutSavesState -bool false was it - thank you!
Posted on 02-12-2020 08:16 AM
actually - weird- I ran it via my computer + terminal - works fine. I put it in execute command / files and processes via a policy - nothing. strange
Posted on 02-12-2020 08:26 AM
@jan.rosenfeld that's a user setting and Jamf commands run as root. You probably need to do something like this:
EDIT: Set this up in a jamf policy and it worked on my machine.
#!/bin/bash
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
loggedInUID=$(id -u "$loggedInUser")
#Disable Reopen Windows When Logging Back In
/bin/launchctl asuser "$loggedinUID" sudo -iu "$loggedInUser" defaults write com.apple.loginwindow TALLogoutSavesState -bool false
exit 0
Posted on 05-06-2022 01:51 AM
Hi Adam
Did you run this policy at startup or login?
also how did you test it locally?(not through jamf)
Posted on 05-06-2022 05:57 AM
I run this policy once per computer during the initial setup. If the user wants to change it back I don't really care that much.
To test it locally put that text into a script file that ends in .sh and then in terminal run
sudo sh /path/to/script.sh
It runs differently when running from Jamf though because scripts run as root and not as the logged in user. That's why you need the get logged in user and the sudo -iu $loggedInUser bit.
Posted on 09-08-2023 11:28 AM
Hey, Adam. Been wanting to look at this for a while. I run this script and it runs successfully. But nothing changes. Do I need to plug the acct name of the logged in user as a variable? Thanks!
Posted on 02-17-2020 08:19 AM
@strayer I ended up running the following through Outset:
#!/bin/sh
user=`ls -la /dev/console | cut -d " " -f 4`
sudo -u $user defaults write com.apple.loginwindow TALLogoutSavesState -bool false
and all works perfectly!
Posted on 05-06-2022 01:21 AM
Hi Jan
Can you explain how you used Outset?