Explorer.exe Command line argument to sort by name?

This question is very minor, but I am sometimes willing to waste an hour or two just to avoid a two second annoyance once or twice a day.  (It's just one of those personal quirks that some of us have.)


Our company's shared root directory has many folders.

\\Root\aafolder1\
\aafolder2\
...\bunches of other folders\..
\projects for bob
\projects for sam
\projects for randi
....\way more folders

My desktop has the following Windows shortcut  which opens explorer with my own "Projects for Bob" folder selected.

    shortcut target:       C:\Windows\explorer.exe /select,"\\Root\Projects for Bob"

If I want to view someone else's projects, I double click the icon, then use arrowup or arrowdown to the desired folder & hit enter.

But, it only works if \\Root is sorted by name, which is often not the case.  While it only takes one additional click to sort it by name, I still find it annoying.

As far as I can tell explorer.exe does not have a command line parameter to sort the directory.  I believe sorting is tucked away in the \\root\Thumbs.db file along with other view properties.  

Does anybody have a suggestion of how to control this?  Perhaps a vbs script like this:
    shortcut target:       C:\MyCommands\MAGICSRIPT.VBS /select,"\\Root\Projects for Bob"

I know how to get vbs to open a folder using objShell.Explore strPath , but I can't figure out how to change the sorting sequence.
LVL 5
rberkeConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JohnBusiness Consultant (Owner)Commented:
Windows Explorer can set the View to the Current Folder settings, but the Sort sequence can be easily changed and there is no default setting for that.

Consider using xPlorer2 (Zabkat) if you want detailed settings retained.
0
Bill PrewCommented:
Windows should remember the last sort column and order for a folder, so each time you open it with the shortcut it should always be the same.  Unless you change it for some reason, and if so just make sure you always put it back to Name when done.


»bp
0
JohnBusiness Consultant (Owner)Commented:
Agree. Setting hold until changed. I see lots of user changing Windows Explorer settings on the fly.
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

rberkeConsultantAuthor Commented:
Bill:

Keep in mind, am only trying to avoid a two second annoyance once or twice a day.

The fact that windows holds the setting does not help me at all: I often change the folder sequence to be sorted by Date of Last Modification. Afterwards, I could return Sort by Name but that would also be a two second annoyance one or twice a day.  

Also, it is not just one directory for my own personal use. My company has a standard list of useful shortcuts that appear in every user's quicklaunch toolbar.  Almost all of those shortcuts work best if the target folder is sorted alphabetically.

John,

At the moment, I think you have the Best Answer. Namely "Explorer does not have any command line sorting option. A 3rd party software solution would be necessary."

Nonetheless, I will leave this question open a few more days in the hopes that someone can come up with a vbscript or possibly an AutoHotkey solution.

rberke
0
Bill PrewCommented:
Well, you could feel Explorer keys once it opens, but the problem with trying to control sort order this way is sorting toggles when you invoke a column, so if you were already sorted by Name Ascending, then the same keys the next time you enter will switch it to Name Descending.  Not sure any way to work around this, but here is a small test VBS if you want to experiment a bit...

With WScript.CreateObject("WScript.Shell")
    .Run "explorer /select,""c:\temp""", 1, False
    WScript.Sleep 2000
    .SendKeys "%VO"
    .SendKeys " "
End With

Open in new window


»bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rberkeConsultantAuthor Commented:
Bill, I solved the Ascending/Descending toggle by first sorting by date time. So, it now does exactly what I wanted.

My shortcut has target: C:\CompanyCode\ExploreSort.vbs "\\Root\aafolder1\Transfer to Bob"

Unfortunately, every time I run, the screen flashes for about 4 seconds which is also annoying.  As far as I know, vbscript does not have a screenupdating property to turn off.




filename = WScript.Arguments(0)
cmd = "C:\Windows\explorer.exe /select,""" & filename & """"
With WScript.CreateObject("WScript.Shell")
    .Run cmd, 1, False
    WScript.Sleep 2000
    .SendKeys "%VO{Down}"
    .SendKeys "{Enter}"
    .SendKeys "%VO"
    .SendKeys "{Enter}"
End With
0
rberkeConsultantAuthor Commented:
So, I have satisfied myself that there is no ideal solution to this minor problem.  It is time to close the thread and award points.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.