OVH Cloud OVH Cloud

Création d'un raccourci bureau

6 réponses
Avatar
CBR
Bonjour,

J'ai un problème en voulant créer un raccourci. En effet, dans la propriété
TARGETPATH je dois placer une ligne de commande du style :

"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" /wrkgrp
"\\MONSERVEUR\TEST.MDW" "C:\TEST\TEST.mdb"

J'ai un souci pour retranscire l'antislash de /wrkgrp et les double slash \\
voici mon code au dessous :

set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\Test par
VBS.lnk")
oShellLink.TargetPath = """C:\Program Files\Microsoft
Office\Office\MSACCESS.EXE""" & "/wrkgrp" & """\\MONSERVEUR\TEST.MDW""" &
"""C:\TEST\TEST.mdb"""
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "Ctrl+Alt+e"
oShellLink.IconLocation = "notepad.exe, 0"
oShellLink.Description = "Shortcut Script"
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save


Celane fonctionne pas. Quelqu'un connait-uil la solution pour retranscrire
correctement la ligne de commande (TARGETPATH).

MERCI BEAUCOUP.

6 réponses

Avatar
Do Re Mi chel La Si Do
Avatar
Fred
Dans le message:,
Do Re Mi chel La Si Do écrit:
et \


Bonjour,
M'est avis qu'il manque des espaces.
... & " /wrkgrp " & _
" MONSERVEURTEST.MDW " & _
" C:TESTTEST.mdb "

(en vbs il n'est pas utile de doubler les "")


--
Fred
http://www.cerbermail.com/?3kA6ftaCvT

Avatar
CBR
J'ai boien essayé de doubler et quadrupler les SLASH mais après l'exécution
du script , la ligne de commande donne invariablement ceci :
"C:Program FilesMicrosoft
OfficeOfficeMSACCESS.EXE"wrkgrp"MONSERVEURTEST.MDW""C:TESTTEST.mdb"
alors que je devrais avoir :
"C:Program FilesMicrosoft OfficeOfficeMSACCESS.EXE" /wrkgrp
"MONSERVEURTEST.MDW" "C:TESTTEST.mdb"


et \








Avatar
jbongran
CBR wrote:
Bonjour,

J'ai un problème en voulant créer un raccourci. En effet, dans la
propriété TARGETPATH je dois placer une ligne de commande du style :

"C:Program FilesMicrosoft OfficeOfficeMSACCESS.EXE" /wrkgrp
"MONSERVEURTEST.MDW" "C:TESTTEST.mdb"

J'ai un souci pour retranscire l'antislash de /wrkgrp et les double
slash voici mon code au dessous :

set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "Test
par VBS.lnk")
oShellLink.TargetPath = """C:Program FilesMicrosoft
OfficeOfficeMSACCESS.EXE""" & "/wrkgrp" &
"""MONSERVEURTEST.MDW""" & """C:TESTTEST.mdb"""
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "Ctrl+Alt+e"
oShellLink.IconLocation = "notepad.exe, 0"
oShellLink.Description = "Shortcut Script"
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save


Celane fonctionne pas. Quelqu'un connait-uil la solution pour
retranscrire correctement la ligne de commande (TARGETPATH).

MERCI BEAUCOUP.


Et comme ça :
Dim strCde, strArg
strCde = """C:Program FilesMicrosoft OfficeOfficeMSACCESS.EXE"""
strArg = "/wrkgrp ""MONSERVEURTEST.MDW"" ""C:TESTTEST.mdb"""
WScript.Echo strCde

Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oShellLink = WshShell.CreateShortcut(strDesktop & "Test par
VBS.lnk")
oShellLink.TargetPath = strCde
oShellLink.Arguments = strArg
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "Ctrl+Alt+e"
oShellLink.IconLocation = "notepad.exe, 0"
oShellLink.Description = "Shortcut Script"
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save
Set oShellLink = Nothing
Set WshShell = Nothing

Extrait de la doc de vbscript 5.6 en ce qui concerne la propriété de
TargetPath:
Le chemin vers le fichier exécutable du raccourci.
Remarques
Chaîne.
Cette propriété permet d'extraire le chemin de la cible du raccourci
uniquement.
Tout argument concernant le raccourci lui-même doit être placé dans la
propriété Arguments.

Ps: Les double apostrophes ne sont je pense, pas utiles pour les endroits où
il n'y a pas d'espaces (chemins vers les fichiers mdw et mdb)
Essayes avant de creer le raccourci de faire un WScript.Echo de la ligne
créé

Avatar
Do Re Mi chel La Si Do
Bonsoir !

(en vbs il n'est pas utile de doubler les "")




Je qui confirme que je connais pas VBS.
Merci pour l'info.

@-salutations

Michel Claveau



Avatar
CBR
Merci beaucoup.

Cela marche parfaitement.


CBR wrote:
Bonjour,

J'ai un problème en voulant créer un raccourci. En effet, dans la
propriété TARGETPATH je dois placer une ligne de commande du style :

"C:Program FilesMicrosoft OfficeOfficeMSACCESS.EXE" /wrkgrp
"MONSERVEURTEST.MDW" "C:TESTTEST.mdb"

J'ai un souci pour retranscire l'antislash de /wrkgrp et les double
slash voici mon code au dessous :

set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "Test
par VBS.lnk")
oShellLink.TargetPath = """C:Program FilesMicrosoft
OfficeOfficeMSACCESS.EXE""" & "/wrkgrp" &
"""MONSERVEURTEST.MDW""" & """C:TESTTEST.mdb"""
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "Ctrl+Alt+e"
oShellLink.IconLocation = "notepad.exe, 0"
oShellLink.Description = "Shortcut Script"
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save


Celane fonctionne pas. Quelqu'un connait-uil la solution pour
retranscrire correctement la ligne de commande (TARGETPATH).

MERCI BEAUCOUP.


Et comme ça :
Dim strCde, strArg
strCde = """C:Program FilesMicrosoft OfficeOfficeMSACCESS.EXE"""
strArg = "/wrkgrp ""MONSERVEURTEST.MDW"" ""C:TESTTEST.mdb"""
WScript.Echo strCde

Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oShellLink = WshShell.CreateShortcut(strDesktop & "Test par
VBS.lnk")
oShellLink.TargetPath = strCde
oShellLink.Arguments = strArg
oShellLink.WindowStyle = 1
oShellLink.Hotkey = "Ctrl+Alt+e"
oShellLink.IconLocation = "notepad.exe, 0"
oShellLink.Description = "Shortcut Script"
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save
Set oShellLink = Nothing
Set WshShell = Nothing

Extrait de la doc de vbscript 5.6 en ce qui concerne la propriété de
TargetPath:
Le chemin vers le fichier exécutable du raccourci.
Remarques
Chaîne.
Cette propriété permet d'extraire le chemin de la cible du raccourci
uniquement.
Tout argument concernant le raccourci lui-même doit être placé dans la
propriété Arguments.

Ps: Les double apostrophes ne sont je pense, pas utiles pour les endroits où
il n'y a pas d'espaces (chemins vers les fichiers mdw et mdb)
Essayes avant de creer le raccourci de faire un WScript.Echo de la ligne
créé