1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Option Explicit
Dim WS, LaDate, strDesktop, TheLink, fso
Set WS = CreateObject("Wscript.Shell")
CreerRaccourci
LaDate = Replace(Date, "/", " ") ' On remplace le séparateur de date par un espace
'Exemple d'application recevant la date sous le format demandé
WS.Run "NotePad.exe ", 1, False ' Lance NotePad.exe
WScript.Sleep 1000 ' Attend 1 seconde pour s'assurer de l'ouverture de NotePad
WS.SendKeys LaDate ' Envoie la date vers NotePad
Sub CreerRaccourci()
Set fso = CreateObject("Scripting.FileSystemObject")
strDesktop = WS.SpecialFolders("Desktop")
If fso.FileExists(strDesktop & "\" & Left(Wscript.ScriptName, Len(Wscript.ScriptName) -4) & ".lnk") Then Exit Sub
set TheLink = WS.CreateShortcut(strDesktop & "\" & Left(Wscript.ScriptName, Len(Wscript.ScriptName) -4) & ".lnk")
TheLink.TargetPath = WScript.ScriptFullName ' Cible du raccourci
TheLink.WindowStyle = 1
TheLink.Hotkey = "CTRL+D" ' Touche de raccourci
TheLink.IconLocation = "Notepad.exe, 0" 'Icône du raccourci
TheLink.Description = "Script pour écrire la date du jour dans un programme donné"
TheLink.WorkingDirectory = strDesktop ' Dossier de travail
TheLink.Save
End Sub |
Partager