I'm looking for a way to put an event trigger on a Windows XP folder which would automatically copy a file from folder1 to folder2 when the file as created in folder1, ideally with System permissions. The purpose is to make a secure repository for files which would be protected. I've looked at WMI, but can't figure out how to get it to trigger on the folder. Any pointers in the right direction would help. Thanks!
If you want to use WMI and need to monitor your folder all the time, you can use WMI permanent event subscription.
You would:
Create a WMI filter ( a query like this, for example: "Select * From __InstanceCreationEvent Within 5 Where TargetInstance Isa 'Cim_DataFile' And TargetInstance.Drive = 'C:' and TargetInstance.Path = '\folder\subfolder\'")
Create a WMI event consumer (a batch or VBScript file to copy the created file to your new location)
Bind the two together
This way you would ensure that the folder is monitored 'at all times' (as long as WMI service is running). You can use VBScript, PowerShell, C# or MOF to set this up. (See the Script Center blog for details)
Related
Currently users have their own inbox folder and due to corporate policy emails will automatically be deleted after a set period of time.
Some emails however users would like to be able to keep for reference.
In order to accomplish allowing users to keep their importasnt emails; a personal folder file .pst needs to be created. The deletion policy will on affect the exchange profile folder that they currently use. This special personal folder should not be touched by the corporate system.
I need to be able to run a powershell script to automatically create this folder for the user (logged in user on the computer) and assign it in outlook 2019 for use, the user will then copy their specific emails into that personal folder. If I can't do it for the current logged in user - then by a collection of usernames and put in their one drive folder ??
Anyone with knowledge of how to or code to do this, I would appreciate your help - while I can code - I'am not a Powershell Guru so specifics and functions that experts might know exactly - I do not know, so please in your answer provide good guidance.
I am using windows 10 .1909 and the powershell version that ships with it.
The Outlook object model provides the AddStoreEx method which adds a Personal Folders file (.pst) in the specified format to the current profile.
Sub CreateUnicodePST()
Dim myNameSpace As Outlook.NameSpace
Set myNameSpace = Application.GetNamespace("MAPI")
myNameSpace.AddStoreEx "c:\" & myNameSpace.CurrentUser & "\.pst",olStoreUnicode
End Sub
After creating additional storage in the Outlook profile users can move items for keeping them locally. Or you may consider creating a VBA script or COM add-in for doing that programmatically. See Walkthrough: Create your first VSTO Add-in for Outlook for getting started quickly.
In our company we follow a process where in a team saves e-mails in a shared folder from where people from another team are supposed to pick and start processing. As a improvement idea I was looking for a macro which upon triggering can loop through all the saved e-mails in that folder and can save or bring them in a outlook sub-folder of the processor's inbox of this team.
I have tried and figured out a code from internet which can copy files from one folder to another (please see below) but could not get to modify it to save the .msg files in the outlook subfolder. This is doable manually so was thinking there should be a macro as well which can do it automatically.
Any help will be highly appreciated. Thank you in advance .
Sub Download_sub()
Application.EnableCancelKey = xlDisabled
'downloads the submission mail item into users download folder
Set fobj = CreateObject("Scripting.FileSystemObject") 'create the file system object
fobj.CopyFolder sht_Databases.Range("B21").Value & "\MailFolder" & _
, sht_Databases.Range("B22").Value
Set fobj = Nothing 'release the variable
End Sub
You can use
Application.CreateItemFromTemplate and pass the folder as the second parameter. Note that the message will be created in the unsent state and no sender properties will be copied.
Namespace.OpenSharedItem to open an MSG file, then copy it to a given folder using MailItem.Move().
I am working on a C++ windowsform project, using visual Studio IDE.
I use CFileDialog class to ask the user to select a file to open.
It display an usual open file selection windows.
I would like the default folder displayed to be the same as the one accessed when clicked on "My computer", where the harddrives, USB drives, dvd drives etc. are displayed.
I can define default folder by writting its path tolpstrInitialDir member, but I don't find the path for such a folder. I tried "\", "explorer.exe", "", none of them gave me the expected result.
The application will be used by several users, so the solution must not include the user name in the path. i.e "C:\Documents and Settings[user]\Desktop\My Computer" may work but is not correct for my application.
Does anyone know of to define the "root" path of windows (i.e the root of C:\) ?
I searched on SO and internet but maybe I have used wrong keywords because I couldn't find appropriate content.
My Computer is a virtual shell folder that doesn't correspond to any file system directory. There's no file system path that would correspond to that location.
Fortunately, file dialogs do speak "shellese", so you can use the CLSID (not to be confused with the GUID KNOWNFOLDERID or the CSIDL) of the shell folder. Sample in C# Winforms, but really, the only important part is the ::CLSID):
var ofd = new OpenFileDialog();
ofd.InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}";
ofd.ShowDialog();
Disclaimer: I couldn't find any relevant documentation for the virtual folder CLSID, or this behaviour of the File dialog. So this is most likely not contractual, and could possibly change in future versions of Windows.
In the explorer, in the search bar copy the address of
This PC
and then select the text
This PC
and paste. Normally we get the
Ce PC ":: {CLSID}"
and then just copy
:: {CLSID}
and paste it wherever we want.
Path should be: C:\Users\UserName\Desktop\Computer.lnk
I script a lot of things to manage the computers in my company. I often need to add shortcuts into the personnal startup folder of users (without a GPO).
Windows 8/8.1 doesn't have a personnal startup folder by default.
Its location is C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\
It is easy to create this folder, but it needs a desktop.ini file into it, with the correct content, for the name to be localised (else it is displayed "Startup" whatever the language).
What is the "official" way to create this folder?
Or what is the official way to add something into it?
I'd prefer a PowerShell or batch command, but whatever reliable mean is okay.
I guess you can do something with the ComObject for this special folder:
$startup = (New-Object -ComObject Shell.Application).NameSpace(0x07)
By the way, if I enter shell:startup in a run box (Win+R) on my Win 8.1 system, it directs me to my personal startup folder (C:\Users\User\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup).
As far as I know, there is no reliable way to do this.
You can get the path with [environment]::getfolderpath("Startup") but the returned string is empty if the folder was neve created. And I don't know any API entry to create it.
So you have to manually create it:
check if the former command return anything (if yes, just create you shortcut)
create yourself the startup folder. Use [environment]::getfolderpath("StartMenu") and add \startup to the path
then create the desktop.ini file and populate it yourself
and update the registry HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders (I didn't check if this is the right place. [environment]::getfolderpath("Startup") must return the right value)
UPDATE: I just found SHGetKnownFolderPath API which allow to create the required folder if needed (with dwFlags). I'm not good at PowerShell, so I don't know how to call this. Maybe Someone can give a better answer.
I'm writing a batch file to map multiple servers to drives on my PC. Using the NET USE command, I have managed to map the drives successfully.
When viewed in Windows Explorer, each drive shows the letter assignment and the server name. I'd like to display a user-friendly plain-English name for each server in the Explorer view also (this is different from the volume label). I can right-click on each drive individually in Explorer and rename but this is a bit long-winded.
Is there any way that names can be assigned to the drives from the command prompt (and therefore from a batch file) rather than right-clicking and renaming in Explorer?
You can do it in Powershell like this:
$rename = new-object -ComObject Shell.Application
$rename.NameSpace("X:\").Self.Name = "DriveLabel"
Just replace the X with the drive-letter on which you want to set the label.
Alternatively if you donĀ“t want to use Powershell you can do the following:
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\##computername#sharename" /f /v "_LabelFromReg" /t REG_SZ /d "DriveLabel"
Of course you have to replace computername with the servername, the sharename with the name of the share and the Drivelabel with your label
The "label" value for a mapped network drive is stored in the registry.
Look into HKEY_USERS\*SID*\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2. There should be a key that represents the mapped network drive. If there is a value called _LabelFromReg you have a custom label and if the value is not there then it uses the default label, such as, Windows (\server\share) (Z:).
You should also be able to use Group Policy Preference, and Network Folders and Shortcuts to get the labels you want.