@@ -13,7 +13,7 @@ function Start-yc360 {
1313 Set-StrictMode - Version Latest
1414
1515 # Version Info
16- $scriptVersion = " 2025.06.20.2137 "
16+ $scriptVersion = " 2025.07.28.1950 "
1717 Write-Host " `n [INFO] Starting yc-360 installer... (Version: $scriptVersion )"
1818
1919 try {
@@ -29,13 +29,8 @@ function Start-yc360 {
2929
3030 # Download yc-360
3131 Write-Host " [INFO] Downloading yc-360..."
32- if (Get-Command curl.exe - ErrorAction SilentlyContinue) {
33- & curl.exe - sSL - o $zip_file $url
34- } else {
35- Write-Host " [INFO] 'curl' not found, using Invoke-WebRequest..."
36- $ProgressPreference = ' SilentlyContinue'
37- Invoke-WebRequest - Uri $url - OutFile $zip_file - UseBasicParsing
38- }
32+ $ProgressPreference = ' SilentlyContinue'
33+ Invoke-WebRequest - Uri $url - OutFile $zip_file - UseBasicParsing
3934
4035 # Detect architecture
4136 $arch = $env: PROCESSOR_ARCHITECTURE
@@ -47,6 +42,7 @@ function Start-yc360 {
4742 " aarch64" { $arch_folder = " arm64" }
4843 default { throw " [ERROR] Unsupported architecture: $arch " }
4944 }
45+ Write-Host " [INFO] Detected platform: $platform / architecture: $arch_folder "
5046
5147 # Extract yc.exe (flat layout)
5248 Write-Host " [INFO] Extracting yc binary..."
@@ -57,6 +53,7 @@ function Start-yc360 {
5753 } else {
5854 throw " [ERROR] No extraction tool found (jar or unzip required)"
5955 }
56+ Write-Host " [INFO] yc.exe extracted to: $bin_dir \yc.exe"
6057
6158 # Move binary
6259 $target = Join-Path $work_dir " $platform \yc.exe"
@@ -69,40 +66,40 @@ function Start-yc360 {
6966 # Clean up temp folders (except output)
7067 Remove-Item - Recurse - Force " $work_dir \linux" , " $work_dir \mac" , " $work_dir \windows" , " $zip_file " - ErrorAction SilentlyContinue
7168
72- # Detect JAVA_HOME
73- if (-Not $JavaHome ) {
74- $javaCmd = Get-Command java - ErrorAction SilentlyContinue
75- if (-not $javaCmd ) {
76- Write-Warning " [WARN] Java not found in PATH. Skipping execution."
77- return
69+ # Set Java path if not provided
70+ if (-not $JavaHome -or $JavaHome -eq " " ) {
71+ $javaPath = Get-Command java - ErrorAction SilentlyContinue | Select-Object - ExpandProperty Source
72+ if ($javaPath ) {
73+ $JavaHome = Split-Path (Split-Path $javaPath - Parent) - Parent
74+ Write-Host " [INFO] JavaHome not provided. Using detected JavaHome: $JavaHome "
75+ } else {
76+ Write-Error " [ERROR] Java not found in PATH and JavaHome was not provided."
77+ exit 1
7878 }
79- $javaPath = $javaCmd.Source
80- $JavaHome = Split-Path - Parent (Split-Path - Parent $javaPath )
81- Write-Host " [INFO] Detected JAVA_HOME: $JavaHome "
79+ } else {
80+ Write-Host " [INFO] Using provided JavaHome: $JavaHome "
8281 }
8382
84- # Detect PIDs
85- if (-not $TargetPids ) {
86- if (Get-Command jps - ErrorAction SilentlyContinue) {
87- $TargetPids = (& jps | Where-Object { $_ -notmatch ' Jps' } | ForEach-Object {
88- ($_ -split ' \s+' )[0 ]
89- }) -join " ,"
90- }
91-
92- if (-not $TargetPids ) {
93- $javaProcesses = Get-Process | Where-Object { $_.Name -like " java*" }
94- $TargetPids = $javaProcesses.Id -join " ,"
95- }
96-
97- if (-not $TargetPids ) {
98- Write-Warning " `n [WARN] No running Java process found. Nothing to capture."
99- return
83+ # Set PIDs if not provided
84+ if (-not $TargetPids -or $TargetPids -eq " " ) {
85+ $javaProcesses = Get-Process java - ErrorAction SilentlyContinue
86+ if ($javaProcesses.Count -eq 0 ) {
87+ Write-Error " [ERROR] No running Java processes found, and TargetPids not provided."
88+ exit 1
10089 }
90+ $TargetPids = ($javaProcesses | Select-Object - ExpandProperty Id) -join " ,"
91+ Write-Host " [INFO] TargetPids not provided. Using detected Java PIDs: $TargetPids "
92+ } else {
93+ Write-Host " [INFO] Using provided TargetPids: $TargetPids "
10194 }
10295
103- # Execute yc for each PID
96+ # Print the detected PIDs
10497 $pidsArray = $TargetPids -split ' ,'
10598
99+ Write-Host " `n [INFO] Detected the following Java PIDs to capture:"
100+ $pidsArray | ForEach-Object { Write-Host " - $_ " }
101+
102+ # Execute yc for each PID
106103 foreach ($targetPid in $pidsArray ) {
107104 if (-not $ExtraArgs -or $ExtraArgs.Count -eq 0 ) {
108105 Write-Host " [INFO] Running yc with default: -onlyCapture for PID: $targetPid "
@@ -115,10 +112,24 @@ function Start-yc360 {
115112
116113 # Final cleanup
117114 Remove-Item - Recurse - Force " $bin_dir " - ErrorAction SilentlyContinue
118- Write-Host " `n [INFO] yc-360 run completed. Output saved in: $work_dir "
115+
116+ # Navigate to output directory and list contents
117+ Set-Location $work_dir
118+ Write-Host " `n [INFO] Listing contents of output directory:"
119+ Get-ChildItem - Force | Format-Table - AutoSize
120+
121+ # Open the output folder in File Explorer
122+ Start-Process explorer.exe $work_dir
123+
124+ Write-Host " `n [INFO] Script executed successfully."
119125
120126 } catch {
121- Write-Warning " `n [WARN] Script encountered an error: $_ "
127+ Write-Host " `n [ERROR] yc-360 script encountered an error."
128+ Write-Host " ------------------------------------------------------------"
129+ Write-Host " Need help? Visit our troubleshooting FAQ page:"
130+ Write-Host " https://test.docs.ycrash.io/yc-360/faq/run-yc-360-faq.html"
131+ Write-Host " ------------------------------------------------------------"
132+ Write-Host " `n [ERROR DETAILS] $ ( $_.Exception.Message ) "
122133 }
123134}
124135
0 commit comments