PowerShell does not run when right-clicked to run PowerShell.

Asked 2 years ago, Updated 2 years ago, 49 views

If you copy the following to PowerShell, the script will run without any problems.
If you put a space between ★, the screen will drop without processing when you run it in powershell.
Even if you put pause in ●, it will fall off without stopping.

$TargetLogFolder="C:\copy"
★
if (-not(Test-Path$TargetLogFolder)){
    Add-Type-Assembly System.Windows.Forms
    System.Windows.Forms.MessageBox::Show("The file does not exist., "Caution", "OK", "Warning", "Button 3")
  pause●
    EXIT
}
★
$g = "C:\hoge"
$o = Get-Date-format "yyyyMMdd_HHmmss"
New-Item$g\"$o.txt"

powershell

2022-09-30 11:43

1 Answers

I was able to solve this question. The solution is to save the script itself from UTF-8 to ANSI and run Powershell to ensure it works.


2022-09-30 11:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.