Solved

How to save shortcut with varible in Windows Explorer Favorites

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

Expert Comment

by:Davis McCarn
Comment Utility
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
Comment Utility
All of our usernames are one word in format first initial last name.
0
 
LVL 42

Expert Comment

by:Davis McCarn
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

So many times I have seen the words written in a question "if only I could show you" or " I know how hard it is for you since you can't see it" in any zone. That has inspired me to write about this tool in windows 7 called "Problem Steps Recorder…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

743 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

18 Experts available now in Live!

Get 1:1 Help Now