?
Solved

How to save shortcut with varible in Windows Explorer Favorites

Posted on 2016-08-16
6
Medium Priority
?
35 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Assume you have an outside contractor who comes in seasonally or once a week to do some work in your office, but you only want to give him access to the programs and files he needs and keep all other documents and programs private. Can you do this o…
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…
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…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

718 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