Solved

How to save shortcut with varible in Windows Explorer Favorites

Posted on 2016-08-16
6
24 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

I hope this helps those who have been battling the SanDisk / U3 problem for a while. For anyone that is running Windows 7 64bit and is receiving and searching the internet for the “Windows Error: Windows has allocated a drive letter to the U3 dri…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

862 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now