Outlook Reset Navigation Pane - powershell

I have been trying to Automate a PowerShell script for Outlook Navigation Pane Reset But I don't Know exactly what it changes.
I changed the Navigation Options, Views, Folder Pane, reading Pane Settings manually and then I tried OUTLOOK.EXE \resetnavepane from Run, "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE" /resetnavpane From Command Prompt and & "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE" /resetnavpane From Powershell but I see no change in Outlook it just restarts outlook in a new window with the same settings I changed manually.

Outlook keeps its settings in the windows registry keys. You must search for settings in the windows registry instead of relying on the command line arguments. For example, you may find the following thread helpful - navigation bar moved to left.

Related

Powershell -command text not appearing

Windows 10, Powershell -v 5.1
I have tried to restore powershell to defaults, both normally and as admin. I have changed/turned off high contrast settings, deleted console files for powershell in Regedit, as well as tried to restore defaults from command line scripts.
Have tried restarting after applying all of this, but much of my output text is invisible, as well as commands with only one "-" dash, but commands with "--" appear.
See in pics below
no - identifiers
Invisible "-i"
Reappearing "--i"
Invisible Surge Data
It sounds like you've persistently modified the console-window colors in a manner that renders certain syntactic elements invisible.
You can either modify your console-window settings interactively - which may be nontrivial - or you can try to restore the original colors by recreating
the shortcut files that start your console windows:
Shortcut files (*.lnk files) contain their own console-window settings, which are independent of the defaults defined for console windows in the [HKEY_CURRENT_USER\Console] registry key and its subkeys named for specific executable names / window titles.
Therefore, even if you remove [HKEY_CURRENT_USER\Console] or specific subkeys, starting a program via a shortcut file will still apply the settings stored inside that shortcut file.
To bypass the shortcut-file settings ad hoc, you can start your program directly, using the Run dialog:
Press WinKey+R and enter powershell (for Windows PowerShell) or pwsh (for PowerShell Core), which applies only the registry defaults, if any.
However, to solve that problem persistently, you must modify or recreate the shortcut
file(s) you use to start your program:
To modify the shortcut:
Invoke your program via the shortcut,
then open the system menu (click on the icon in the top-left corner of the window),
select Properties
and modify the properties, notably the colors via the Colors tab.
To recreate the shortcut (instructions based on Windows 10):
In the Start Menu:
Right-click on the application of interest, then select More > Open file location.
In the taskbar:
Right-click on the application of interest, then right-click the application name and select Properties.
Activate the General tab
Copy the value of the Location: field - the folder in which the *.lnk file is located - to the clipboard.
Open File Explorer and paste the location into its address bar, which should open the folder in which the *.lnk file of interest is located.
Once you've located the *.lnk file of interest:
Make a note of:
its exact filename (typically: Windows PowerShell)
its target command line, by right-clicking the file, selecting Properties, selecting the Shortcut tab and copying the value of the Target: field.
its startup directory, as noted in the Start in: field.
Delete the *.lnk file.
Recreate it with the previously noted target command line:
Right-click in an empty part of the File Explorer window and select New > Shortcut
Paste the command line and click Next.
Specify the previous filename, and click on Finish.
Right-click on the new file, select Properties, and paste the startup directory into field Start in:, then click OK.
Drag the new *.lnk file into the Start Menu and/or taskbar, as needed.

Execute Powershell from File Explorer after installing VS Code

VS Code is trying to position itself as a new way to work with Powershell, and one of the changes it makes upon installation is to replace the File Explorer context menu option "Run with PowerShell" on .ps1 files with a new "Open with Code" option instead.
Is there a way to remove the "Open with Code" option and replace it with the old "Run with PowerShell" option? I assume this would involve the registry somehow but I don't know enough about the registry in general to do it safely.
Try this:
Save the following contents into a file "EnablePowerShellRightClickRun.reg", then right click - merge.
Then it doesn't matter which application you associate .ps1 files with - you still have "Run with Powershell" as a right click option.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1]
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\shell]
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\shell\RunPS]
#="Run with Powershell"
[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\shell\RunPS\command]
#="\"C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe\" -File \"%1\""
VS Code is not really positioning itself as the new way to work with PowerShell, it will be the only "built-in" way with Windows to work with it because the PowerShell ISE is being depreciated.
Either way, VS Code did not cause that option to disappear. I have VS Code and the PS extension on my machine and still have access to both options:
When you install VS Code you are prompted to add the right-click menu options, so if you opt'ed into those then it is not what removed your "Run with PowerShell" option.
If you want to remove those right-click options then you would have to uninstall VS Code and install it again, making sure those options are not checked.
To restore your menu option to Run with PowerShell verify you have not changed the default program for PowerShell files (e.g. ps1). If you set that to VS Code it will cause the option to be removed from your right-click menu. You can restore it by changing the default program in Windows back to Notepad.

