Skip to content

Commit

Permalink
try ajout dùn raccourci bureau
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisdeguet committed Oct 16, 2024
1 parent 61604dd commit fdf1552
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions scriptsharp/ScriptSharp/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,26 @@ public static string GetSDKPath()

public static void CreateDesktopShortcut(string shortcutName, string targetPath)
{
var desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var linkPath = Path.Combine(desktopFolder, $"{shortcutName}.lnk");
var commande = "$WshShell = New-Object -ComObject WScript.Shell; " +
"$Shortcut = $WshShell.CreateShortcut('"+linkPath+"'); " +
"$Shortcut.TargetPath = '"+targetPath+"'; " +
"$Shortcut.Save();";
LogSingleton.Get.LogAndWriteLine("Création du raccourci sur le bureau pour " + targetPath);
//string commande = "Add-Desktop-Shortcut \""+targetPath+"\" \""+shortcutName+"\"";
//LogSingleton.Get.LogAndWriteLine("path "+ commande);
RunPowerShellCommand(commande);
LogSingleton.Get.LogAndWriteLine(" FAIT Raccourci ajouté sur le bureau pour " + targetPath);
try
{
var desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var linkPath = Path.Combine(desktopFolder, $"{shortcutName}.lnk");
var commande = "$WshShell = New-Object -ComObject WScript.Shell; " +
"$Shortcut = $WshShell.CreateShortcut('"+linkPath+"'); " +
"$Shortcut.TargetPath = '"+targetPath+"'; " +
"$Shortcut.Save();";
LogSingleton.Get.LogAndWriteLine("Création du raccourci sur le bureau pour " + targetPath);
//string commande = "Add-Desktop-Shortcut \""+targetPath+"\" \""+shortcutName+"\"";
//LogSingleton.Get.LogAndWriteLine("path "+ commande);
RunPowerShellCommand(commande);
LogSingleton.Get.LogAndWriteLine(" FAIT Raccourci ajouté sur le bureau pour " + targetPath);
}
catch
{
LogSingleton.Get.LogAndWriteLine(" ERREUR Raccourci pour " + targetPath);
}


}

public static void RunPowerShellCommand(string command)
Expand Down

0 comments on commit fdf1552

Please sign in to comment.