VB script - creating a desktop shortcut (1 Viewer)

ghudson

Registered User.
Local time
Today, 07:09
Joined
Jun 8, 2002
Messages
6,195
I am attempting to use a VB script for the first time. CyberCow has helped my so far with the script that will create a shortcut on the users desktop. I can get it to work for a simple database but not for a "secured" database shortcut.

My end result for the secured shortcut Target: field should look like this...
"C:\Program Files\Microsoft Office\Office\msaccess.exe" /runtime" /wrkgrp" "C:\Databases\dbSecured.mdw" "C:\Databases\TestDB.mdb"

BUt this is what I am getting with my feeble attempts below...
"C:\Program Files\Microsoft Office\Office\msaccess.exe" \runtime" \wrkgrp" "C:\Databases\dbSecured.mdw" "C:\Databases\TestDB.mdb"

Below are two attempts that should work but the forward slashes before the workgroup and runtime command line switches are being reversed into back slashes when I run the script. Do you know of a way that I can format the TargetPath string? Can you spot the error of my ways?

link.TargetPath = "C:\Program Files\Microsoft Office\Office\msaccess.exe" & Chr(34) & Chr(32) & "/runtime" & Chr(32) & "/wrkgrp" & Chr(32) & Chr(34) & "C:\Databases\dbSecured.mdw" & Chr(34) & " " & Chr(34) & "C:\Databases\TestDB.mdb"

link.TargetPath = "C:\Program Files\Microsoft Office\Office\msaccess.exe" & Chr(34) & Chr(32) & Chr(47) & "runtime" & Chr(32) & Chr(47) & "wrkgrp" & Chr(32) & Chr(34) & "C:\Databases\dbSecured.mdw" & Chr(34) & " " & Chr(34) & "C:\Databases\TestDB.mdb"

I am attaching my VB script file for the curious. Thanks in advance for your help and suggestions!
 

Attachments

  • vbscript.zip
    874 bytes · Views: 588

ritchieroo

Registered User.
Local time
Today, 11:09
Joined
Aug 2, 2002
Messages
80
this works, i think

Code:
Set Shell = CreateObject("wscript.shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set link = Shell.CreateShortCut(DesktopPath & "\Test Link.lnk")
link.Arguments = " /user TestUser"
link.Description = "New Test Link"
link.Hotkey = "Ctrl+Alt+T"
link.IconLocation = ""
link.TargetPath = "C:\Program Files\Microsoft Office\Office\msaccess.exe"" " & _
                  "/runtime"" /wrkgrp"" ""C:\Databases\dbSecured.mdw"" ""C:\Databases\TestDB.mdb" 
link.WindowStyle = 3
link.WorkingDirectory = ""
link.Save
 

ghudson

Registered User.
Local time
Today, 07:09
Joined
Jun 8, 2002
Messages
6,195
Thanks for responding ritchieroo!

Almost but your script is also flipping the / into \ and there are a couple of extraneous quotes as well. Here is what you scripts creates on my Windows XP computer...

"C:\Program Files\Microsoft Office\Office\msaccess.exe" \runtime" \wrkgrp" "C:\Databases\dbSecured.mdw" "C:\Databases\TestDB.mdb" /user TestUser

I need the script to create the Target: info like this...

"C:\Program Files\Microsoft Office\Office\msaccess.exe" /runtime /wrkgrp "C:\Databases\dbSecured.mdw" "C:\Databases\TestDB.mdb" /user TestUser

Any suggestions?
 

Users who are viewing this thread

Top Bottom