create_shortcut.ps1 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # 创建桌面快捷方式脚本
  2. # 运行此脚本将在桌面创建GreaterWMS的启动快捷方式
  3. Write-Host "正在创建桌面快捷方式..." -ForegroundColor Yellow
  4. # 获取脚本所在目录(项目根目录)
  5. $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
  6. # 桌面路径
  7. $DesktopPath = [Environment]::GetFolderPath("Desktop")
  8. $ShortcutPath = Join-Path $DesktopPath "GreaterWMS.lnk"
  9. # 启动脚本路径(优先使用.bat,兼容性更好)
  10. $StartScript = Join-Path $ScriptDir "start_project.bat"
  11. # 图标路径(如果有的话,可以指定一个图标文件)
  12. # $IconPath = Join-Path $ScriptDir "icon.ico"
  13. try {
  14. # 创建快捷方式
  15. $WshShell = New-Object -ComObject WScript.Shell
  16. $Shortcut = $WshShell.CreateShortcut($ShortcutPath)
  17. $Shortcut.TargetPath = $StartScript
  18. $Shortcut.WorkingDirectory = $ScriptDir
  19. $Shortcut.Description = "GreaterWMS 仓库管理系统"
  20. # $Shortcut.IconLocation = $IconPath
  21. $Shortcut.Save()
  22. Write-Host "✓ 桌面快捷方式创建成功!" -ForegroundColor Green
  23. Write-Host " 位置: $ShortcutPath" -ForegroundColor Cyan
  24. Write-Host ""
  25. Write-Host "现在您可以在桌面双击 'GreaterWMS' 快捷方式来启动项目了!" -ForegroundColor Yellow
  26. } catch {
  27. Write-Host "✗ 创建快捷方式失败: $_" -ForegroundColor Red
  28. Write-Host ""
  29. Write-Host "请尝试以管理员身份运行此脚本,或者手动创建快捷方式:" -ForegroundColor Yellow
  30. Write-Host " 1. 右键点击桌面 -> 新建 -> 快捷方式" -ForegroundColor Gray
  31. Write-Host " 2. 输入: $StartScript" -ForegroundColor Gray
  32. Write-Host " 3. 命名为: GreaterWMS" -ForegroundColor Gray
  33. }
  34. Write-Host ""
  35. Write-Host "按任意键退出..."
  36. $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")