PowerShell script to cut paste the folder content in Windows 2012 R2 - powershell-2.0

How can I delete all the contents of one folder (present in C drive) and copy it in another new folder present in different drive (say F).
Example:
C drive→window→ users →temp (make it empty).
move all the content in
F drive→ Temp_backup

You can use:
Move-Item -Path "from" -Destination "to"
like described here:
https://social.technet.microsoft.com/Forums/windows/en-US/848b28c2-1ec2-405a-aebd-48bf79a9594f/how-to-move-files-from-one-location-to-another-location-using-powershell?forum=winserverpowershell

Related

Missing file from computer "opencv_core249d.dll". Resolution with eclipse Version: Mars.2 Release (4.5.2).Closed

I am facing a problem with my visual studio 2013 ultimate. i would run a open cv project but iam getting a error message like this " opencv_core249d.lib" missing from ur computer. re install the program.
Solution : It works with eclipse Version: Mars.2 Release (4.5.2).
This is a missing .dll issue, not a missing lib issue. It usually occurs when the Environment Variables have not been correctly set in your Windows environment. To take care of this problem, there are 2 methods:
1) edit Environment variables
Go to ‘My Computer’ , right-click and select ‘Properties’. A window called ‘System’ will open, containing the Windows Logo on the right. On the left margin of this window, you will find a link named ‘Advance system
settings’. Click on it.
Another window called ’System Properties’ will open. On the bottom right corner of this window, click on the button named ’Environment Variables..’.
Under the ‘System variables’ column, look for a variable by the name ‘Path’. - Select ‘Path’ and click ‘Edit..’
In the ‘variable value’ row, add the following address:
\path to\opencv\build\x86\vc12\bin;
Please Note- Ensure that the new address added by you, and the address previously written in the ‘variable value’ row, are separated by a ; DO NOT REMOVE the previous environment variable addresses.
2) Manually copy the .dll files.
In case the first approach does not work for you, go to:
\path to\opencv\build\x86\vc12\bin;
You'll find all the dll files that you're looking for. Copy those files to directory where your source code is located.

Using command line to copy txt of many files and create new txt with all text

