Search through multiple public folders - outlook

One of our customers uses their public folders for sending price lists to various customers, they have one main folder with dozens of sub-folders, now everytime someone wants to be deleted from the list and noone knows in which folder he is we have to manually search through every folder, so I was wondering if there is any way to automate this with powershell or the exchange management shell to look through all folders at once?

While you cannot delete items with Exchange Powershell, you can get some item detail.
If you call Get-PublicFolderItemStatistics on a folder it will output a few details about each item. This may be enough to at least tell you if a folder contains what you are looking for.
You could then loop thru the selected folder and its children and call Get-PublicFolderItemStatistics on each folder. Then do a Where-Object filter on the output to filter out any item that doesn't match your filter.
Sadly though, you're left with either EWS (which has some powershell wrappers) or MAPI to do the deletes.

Related

can i make windows file explorer show certain text extracted from files as a new detail column?

I have folders full of log files, and I'd like to display their final status in a column in the folder they are in. That is, in Details view I want to make a new column that shows a piece of text which is extracted from each file. I don't expect to find such a thing out there, and the searches I've tried haven't even yielded a hint about how I would go about writing a plugin to do any such thing. Is it possible?
This sort of thing used to be possible with custom column handler shell extensions but Microsoft removed support for those in Vista (3rd-party Explorer replacements might still support them).
Microsofts inadequate replacement are property handlers. You cannot do this for .log files, you would have to invent a .myapp-log file extension.
Some people abuse the Windows 10 cloud API to create columns but that only works in specific folders.
If you are looking for a specific string in the last line, you could perhaps use a custom icon handler for .log files.

Programmatically sort folders on Windows 8

Windows 8 does not seem to persist sort orders on individual folders. I'm guessing when explorer.exe terminates (like when rebooting) these preferences get discarded? Beats me, all I know is after a time (like a few days) those preferences get totally lost.
Is there a way to duplicate programmatically sorting folders in Windows Explorer (opting one of the 'Sort by' options in the context menu)?
Such that, say I have a folder opened in the Windows UI. Say the folder is currently set to sort by 'Name' and after running the program which will sort it by size I check the sort order in Windows Explorer again and it now says 'Size'?
I have a certain big folder structure that I want all of it and its subfolders sorted by size permanently. So I would like to run this program before viewing them and not have to individually manually re-sort them all first. Thanks!
The sort order belongs to the view, not folder. You can have two Windows Explorer windows open on the same folder, each has a different sort order.
To force a sort order when Windows Explorer navigates to a specific folder, first hook the DShellWindowsEvents::WindowRegistered event on the shellwindows object, then each time when the WindowRegistered event triggers, enumerate through the shell window list and compare with your existing enumeration to find the new windows explorer instance. Once you get hand on the new instance, hook up the DWebBrowserEvents2::DocumentComplete event for that instance to listen to its navigations.
When a navigation is complete, the DocumentComplete event will give you the target URL which you can use to detect if the target is inside your big folder structure. If so, query the IShellBrowser service from the windows explorer instance, then call QueryActiveShellView to get the shell view. Once you get the shell view, QI for IFolderView2 and then call SetSortColumns.
The Automate the Active Windows Explorer or Internet Explorer Window sample on codeproject has most of the code, except that it calls IShellView::SelectItem to simulate SHOpenFolderAndSelectItems at the end.
You can save Explorer sort settings by holding CTRL while clicking on that X on top right.
http://blog.chron.com/helpline/2009/01/saving-explorer-sort-order/

How can I determine which folder the user was browsing when my program was invoked from the "sent to" menu?