Configure Autohotkey to edit scripts with Notepad++

I have my default editor for .ahk files set to Notepad++ Portable on my work laptop, but selecting Edit This Script opens files in the standard Windows Notepad.
A post on the AHK forums suggests editing the registry, but I don't see any entries under HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command.
How can I configure AutoHotkey to edit scripts with Notepad++?
For whatever reason, the Registry entry doesn't exist by default, but it is recognized by the application once created.
Navigate to HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell in RegEdit.
Right-click the Shell folder, select New > Key and name this Edit.
Right-click the Edit folder, select New > Key and name this Command.
Double click the (Default) string entry in Command.
Paste in "C:\Program Files\Notepad++\Notepad++.exe" "%1" to this window.
Reload AutoHotkey for the changes to take effect.
Note: I don't use Notepad++, but this works for VS Code on my system, and will for N++ as long as the directory information for the executable is correct.
The corresponding .reg file looks like this:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command]
#="\"C:\\Program Files\\Notepad++\\notepad++.exe\" \"%1\""
The registry entry in item 5 of the previous answer did not work. I don't even know what the extra %* at the end means, so I simplified it to:
"C:\Program Files\Notepad++\Notepad++.exe" "%1"
For AHK version 2, changing the registry didn't work for me (I tried both Computer\HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command and Computer\HKEY_CLASSES_ROOT\.ahk\Shell\Edit\Command), but this did it for me. It adds two menu items to the AHK tray menu after a divider:
EditWithNotepadPlusPlus(*)
{
Run "C:\Program Files\Notepad++\notepad++.exe " A_ScriptFullPath
}
EditWithVsCode(*)
{
Run "C:\Program Files\Microsoft VS Code\Code.exe " A_ScriptFullPath
}
A_TrayMenu.Add()
A_TrayMenu.Add("Edit with VS Code", EditWithVsCode)
A_TrayMenu.Add("Edit with Notepad++", EditWithNotepadPlusPlus)
return
If you are like me and you are hesitant to modify the registry, there is a way to do this using AutoHotKey code.
This is a method I use to edit the script with a different editor. Although I am using Visual Studio Code, the method is the same no matter which editor you want to use. One caveat though: we can't change the existing "Edit This Script" menu item, since that is considered one of the standard menu items and can't be modified. Instead I am adding a new menu item at the top of the menu that says "Edit With Notepad++".
EditWithNotepadPlusPlus()
{
Run "C:\Program Files (x86)\Notepad++\notepad++.exe" "%A_ScriptFullPath%"
}
; Remove the standard menu items temporarily
Menu, Tray, NoStandard
; Add our custom menu item labeled "Edit With Notepad++"
; and calls the function above
Menu, Tray, Add, Edit With Notepad++, EditWithNotepadPlusPlus
; Add a separator
Menu, Tray, Add
; Put the standard menu items back, under our custom menu item
Menu, Tray, Standard
Note: If you're wondering, the lines Menu, Tray, NoStandard and Menu, Tray, Standard are not required. The reason I use those lines is because by default, Menu, MenuName, Add adds menu items to the bottom of the menu. For aesthetic and practical reasons, I prefer Exit to be the last menu item. So Menu, Tray, NoStandard and Menu, Tray, Standard will cause our menu item to appear at the top.
One added benefit of this method is that if you transfer your scripts to a new computer, it should still work (provided you have Notepad++ installed on the other computer). If you edit the registry, you have to remember to edit the registry again.
Using AHK v1.1.3.02 on Win10 with string
"C:\Program Files\TextPad 8\TextPad.exe" "%1"
worked well.
The registry change mentioned in other answers for me worked, but you may want to further add the following flags:
C:\Program Files (x86)\Notepad++\notepad++.exe %1 -multiInst -nosession
These flags will stop Notepad++ from recognizing this window as part of your overall session, so it won't overwrite your normal session history or anything. I don't remember where I first found these solutions but I'm switching computers atm and found them in my registry and noticed they weren't mentioned anywhere in this thread.
Was not working for me, i fixed it by first using the suggestion by R River
C:\Program Files (x86)\Notepad++\notepad++.exe %1 -multiInst -nosession
But this would create a new session each time, so i tried removing the end parameters and it now works.
C:\Program Files (x86)\Notepad++\notepad++.exe %1
Simplest way I've found is to:
Right click the .ahk file
Select "Open with" -> "Choose another app"
Check "Always use this app to open .ahk files"
Then select NotePad++ from the list
If it's not listed select "More Apps" and scroll down to NotePad++. (Mind you this example is Windows 10 specific, but previous versions are very similar.)
Editing the registry is great, don't get me wrong, but it takes longer. It's kinda like using a truck to swat a fly! Anyways, hope this works for you. I use it all the time to set the file associations I want.

