Avatar of SP3CLt
SP3CLt
Flag for United States of America asked on

VBS or Batch File - Add a Shortcut to an All Users Desktop Folder

Hello Experts,

I need a VB Script or Batch File to add a shortcut to a all users desktop folder called "Corporate Shortcuts". The link is https://ipay.adp.com.

The requested Icon location is \\pcfileprint\PC_Signatures\CDR Link Project\Bank-Check.ico

I have the the following code ready, however it will place the icon/shortcut on the desktop not the All Users/ Desktop / Corporate Shortcuts folder..


Thanks in advance!

'CreateSC.vbs
Dim objShell:Set objShell=CreateObject("Wscript.Shell")
strDesktop = objShell.SpecialFolders("Desktop")
Dim objSC: Set objSC=objShell.CreateShortCut(strDesktop & "\iPAY-adp.lnk")
With objSC
  .WorkingDirectory="https://ipay.adp.com"
  .TargetPath="https://ipay.adp.com"
  .IconLocation ="\\pcfileprint\PC_Signatures\CDR Link Project\Bank-Check.ico"
  .Save
End With
Set objSC=Nothing
Set objShell=Nothing

Open in new window

Visual Basic ClassicWindows BatchVB Script

Avatar of undefined
Last Comment
SP3CLt

8/22/2022 - Mon
sirbounty

This has been asked before - your users will need access to write to that folder if you're trying to do it under a logon script, for example.
See https://www.experts-exchange.com/questions/23347528/GPO-that-copies-Internet-shortcut-to-allusers-desktop-via-VBScript.html

You don't want the "Desktop" special folder though, use:

strAllUserDesktop = objShell.ExpandEnvironmentStrings("%AllUsersProfile%") & "\Desktop"
sungenwang

Try changing line 3 & 4 to the code below.

sew

strDesktop = objShell.SpecialFolders("ALLUSERSPROFILE")
Dim objSC: Set objSC=objShell.CreateShortCut(strDesktop & "\Desktop\iPAY-adp.lnk")

Open in new window

SP3CLt

ASKER
Hmm, I did not mention that the job will be sent using an altiris solution which will run the job with system permissions.
Also, the folder on ( C:\Documents and Settings\All Users\Desktop\Corporate Shortcuts ) already exists on all workstations, so I'd like the scrip to place the shortcut there.
Thanks for the lightning fast response! (Sungen, Sirbounty)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
sungenwang

You're welcome... You can replace line 4 with the code below.
sew

Dim objSC: Set objSC=objShell.CreateShortCut(strDesktop & "\Desktop\Corporate Shortcuts\iPAY-adp.lnk")

Open in new window

ASKER CERTIFIED SOLUTION
sirbounty

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SP3CLt

ASKER
Hmm, this one seems to work, however it is placing the shortcut wherever the script is ran - so in other words, if it's run on the desktop, the shortcut will be placed on the desktop. Ran on the server, shortcut placed in the same path :)
 
Any other ideas?
Thanks!
 

 
 

'CreateSC.vbs
Dim objShell:Set objShell=CreateObject("Wscript.Shell")
'strDesktop = objShell.SpecialFolders("Desktop")
strAllUserDesktop = objShell.ExpandEnvironmentStrings("%AllUsersProfile%") & "\Desktop\Corporate Shortcuts\ADP_iPay.ink"
Dim objSC: Set objSC=objShell.CreateShortCut("iPAY-adp.lnk")
With objSC
'  .WorkingDirectory="https://ipay.adp.com"
  .TargetPath="https://ipay.adp.com" 
  .IconLocation ="\\pcfileprint\PC_Signatures\CDR Link Project\Bank-Check.ico"
  .Save
End With
Set objSC=Nothing
Set objShell=Nothing
 

Open in new window

RobSampson

>> the job will be sent using an altiris solution which will run the job with system permissions.

If it *is* running as the SYSTEM account, it won't have access to
"\\pcfileprint\PC_Signatures\CDR Link Project\Bank-Check.ico"

to read the icon location.  The SYSTEM account, as far as network access goes, by default only has access to the NetLogon share of your domain controllers.  So if you place the .ico file in your NetLogon share, you will be able to reference it there.

Regards,

Rob.
'CreateSC.vbs
Dim objShell:Set objShell=CreateObject("Wscript.Shell")
strLogonServer = objShell.ExpandEnvironmentStrings("%LOGONSERVER%")
strAllUsersDesktop = objShell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%") & "\Desktop"
Dim objSC: Set objSC=objShell.CreateShortCut(strAllUsersDesktop & "\iPAY-adp.lnk")
With objSC
  .WorkingDirectory="https://ipay.adp.com"
  .TargetPath="https://ipay.adp.com"
  .IconLocation = strLogonServer & "\NetLogon\PC_Signatures\CDR Link Project\Bank-Check.ico"
  .Save
End With
Set objSC=Nothing
Set objShell=Nothing

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SP3CLt

ASKER
Thanks Rob, however the \\pcfileprint is not a DC, simply a File\Print Server - Domain users all have access.
Regardless, the icon has very low priority - the main objective to execute a script which will place the specified weblink/shortcut in the "C:\Documents and Settings\All Users\Desktop\Corporate Shortcuts"
Would a new script be a better idea?
 
sirbounty

How about a list of PCs?
Then you can simply copy the shortcut to all systems using this from a command line:

for /f %a in (c:\PCList.txt) do copy "%allusersprofile%\desktop\corporate Shortcuts\ADP_iPay.ink" "\\%a\c$\documents and setttings\all users\desktop\corporate Shortcuts" /y
SOLUTION
RobSampson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SP3CLt

ASKER
Okay I got it to work! I modified a few of your submissions (from everyone) and here is what I came up with...
'CreateSC.vbs
Dim objShell:Set objShell=CreateObject("Wscript.Shell")
strLogonServer = objShell.ExpandEnvironmentStrings("%LOGONSERVER%")
strAllUsersDesktop = objShell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%") & "\Desktop\Corporate Shortcuts"
Dim objSC: Set objSC=objShell.CreateShortCut(strAllUsersDesktop & "\iPAY-adp.lnk")
With objSC
  .WorkingDirectory="https://ipay.adp.com"
  .TargetPath="https://ipay.adp.com"
  .IconLocation ="\\pcfileprint\PC_Signatures\CDR Link Project\Bank-Check.ico"
  .Save
End With
Set objSC=Nothing
Set objShell=Nothing

Open in new window

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23