Powershell script tips

Write to a file

Use Set-Content and Add-Content

Set-Content "C:\Program Files\Sublime Text 2\subl.bat" "@echo off"
Add-Content "C:\Program Files\Sublime Text 2\subl.bat" "sublime_text.exe %1"

Adding to environmental path variable

from http://softwaresalariman.blogspot.co.uk/2008/01/add-path-environment-variable-in.html

Set-Content "C:\Program Files\Sublime Text 2\subl.bat" "@echo off"
Add-Content "C:\Program Files\Sublime Text 2\subl.bat" "sublime_text.exe %1"
[System.Environment]::SetEnvironmentVariable("PATH", $Env:Path + ";C:\Program Files\Sublime Text 2", "Machine")
Powershell script tips

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s