Reputation: 1124
I'm trying to modify a file in %appdata%\LocalLow\Sun\Java\Deployment using Powershell. The script is simply:
Add-Content "%appdata%\LocalLow\Sun\Java\Deployment\deployment.properties" "mydata"
However, it returns "Could not find part of the path 'C:\Users\MyUsername\Desktop\%appdata%\LocalLow\Sun\Java\Deployment\deployment.properties"
Even though I specify %appdata%, it's adding in the current directory of the script. How can I specify the C:\Users\MyUsername\%AppData% folder?
Upvotes: 3
Views: 7243
Reputation: 36342
So try using the PowerShell environmental variables to do this:
Add-Content "$env:appdata\..\locallow\sun\java\deployment\deployment.properties" "mydata"
Edit: On that note, load up the ISE, type in $env:
and familiarize yourself with the available environmental variables. It will benefit you in the long run.
Upvotes: 6
Reputation: 22881
You can't use %appdata%
syntax in PowerShell. Use $ENV:AppData
in its place:
Add-Content "$($ENV:AppData)\LocalLow\Sun\Java\Deployment\deployment.properties" "mydata"
Upvotes: 1