Hey everyone! I'm trying to run a PowerShell script during Windows startup using Group Policy, and while it works fine when I run it manually, I ran into some trouble with the javaw process. My script looks like this: Start-Process -FilePath javaw.exe -ArgumentList '-jar C:temptest.jar'. However, I get an error saying 'ERROR: The process "javaw.exe" not found.' I've enabled transcript logging, and I see that the transcript starts but then it fails. Any ideas on how to fix this?
4 Answers
When running scripts with Group Policy, make sure you're aware that they execute in the system context. This might mean the path to javaw.exe isn't included in the environment variable for that user. Adding the full path should resolve the issue. You could also update the `$env:path` variable right in your script like this: $env:path += ";C:Program FilesJavajdk_versionbin".
I wonder why you specifically need to use PowerShell for this. Could you just run the Java command directly without needing the script?
Try using the full path to javaw.exe in your script. For example, something like 'C:Program FilesJavajdk_versionbinjavaw.exe' instead of just 'javaw.exe'. PowerShell may not know where to look for it otherwise.
Have you thought about using Scheduled Tasks instead of Group Policy? It could be more reliable for running scripts like this. Also, make sure that javaw.exe is included in your system's PATH variable; if it's not, PowerShell won't find it when the script runs.
Got it! That makes sense since the error mentions it can't find javaw.exe. I'll give that a try.