PowerShell/PowerShellコンソール起動時にスクリプトを実行する方法
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* PowerShellコンソール起動時にスクリプトを実行する方法 $p...
LinuxなどUNIX系のシェルでターミナル起動時に実行されるスク...
方法を以下に記します。
#contents
#htmlinsertpcsp(win-top.html,win-sp.html)
* 関連記事 [#h3e9341b]
-[[PowerShellスクリプトを起動できるようにする>PowerShell/...
-[[コマンドプロンプト起動時にバッチファイルを読み込み設定...
* 環境変数 $profile [#tb85172e]
PowerShellのコンソールを起動し、''$profile'' と入力しEnte...
出力されたパスがPowerShell起動時に読み込まれるスクリプト...
以下に出力例を記します。
PS C:\Users\Sakura> $profile
C:\Users\Sakura\Documents\WindowsPowerShell\Microsoft.Po...
* $profileを作成して試してみる [#n092ded9]
''$profile''により、配置するディレクトリおよびファイル名...
以下、上記の$profileの出力をもとにした手順です。~
みなさんの環境にあった値で読み替えてください。
+ ディレクトリの作成
mkdir C:\Users\Sakura\Documents\WindowsPowerShell\
#br
+ ファイルの作成
notepad $profile
#br
+ Microsoft.PowerShell_profile.ps1 に以下の記述を書き、保...
# Office2013 Path
$Env:Path += ";C:\Program Files\Microsoft Office 15\root...
# Google Chrome Path
$Env:Path += ";C:\Program Files\Google\Chrome\Application"
# Function
Function touch($file) {
If (Test-Path $file) {
(Get-Item $file).LastWriteTime = Get-Date
} Else {
Out-File -encoding Default $file
}
}
Function uptime() {
[DateTime]::Now - [Management.ManagementDateTimeConve...
Select-Object Days, Hours, Seconds, Milliseconds| Form...
}
+一度、PowerShellを終了し再度起動します。~
&color(red){''エラーになった場合は…''};&br;
スクリプトが実行できる設定になっていないと思われます。~
PowerShellのデフォルトではPowerShellスクリプトを記述した...
以下のリンクの記事で、PowerShellのスクリプトファイル実行...
--[[PowerShellスクリプトを起動できるようにする>PowerShell...
#br
+ 実際にPATHが通っているかを確認したり、定義したFunction...
#ref(01.png)
#br
以上、PowerShell起動時にスクリプトを読み込み実行する方法...
#htmlinsertpcsp(win-btm.html,win-sp.html)
終了行:
#navi(../)
* PowerShellコンソール起動時にスクリプトを実行する方法 $p...
LinuxなどUNIX系のシェルでターミナル起動時に実行されるスク...
方法を以下に記します。
#contents
#htmlinsertpcsp(win-top.html,win-sp.html)
* 関連記事 [#h3e9341b]
-[[PowerShellスクリプトを起動できるようにする>PowerShell/...
-[[コマンドプロンプト起動時にバッチファイルを読み込み設定...
* 環境変数 $profile [#tb85172e]
PowerShellのコンソールを起動し、''$profile'' と入力しEnte...
出力されたパスがPowerShell起動時に読み込まれるスクリプト...
以下に出力例を記します。
PS C:\Users\Sakura> $profile
C:\Users\Sakura\Documents\WindowsPowerShell\Microsoft.Po...
* $profileを作成して試してみる [#n092ded9]
''$profile''により、配置するディレクトリおよびファイル名...
以下、上記の$profileの出力をもとにした手順です。~
みなさんの環境にあった値で読み替えてください。
+ ディレクトリの作成
mkdir C:\Users\Sakura\Documents\WindowsPowerShell\
#br
+ ファイルの作成
notepad $profile
#br
+ Microsoft.PowerShell_profile.ps1 に以下の記述を書き、保...
# Office2013 Path
$Env:Path += ";C:\Program Files\Microsoft Office 15\root...
# Google Chrome Path
$Env:Path += ";C:\Program Files\Google\Chrome\Application"
# Function
Function touch($file) {
If (Test-Path $file) {
(Get-Item $file).LastWriteTime = Get-Date
} Else {
Out-File -encoding Default $file
}
}
Function uptime() {
[DateTime]::Now - [Management.ManagementDateTimeConve...
Select-Object Days, Hours, Seconds, Milliseconds| Form...
}
+一度、PowerShellを終了し再度起動します。~
&color(red){''エラーになった場合は…''};&br;
スクリプトが実行できる設定になっていないと思われます。~
PowerShellのデフォルトではPowerShellスクリプトを記述した...
以下のリンクの記事で、PowerShellのスクリプトファイル実行...
--[[PowerShellスクリプトを起動できるようにする>PowerShell...
#br
+ 実際にPATHが通っているかを確認したり、定義したFunction...
#ref(01.png)
#br
以上、PowerShell起動時にスクリプトを読み込み実行する方法...
#htmlinsertpcsp(win-btm.html,win-sp.html)
ページ名: