Solved

How to save shortcut with varible in Windows Explorer Favorites

Posted on 2016-08-16
6
25 Views
Last Modified: 2016-09-17
I'm able to run this shortcut from my desktop w/o any issue. It's a link to OneDrive for Business. The shortcut launches Windows Explorer with my files and folders listed. (I plan to incorporate this into a login script so users can access their OneDrive for Business files from Windows Explorer Favorites w/o having to map a drive or use OneDriveSync.)

%windir%\explorer.exe /e,\mycompany-my.sharepoint.com@SSL\DavWWWRoot\personal\%UserName%_mycompany_org\Documents

When I save this shortcut to c:\users\myusername\links (Windows Explorer Favorites shortcuts), and try to launch it from Favorites it launches Windows Explorer, but doesn't show my files.

If I first click Favorites at the top of Windows Explorer so my shortcuts are on the right side and then launch the shortcut it displays the files.

If I remove "%windir%\explorer.exe /e" the %username% saves as my username.

Any suggestions?
0
Comment
Question by:cwhitmore88
  • 2
  • 2
6 Comments
 
LVL 43

Expert Comment

by:Davis McCarn
ID: 41759192
If %Username% includes a space, it will break the string at the space and then be missing the end characters.  Can you try a user which is one word or one without a space?
0
 

Author Comment

by:cwhitmore88
ID: 41759300
All of our usernames are one word in format first initial last name.
0
 
LVL 43

Expert Comment

by:Davis McCarn
ID: 41759348
I generally make the shortcut be explorer.exe /e,<path-to-folder> and Windows then prepends C:\Windows\ automatically.  Have you tried it that way?
0
 

Accepted Solution

by:
cwhitmore88 earned 0 total points
ID: 41759697
using explorer.exe doesn't work under Windows Explorer Favorites.

I found two ways to resolve this: FastTrack Scripting and Powershell.  

FastTrack Scripting is a great scripting language we use for end user scripts and menus. This one line created the Favorites shortcut I needed:

CreateShortCut [UserProfileDir]\links\,OneDrive-ScriptTest,\\mycompany-my.sharepoint.com@SSL\DavWWWRoot\personal\[UserName]_[b]companydomain_com[/b]\Documents

Open in new window


Here is the powershell script I've verified works:
$destination = "c:\users\" + ${env:username} + "\links\"
$shell = New-Object -COM WScript.Shell
$shortcut = $shell.CreateShortcut($destination + "OneDrive-Access.lnk") 
$shortcut.TargetPath = "\\mycompany-my.sharepoint.com@SSL\DavWWWRoot\personal\" + "%username%" + "_[b]mycompanydomain_com[/b]\Documents" 
$shortcut.WorkingDirectory = "%windir%" 
$shortcut.Description = "OneDrive-Access" 
$shortcut.Save() 

Open in new window


(mycompany needs to be set for your o365 tenant)
0
 
LVL 59

Expert Comment

by:LeeTutor
ID: 41802872
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question