Solved

How to save shortcut with varible in Windows Explorer Favorites

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 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…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.

622 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