Opening outlook in safe mode via powershell

How do you open Outlook in safe mode by default? Is there a powershell/cmd script I can use?
I'm assisting a user who's Outlook crashes after every 2nd email. The user doesn't experience these issues while opening Outlook in safe mode. User is currently able to access outlook in safe mode by holding down the ctrl key and double-clicking the Outlook icon. Looking for an easier solution for user such as a desktop icon.
Copy\Paste from here:
- If you are using Windows Vista or Windows 7, then there is a Search box in the Start Menu. Here type outlook.exe /safe
- In Windows 8, the search box will automatically show when you start typing. So simply open the Start Screen and type outlook.exe /safe
- In Windows 10, there is a search box on the Taskbar by default but if you have set to hide this, it will automatically show when you start typing after opening the Start Menu as well. Here type outlook.exe /safe
- You can also create a new shortcut to outlook.exe and add the /safe switch;
First, determine the location of outlook.exe on your system. In general you’ll find it under;
32-bit version of Windows
C:\Program Files\Microsoft Office\Office
64-bit version of Windows
C:\Program Files (x86)\Microsoft Office\Office
If you can’t find it, do a search for outlook.exe or use OutlookTools (free) instead.
Once you’ve found outlook.exe we create a shortcut to it with the /safe switch to prevent Outlook from opening an extra window each time you click the shortcut or use your keyboard shortcut.
Right click on an empty space on your Desktop and choose New-> Shortcut
Type the path to outlook.exe between quotes or browse to its location via the Browse… button
Type a space behind that and /safe
The entire line should now look like this (example is for a 32-bit version of Outlook 2010 on a 64-bit version of Windows);
"C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE" /safe
Click Next
Name your shortcut for instance: Outlook Safe Mode
Click Finish

I have made an installer for MyProgram but the uninstall shortcut that it creates leaves behind empty folders

I have created an installer for MyProgram using the Visual Studio Installer (Visual Studio Setup Project). It is called "MyProgram Setup.msi". It installs the program fine and if it is uninstalled using the Add/Remove Programs control panel then everything gets removed as it should.
The problem is that I want to add a shortcut to the "User's Programs Menu" under the program shortcut called "Uninstall MyProgram". I have tried doing this in 3 different ways and in all 3 ways if MyProgram is uninstalled using that shortcut, the uninstall will leave behind 2 empty folders ("...Program Files\MyCompany\" and "...Program Files\MyCompany\MyProgram\").
Here are the 3 ways that I have tried to make an uninstaller shortcut:
1) A shortcut to a batch or script file
Uninstall MyProgram.bat:
#ECHO OFF
msiexec /uninstall {MyGUID}
Uninstall MyProgram.vbs:
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("START /B msiexec /uninstall {MyGUID}")
Set objShell = Nothing
2) Editing the MSI file using Orca.exe
I found out how to do this using this guide: http://www.codeproject.com/KB/install/MSIShortcuts.aspx
I added the Shortcut Entry to the Shortcut table. Uninstalling worked but it still left behind the 2 empty folders when using this shortcut.
3) From code within MyProgram.exe
I modified MyProgram.exe to take a "/uninstall" command line parameter to run "msiexec.exe /uninstall {MyGUID}" and exit itself. Similar to this solution: http://www.codeproject.com/KB/install/DeployUninstall.aspx
None of these attempts created a shortcut which can uninstall the program as well as the program's base folders. I don't want to switch to some other installer product such as Inno Setup, NSIS, or WiX.
If for whatever reason manually running msiexec /x {MyGUID} doesn't remove all folders, then it's an issue with your setup or something you're doing in your application.
For more information about creating an uninstall shortcut with WiX, check out this blog post which goes into quite a bit of detail. Based on the information shown in the blog post you should be able to work out how to stick with your existing technology and use some variation on the (2) method you mention.
It seems that this is a bug in the Visual Studio Installer. I have decided to use WiX instead. It is able to create the uninstall shortcut with correct functionality.