Good morning folks.
I'm actually an AWS Solutions Architect and have been working through a deployment of AutoCAD 2021 for one of my customers. I hit the same problem as outlined earlier on in this thread. The script does resolve the issue, but I'm using the AppStream Script Execution engine to fire it before the user session starts (rather than Windows Scheduled Tasks). The steps I took are below are done from my Image Builder machine:
1. I modified the script by @bryanleuschen to reflect my AutoCAD 2021 install, as shown below:
$GCF = "$env:LOCALAPPDATA\Autodesk\AutoCAD 2021\R24.0\enu\GraphicsCache\"
$LRF = "$env:LOCALAPPDATA\Autodesk\AutoCAD 2021\R24.0\enu\"
$RRF = "$env:APPDATA\Autodesk\AutoCAD 2021\R24.0\enu\"
$RegKey = "HKCU:\Software\Autodesk\AutoCAD\R24.0\ACAD-4101:409"
Set-ItemProperty -Path $RegKey -Name "GraphicsCacheFolder" -Value $GCF
Set-ItemProperty -Path $RegKey -Name "LocalRootFolder" -Value $LRF
Set-ItemProperty -Path $RegKey -Name "RoamableRootFolder" -Value $RRF
2. I saved this as a file called "autocad-fix.ps1" to a new folder called "scripts" in the root of my C: drive.
3. AWS AppStream has hooks which allow you to fire scripts (.bat or powershell) when certain events happen. These are called AppStream Session Scripts. One of those events is when a streaming session starts. On your AppStream builder machine, you will find a file called "config.json". This will be stored in C:\AppStream\SessionScripts. I modified this file as follows, as you will see, this tells AppStream to fire the powershell above when any user starts their AppStream session:
{
"SessionStart": {
"executables": [
{
"context": "user",
"filename": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"arguments": "-File \"C:\\scripts\\autocad-fix.ps1",
"s3LogEnabled": true
},
{
"context": "system",
"filename": "",
"arguments": "",
"s3LogEnabled": true
}
],
"waitingTime": 30
},
"SessionTermination": {
"executables": [
{
"context": "system",
"filename": "",
"arguments": "",
"s3LogEnabled": true
},
{
"context": "user",
"filename": "",
"arguments": "",
"s3LogEnabled": true
}
],
"waitingTime": 30
}
}
Note a couple of things:
1. The double backslash on the folder locations is intentional, and should be used.
2. I am logging out the output from my powershell script to an S3 Bucket. When this option is enabled in the configuration file, AppStream 2.0 automatically captures the output from the session script that is written to the standard out. This output is uploaded to an Amazon S3 bucket in your account. You can review the log files for troubleshooting or debugging purposes. Unless you need this logging information, or you have housekeeping on the S3 Bucket, then turn it off so you are not logging out un-necessarily. See here for more details.
After that, I created a new Image from this machine, and added it into my AppStream fleet.