So as an early task at a new junior developer position I was asked to go through and update thousands of old parameter data types in various stored procs. I did all the updates and loaded them to the team server and now have to push them into our SQL server so they will compile.
Last night my boss eluded to how I could pull the modified procs into a directory, then use command line to copy all text and create a new txt file that could be opened in SQL to run a mass update basically in batch mode per database.
I have almost no command line experience, can someone give me a quick overview.
My Pseudocode:
Open command line window in my UpdatedProcs folder, copy text from all files in same directory, create new text file containing all of the text (name of new file doesn't matter). Then open in SQL, look for errors one last time, and finally run.
This seems simple but I know nothing about command line.
Thanks for your help.
Use a for /f loop. You don't even need to copy the files from the subdirectory first. This appends all of the text files in the Temp subfolder (C:\Test\Temp) into a file named summary.log in the current folder (C:\Test):
c:\Test>for /f "tokens=*" %a in ("dir temp\*.txt") do type %a >> .\summary.log
summary.log now contains all of the content of the text files in a single file. You can open it with Notepad or any other text editor.
To run from a batch file, simply change the %a to %%a in both places.
c:\Test>copy con mergefiles.bat
for /f "tokens=*" %%a in ("dir temp\*.txt") do type %%a >> .\summary.log
F6 or Ctrl+Z
c:\Temp>mergefiles
Enter
c:\Temp>notepad summary.log
Enter

How add context menu item to Windows Explorer for folders [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have found out how to add right-click context menu items to files on Windows Explorer, by adding keys to the registry. I.e. I can right-click on a file in Explorer and run a custom app against that file.
I would like to do the same for a folder and have not found a way to do that (yet). I see articles on creating/writing custom context menu handlers, but I would rather not go there.
I have found an article here on how to add cascading context menu items to the Desktop and to the "Computer" in Explorer, but this does not work for any folder.
I would like to be able to add my custom app to the context menu and have it work on both files and folders. Is there a way to do this without writing a context menu handler?
I found the solution in the below article, which describes how to do this via the registry for files, as well as for folders:
How to Add Any Application Shortcut to Windows Explorer’s Context Menu
The following two articles provided additional info and options:
Ultimate Tutorial to Customize Desktop Context Menu in Windows Vista, 7 and 8
Add Cascading Menus for Your Favorite Programs in Windows 7 Desktop and My Computer Context Menus
In the registration editor (regedit.exe) find:
Context menu for right click on folders in left panel of Windows Explorer or on background of a directory in right panel:
HKEY_CLASSES_ROOT\Directory\Background\shell if you are administrator
HKEY_CURRENT_USER\Software\Classes\directory\Background\shell if you are a normal user
Context menu for right click on folders in right panel of Windows Explorer:
HKEY_CLASSES_ROOT\Directory\shell if you are administrator
HKEY_CURRENT_USER\Software\Classes\directory\shell if you are a normal user
Context menu for any file:
HKEY_CLASSES_ROOT\*\shell if you are administrator
HKEY_CURRENT_USER\Software\Classes\*\shell if you are a normal user
In all cases:
add a new key under shell, naming it as you want to name the
context menu item
add a new key inside this key, named command (mandatory name)
edit the default property in command to
myprogrampath\path\path\executable.exe "%1" to pass the file path and
name of the selected file to your custom program (for .../Directory/Background and .../directory/Background cases use %V instead of %1)
More customization:
Add icon: add a string value named icon for key created at step 1 with value matching an icon resource path. You can also provide an integer arguments to specify which icon to use. Example: %SystemRoot%\System32\shell32.dll,3
Display only on shift-click: add an empty string value named Extended for key created at step 1
Customize menu entry label: change the value of default value for key created at step 1
Change menu entry location: add a string value named Position with one of: Top, Bottom
Found a cleaner, easier and faster solution: create a text file, fill it with these contents, update it to your needs, save with .reg suffix and launch it (it does not need administrator priviliges because it accesses user-part of the registry):
Windows Registry Editor Version 5.00
; Setup context menu item for click on right panel:
[HKEY_CURRENT_USER\Software\Classes\directory\Background\shell\MenuItemNameBackground\command]
#="C:\\yourpath\\executable.exe \"%1\""
; Optional: specify an icon for the item:
; HKEY_CURRENT_USER\Software\Classes\directory\Background\shell\MenuItemNameBackground]
;"icon"="C:\\yourpath\\appicon.ico"
; Optional: specify a position in the menu
; HKEY_CURRENT_USER\Software\Classes\directory\Background\shell\MenuItemNameBackground]
;"position"="Bottom"
; -------------------------------------------------------------------------------------
; Setup context menu item for click on folders tree item:
[HKEY_CURRENT_USER\Software\Classes\directory\shell\MenuItemNamePanel\command]
#="C:\\yourpath\\executable.exe \"%1\""
; Optional: specify an icon for the item:
; [HKEY_CURRENT_USER\Software\Classes\directory\shell\MenuItemNamePanel]
;"icon"="C:\\yourpath\\appicon.ico"
; Optional: specify a position in the menu
; [HKEY_CURRENT_USER\Software\Classes\directory\shell\MenuItemNamePanel]
;"position"="Top"
In this way you can also have a backup of your configuration: just save the .reg file in a safe place. If you manually edit the registry after launching the file, right-click and slect "export".
Beware of double backspaces in path: \\
I went back and also answered this in another topic since there doesn't appear to be much on this question specifically.
I found the simplest way was to add a String Value to the key called "AppliesTo" and set its value to "under:{path}"
In my example, I want it to only look in the T Drive, so my String value is "AppliesTo":"under:T:".
In C#, this is easily accomplished with the following:
RegistryKey _key = Registry.ClassesRoot.OpenSubKey("Folder\\Shell", true);
RegistryKey newkey = _key.CreateSubKey("My Menu Item");
newkey.SetValue("AppliesTo", "under:T:");
RegistryKey subNewkey = newkey.CreateSubKey("Command");
subNewkey.SetValue("", "C:\\yourApplication.exe");
subNewkey.Close();
newkey.Close();
_key.Close();
The only good solution I found a really working is : https://superuser.com/questions/1097054/shell-context-menu-registry-extension-doesnt-work-when-default-program-is-other
Add keys in HKEY_CLASSES_ROOT\SystemFileAssociations\your.extension\shell\command
Modify the last key with the command you wanna do.
For my purpose it was :
"C:\Program Files (x86)\GPSBabel\gpsbabel.exe" -r -i gpx -f "%1" -x simplify,count=1000 -o gpx -F "%1.gpx"
If I export the it I get a .reg :
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SystemFileAssociations\.gpx\shell\Simplify gpx\command]
#="\"C:\\Program Files (x86)\\GPSBabel\\gpsbabel.exe\" -r -i gpx -f \"%1\" -x simplify,count=1000 -o gpx -F \"%1.gpx\""
Open command prompt [run as administrator] and execute this command
reg add "HKEY_CLASSES_ROOT\Directory\shell\Refi2\command" /d "powershell.exe -noexit -command Set-Location -literalPath '%V'"
-d : value to execute[app name exe].
-v : creates a new subkey inside the command key.
-f : to forcefully override the key if already exists.
powershell.exe -noexit -command Set-Location -literalPath '%V' instead of this you can specify path of your exe.
For more details about more features run:-
reg add /?

I need to create a script that will check a files size, warn user, move files and link to new location

We are trying to keep as little end-user data on our companies thin-clients, so I need to create a script that will run when a file is saved locally. I'm completely new to power shell so I do apologize for the lack of knowledge.
Check file size
if (file size is equal or greater than "x"mb) output a warning "file is larger than allowed, moving file to you cloud drive (usually the K: drive)
I'd imaging I'd use Move-Item -destination "k:\My Documents\"
create a link or shortcut to the new file location.
I'm sure I will need more data at some point. I will take any/all the help I can get.
$Directory = Get-ChildItem "D:\Download" #Directory I care about
$SizeLimit = "200000" #Size limit in bytes
foreach ($File in $Directory) {
if ($File.Length -ge $SizeLimit) {
# Notify the user with a pop-up
# the coding for said popup
# Move the file
Move-Item $File.FullName K:\
mklink.exe K:\$File.Name $File.FullName

Is there a macro to toggle to a specific folder in Outlook?

I often (using the mouse) switch between 1 of 3 favorite folders under my inbox. I am looking to write a macro to switch between these folders. I see lots of emails on code to move specific emails to folders but is there a way to move focus on a specific folder?
Sure, you could just change the CurrentFolder value to one of your Inbox folders. Here's an example of changing views from wherever I am to a folder named "T1" which is under the Inbox.
Sub ChangeViewtoFolderT1()
Dim ns As Outlook.NameSpace
Set ns = Application.GetNamespace("MAPI")
Dim Exp As Outlook.Explorer
Set Exp = Application.ActiveExplorer
Dim myInbox As Folder
Set myInbox = ns.GetDefaultFolder(olFolderInbox)
Dim folder1 As Folder
Set folder1 = myInbox.Folders.Item("T1")
Set Exp.CurrentFolder = folder1
End Sub
See http://msdn.microsoft.com/en-us/library/bb220039.aspx for more details.

Resources