![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Restarting ActiveSync from PowerShell - quick scripts If you use a handheld Windows computer of some kind, you're probably aware of the occasional issues with managing ActiveSync. It may need to be stopped, started, or restarted, and there is no direct way to do this normally. The following 3 short scripts are all used for this purpose: Stop-ActiveSync, Start-ActiveSync, and Restart-ActiveSync. Note that they are actually trivial scripts, which could be shortened down to 1-liners. The real reason they exist is that they _are_ useful, in a very PowerShellish way. To stop, start, or restart ActiveSync, I don't have to think about the application name; I just need to use the verb and the noun. Since ActiveSync also registers its executable's application path, we can also get a highly reliable automatic find-and-start through [Diagnostics.Process]::Start(). ###<script name="Stop-ActiveSync.ps1"> Param([switch]$PassThru) # Name is fake-wildcarded to suppress errors if # Activesync is not running. $result = Stop-Process -Name [w]cescomm -PassThru if($PassThru){$result;} ###</script> ###<script name="Start-ActiveSync.ps1"> Param([switch]$PassThru) # Find-and-launch automatically using ShellExecute and # registered App Paths. $result = [System.Diagnostics.Process]::Start("WCESCOMM.EXE"); if($PassThru){$result;} ###</script> ###<script name="Restart-ActiveSync.ps1"> Param([switch]$PassThru) # Name is fake-wildcarded to suppress errors if # Activesync is not running. Stop-Process -Name [w]cescomm # Find-and-launch automatically using ShellExecute and # registered App Paths. $result = [System.Diagnostics.Process]::Start("WCESCOMM.EXE"); if($PassThru){$result;} ###</script> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Multithread scripts in Powershell | PowerShell | |||
| run PowerShell scripts from ASP or asp.net | PowerShell | |||
| Powershell scripts not working with Vista powershell | PowerShell | |||
| Can't run powershell scripts | PowerShell | |||
| powershell logon scripts | PowerShell | |||