I put a shortcut to my application in SendTo. Now I can select some files in Explorer and send them to my application. But how can I get the path where the files are? My program is supposed to create a new file in the parent directory that's common to all the received file names.
For example, if I have these files:
C:\one.txt
C:\1\
I select the file one.txt and the directory 1 in Explorer. How can I find out that the starting directory for these files is C:\?
I know I can use ParamStr() to get files' paths, but what then?
I could try to get common directory for all the files passed to my application, but if I select in C:\ directories 1 and 2 and these directories look like this:
C:\1\4\5\one.txt
C:\1\4\two.txt
Then the starting directory is C:\1\4.
Prior to Windows 7, all files selected in Explorer always reside in the same directory, so it's easy to know which directory the user was browsing. It's the same as the directory of any one file. Use ExtractFilePath for that.
As of Windows 7, though, Explorer lets you put directories into groups called libraries. All the files from all the folders are displayed together in a single view. Users can select files from multiple directories and send them all to your program at once. The view doesn't represent any real directory on the disk, so the question asked here is meaningless.
As an alternative, you could decide use the ancestor directory common to all the files sent to your program, but that won't tell you much. For one thing, if the files reside on multiple drives, the common directory will be the empty string. The directory you calculate also might not be writable by the current account, even if the directories of one or more of the selected files are.
It will probably be easier to just use the directory of the first file you receive, or even to display a UI that asks the user what directory to use in the cases you can't determine it automatically. (Maybe you could pre-populate the result with the first directory, so the user doesn't have to do anything but approve your suggestion in the common case.)
I think I will just take all the filenames passed to my program via ParamStr and use this function:
http://delphi.about.com/od/delphichallengesexercises/qt/delphi-extract-base-path-challenge.htm
to find common base path which should be the path where the SendTo was invoked.

Adding files to all users 'My Documents' folders in Windows

I am creating an installer (using Inno Setup) for a windows application. The app has initial documents that I need to store in the users 'My Documents' folder.
Here is the issue, I install it as an Admin, but there may be one or many non admin users on that machine. How can i add that same folder to all the possible current (and future user's) My Documents folder?
Here is what i have tried so far-
1) I could try to pick up all usernames - This however, wont work for future user creations :(
2) I have tried to add it to the systems %allusersprofile%\Documents folder. It does not get reflected to individual My Documents folders.
I believe there should be a way, but have been unable to find a clean solution off the internet till now. Can anyone direct me towards the right path?
Mucho Thanks!
There isn't really a construct for this in Windows. You have a few options:
Put the document in some common place (like %allusersprofile%\Documents, or %program files%\yourCompany\yourApp\documents) and create a start menu link/icon that points to either the folder with the documents or the document itself.
Put the document into the Default User documents folder. When a new user is created, their profile is setup to mirror that of the default user. This doesn't help you with current users, but it does help you for users who haven't been created (logged on)
I'd go with option 1 because it's relatively standard and its what your average user is going to expect.
Look at Inno Setup Shell Folder Constants : {commondocs}

Decrypt/Read/Modify “.automaticDestinations-ms” and/or ".customDestinations-ms"

Does anyone know how to read the files Microsoft creates for JumpLists?
I want to clear from JumpList all history/most visited/recently closed, WITHOUT clearing up the tasks.
I tried to use the APPID from win7api, and clear for example, google chrome's jumplist. But with "ClearAllUserTasks" method it clears EVERYTHING from the jumplist, even the "Tasks". The same thing is with deleting the file.
Isn't any way of knowing the format of the *destinations-ms files, so I can modify them myself? Basically, wanting to clear just history/most visited, but couldn't find anything in Windows 7 Api (nor C++ or .NET).
The file is a Structured Storage file.
The OpenMCDF project is capable of reading and basic editing out of the box and you can easily create a specific tool with the library.
Here are steps to the hacky approach I took to clear Chrome's Recent list:
Open the AutomaticDestinations folder
%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations
Sort the AutomaticDestinations folder descending by Date modified
Open Chrome and visit a site
In the AutomaticDestinations folder, rename the most recently modified item
Right click on Chrome's icon
If the Recent list has been removed, you have the right file and can delete it.
Otherwise, repeat steps 3 through 5 until the Recent list is empty
Don't forget to return the other files back to their original names.
To clear the Recent list of other applications, open them and perform and action that will cause their list to be modified.
The advantage of this method is that removes the need to read .automaticDestinations-ms files.

Resources