My Wiki!

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
windows:win_tricks [2025/02/20 14:54] – created - external edit 127.0.0.1windows:win_tricks [2026/04/23 14:33] (current) – [Env Var Powershell] td
Line 1: Line 1:
-====== Windows tricks ====== +Windows tricks 
-===== - Auto power on =====+## Auto power on
 PS as admin: PS as admin:
     powercfg -devicequery wake_armed     powercfg -devicequery wake_armed
Line 10: Line 10:
 Mouse properties and disable wakeup. Mouse properties and disable wakeup.
  
-===== - Powershell ===== +## Powershell 
-==== - Execution policy ====+### Execution policy 
 Open PS as admin and run: Open PS as admin and run:
      Set-ExecutionPolicy Unrestricted      Set-ExecutionPolicy Unrestricted
  
-==== - Run ps1 script ====+### Run ps1 script
     PS C:\Users\Thuy Dang\Workspace\00_current\gwui> Set-ExecutionPolicy Unrestricted -Scope Process     PS C:\Users\Thuy Dang\Workspace\00_current\gwui> Set-ExecutionPolicy Unrestricted -Scope Process
     PS C:\Users\Thuy Dang\Workspace\00_current\gwui> PowerShell.exe -ExecutionPolicy Bypass -File C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1     PS C:\Users\Thuy Dang\Workspace\00_current\gwui> PowerShell.exe -ExecutionPolicy Bypass -File C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
 +## Env Var Powershell
 +
 +(https://stackoverflow.com/a/59706882/707704)
 +    
 +After I installed JAVA from oracle website I set
 +
 +    [System.Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Java\jdk-13.0.1")
 +
 +To set java in the path I did,
 +
 +    [System.Environment]::SetEnvironmentVariable("Path", [System.Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine) + ";$($env:JAVA_HOME)\bin")
 +
 +Worked like a charm!
 +
 +If you want to have it load up automatically when you open powershell you can do,
 +
 +    New-Item $profile -Type File -Force
 +
 +and open in notepad like
 +
 +    notepad.exe $profile
 +and paste in
 +
 +    [System.Environment]::SetEnvironmentVariable("JAVA_HOME", "D:\devfs\jdk-21.0.10+7")
 +    [System.Environment]::SetEnvironmentVariable("MAVEN_HOME", "D:\devfs\apache-maven-3.9.15")
 +    [System.Environment]::SetEnvironmentVariable("Path", [System.Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine) + ";$($env:JAVA_HOME)\bin";$($env:MAVEN_HOME)\bin")
 +
 +You can close the notepad now! Next, you want to allow powershell to run the ps script so don't forget to grant unrestricted access to running the profile script on load by,
 +
 +    Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
 +
 +Java should now be loaded after you reopen powershell. Thats it!    
          
-===== - Git ===== +## Gi 
-==== - Ignore File mode ====+
 +### Ignore File mode
 git config --global core.fileMode false git config --global core.fileMode false
  

Navigation