# System Tray Icon One-Liners

**URL:** <https://community.syncromsp.com/t/system-tray-icon-one-liners/2693>\
**Category:** Staff Picks\
**Tags:** staff-picks\
**Created:** [January 21, 2022, 1:47am UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693 "2022-01-21T01:47:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremy](https://sea3.discourse-cdn.com/syncro/user_avatar/community.syncromsp.com/jeremy/32/167_2.png) [@jeremy](https://community.syncromsp.com/u/jeremy)\
**Post date:** [January 21, 2022, 1:47am UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/1 "2022-01-21T01:47:55Z")

</div>

Is anybody else up to sharing their System Tray Icon-compatible one-liner commands?

I’ll start!

`powershell.exe -command "$exePath = '\\SOMESERVER\FOLDER\Setup.exe'; $instName = 'LOB Application Name'; Add-Type -AssemblyName PresentationFramework; if (Test-Path -Path $exePath) { $res = ([System.Windows.MessageBox]::Show(('Are you ready to install ' + $instName + '? (Note: It may take a moment for the installer to download and launch.)'),'Automated Installer',1,32)); if ($res -eq 'OK') {Start-Process $exePath} } else { [System.Windows.MessageBox]::Show('PC must be connected to work network to install.','Automated Installer - ERROR',0,16) }"`

This command will allow an application to be installed from the Syncro System Tray icon and includes a user confirmation prompt, a test for the file as well as a notice to be patient. It’s easily adapted by changing the two variables at the beginning of the command: exePath and instName. Stick it in the policy’s System Tray as a “Execute a CMD” type and away you go.

---

<div class="post-metadata">

**Author:** ![jeremy](https://sea3.discourse-cdn.com/syncro/user_avatar/community.syncromsp.com/jeremy/32/167_2.png) [@jeremy](https://community.syncromsp.com/u/jeremy)\
**Post date:** [January 21, 2022, 1:49am UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/2 "2022-01-21T01:49:25Z")

</div>

Here’s another that clears the Microsoft Teams cache and seems to fix about 90% of calls about Teams acting up. (Or don’t get any more because users can self-medicate.)

`powershell.exe -command "Get-Process Teams | stop-process -force; Start-Sleep -Milliseconds 1500; Remove-Item -path $env:APPDATA'\Microsoft\teams\Cache\*'; Remove-Item -path $env:APPDATA'\Microsoft\teams\blob_storage\*'; Remove-Item -path $env:APPDATA'\Microsoft\teams\databases\*'; Remove-Item -path $env:APPDATA'\Microsoft\teams\GPUcache\*'; Remove-Item -path $env:APPDATA'\Microsoft\teams\IndexedDB\*' -recurse; Remove-Item -path $env:APPDATA'\Microsoft\teams\Local Storage\*' -recurse; Remove-Item -path $env:APPDATA'\Microsoft\teams\tmp\*'; Start-Sleep -Milliseconds 1500; Start-Process -FilePath $env:LOCALAPPDATA'\Microsoft\Teams\Update.exe' -ArgumentList '-processStart Teams.exe'"`

---

<div class="post-metadata">

**Author:** ![Jimmie](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Jimmie](https://community.syncromsp.com/u/Jimmie)\
**Post date:** [January 21, 2022, 6:31am UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/3 "2022-01-21T06:31:29Z")

</div>

Clears printer queue, I may have grabbed this from somewhere.

```auto
powershell "Stop-Service spooler -Force; $files = Get-ChildItem -Path $env:SystemRoot\System32\spool\PRINTERS -Force; $files | Remove-Item -Force; Start-Service spooler;[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms');[System.Windows.Forms.Messagebox]::Show('Print queue cleared!')"
```

---

<div class="post-metadata">

**Author:** ![Jimmie](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Jimmie](https://community.syncromsp.com/u/Jimmie)\
**Post date:** [January 21, 2022, 6:33am UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/4 "2022-01-21T06:33:03Z")

</div>

Simple ones

 ![image](https://us1.discourse-cdn.com/syncro/original/1X/92e91e89e1c1e9511b77a45a8102004dda3b7047.png)

---

<div class="post-metadata">

**Author:** ![jeremy](https://sea3.discourse-cdn.com/syncro/user_avatar/community.syncromsp.com/jeremy/32/167_2.png) [@jeremy](https://community.syncromsp.com/u/jeremy)\
**Post date:** [January 21, 2022, 7:07am UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/5 "2022-01-21T07:07:49Z")

</div>

> [@Jimmie](#):
>
> `powershell "Stop-Service spooler -Force; $files = Get-ChildItem -Path $env:SystemRoot\System32\spool\PRINTERS -Force; $files | Remove-Item -Force; Start-Service spooler;[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms');[System.Windows.Forms.Messagebox]::Show('Print queue cleared!')"`

A very nice one. I can see use for that for sure!

---

<div class="post-metadata">

**Author:** ![anon75442803](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@anon75442803](https://community.syncromsp.com/u/anon75442803)\
**Post date:** [January 21, 2022, 8:37pm UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/6 "2022-01-21T20:37:44Z")

</div>

Neat! How have you done to add the little icon next to the title? I mean I guess it’s a copy/paste but, is there somewhere we can see all icon available?

Thanks!

---

<div class="post-metadata">

**Author:** ![Jimmie](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Jimmie](https://community.syncromsp.com/u/Jimmie)\
**Post date:** [January 21, 2022, 8:40pm UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/7 "2022-01-21T20:40:40Z")

</div>

Win + period will bring up the emoji menu and just copy and paste. Not Syncro specific, just uses what’s available in Windows.

---

<div class="post-metadata">

**Author:** ![jeremy](https://sea3.discourse-cdn.com/syncro/user_avatar/community.syncromsp.com/jeremy/32/167_2.png) [@jeremy](https://community.syncromsp.com/u/jeremy)\
**Post date:** [January 21, 2022, 9:03pm UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/8 "2022-01-21T21:03:35Z")

</div>

I got the values from this page: [How to show a message box with windows powershell](https://michlstechblog.info/blog/powershell-show-a-messagebox/)

I swapped-in the Integers to keep things short.

---

<div class="post-metadata">

**Author:** ![isaacg](https://sea3.discourse-cdn.com/syncro/user_avatar/community.syncromsp.com/isaacg/32/658_2.png) [@isaacg](https://community.syncromsp.com/u/isaacg)\
**Post date:** [January 21, 2022, 11:40pm UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/9 "2022-01-21T23:40:35Z")

</div>

Force Close All Browsers & prevent recovery button from working

```auto
powershell "Stop-Process -processname chrome,iexplore,firefox,msedge;Start-Sleep -Second 3;Remove-Item "$ENV:HOMEDRIVE\Users\*\AppData\Local\Google\Chrome\Userda~1\Default\Sessions" -Recurse -Force;Remove-Item "$ENV:HOMEDRIVE\Users\*\AppData\Local\Microsoft\Edge\Userda~1\Default\Sessions" -Recurse -Force;Remove-Item "$ENV:HOMEDRIVE\Users\*\AppData\Roaming\Mozilla\Firefox\Profiles\*\sessionstore-backups\recovery.jsonlz4" -Force;[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms');[System.Windows.Forms.Messagebox]::Show('Browsers closed!')"
```

---

<div class="post-metadata">

**Author:** ![jeremy](https://sea3.discourse-cdn.com/syncro/user_avatar/community.syncromsp.com/jeremy/32/167_2.png) [@jeremy](https://community.syncromsp.com/u/jeremy)\
**Post date:** [January 22, 2022, 6:14am UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/10 "2022-01-22T06:14:02Z")

</div>

> [@isaacg](#):
>
> Force Close All Browsers & Prevent Recovery
> 
> ```auto
> 
> ```

Okay, this is slick! What a great option for those people with the “RED BOX OF BEEP AND WARNING” problems… (What web sites do they browse anyway?)

Quick question… Do the embedded double-quotes create any issues as a “one-liner” or would they be better swapped out with single-quotes?

---

<div class="post-metadata">

**Author:** ![isaacg](https://sea3.discourse-cdn.com/syncro/user_avatar/community.syncromsp.com/isaacg/32/658_2.png) [@isaacg](https://community.syncromsp.com/u/isaacg)\
**Post date:** [January 22, 2022, 6:48am UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/11 "2022-01-22T06:48:38Z")

</div>

Yes, that’s exactly the intention. IME it’s usually Facebook right before in their browser history so I’m guess advertisements that either manage to redirect or they actually clicked on.

The double-quotes are required if you want to use variables within them (ENV in this case) but otherwise yes they could be replaced by singles. Believe me there were a few iterations to get it to work 😃 Had to use 8.3 folder name to get avoid the spaces causing an issue also.

---

<div class="post-metadata">

**Author:** ![Jimmie](https://avatars.discourse-cdn.com/v4/letter/j/e95f7d/32.png) [@Jimmie](https://community.syncromsp.com/u/Jimmie)\
**Post date:** [January 22, 2022, 9:37pm UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/12 "2022-01-22T21:37:36Z")

</div>

Or recipe sites around any holiday…

---

<div class="post-metadata">

**Author:** ![jeff](https://sea3.discourse-cdn.com/syncro/user_avatar/community.syncromsp.com/jeff/32/176_2.png) [@jeff](https://community.syncromsp.com/u/jeff)\
**Post date:** [January 24, 2022, 8:37pm UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/13 "2022-01-24T20:37:33Z")

</div>

It would be really nice to run a script from the library from the tray. Then the script runs would be logged and have access to Syncro Customer and Asset variables.

Some nice scripts in here so far. Please keep them coming.

---

<div class="post-metadata">

**Author:** ![jeremy](https://sea3.discourse-cdn.com/syncro/user_avatar/community.syncromsp.com/jeremy/32/167_2.png) [@jeremy](https://community.syncromsp.com/u/jeremy)\
**Post date:** [January 24, 2022, 9:50pm UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/14 "2022-01-24T21:50:04Z")

</div>

> [@jeff](#):
>
> Then the script runs would be logged and have access to Syncro Customer and Asset variables.

For sure. I have a little side-project (Shhhhh. don’t tell Syncro!) to load their modules and try to back-fill all of the connection details but so far am blocked by security… (Good thing… I guess.) 🤪

---

<div class="post-metadata">

**Author:** ![isaacg](https://sea3.discourse-cdn.com/syncro/user_avatar/community.syncromsp.com/isaacg/32/658_2.png) [@isaacg](https://community.syncromsp.com/u/isaacg)\
**Post date:** [January 24, 2022, 11:59pm UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/15 "2022-01-24T23:59:33Z")

</div>

Yea, I’ve been asking for this for years. They don’t want to do it for some reason.

---

<div class="post-metadata">

**Author:** ![garyh](https://sea3.discourse-cdn.com/syncro/user_avatar/community.syncromsp.com/garyh/32/192_2.png) [@garyh](https://community.syncromsp.com/u/garyh)\
**Post date:** [January 25, 2022, 12:54pm UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/16 "2022-01-25T12:54:43Z")

</div>

These are handy but it would be a LOT better to just be able to present select scripts the user can run.

These scripts are easier to maintain and you have one location for maintaining them rather than having some duplication. The scripts are also more powerful with variables and calls to Syncro functions like logging and alerts…

---

<div class="post-metadata">

**Author:** ![Alexandra](https://sea3.discourse-cdn.com/syncro/user_avatar/community.syncromsp.com/alexandra/32/2589_2.png) [@Alexandra](https://community.syncromsp.com/u/Alexandra)\
**Post date:** [January 25, 2022, 11:50pm UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/17 "2022-01-25T23:50:39Z")

</div>

They can run scripts from the Customer Portal. It’s not as easily accessible as the tray icon but it is an option. The downside is the script ends up being available on every customer portal (unless you restrict them from scripts via permissions.)

---

<div class="post-metadata">

**Author:** ![jeremy](https://sea3.discourse-cdn.com/syncro/user_avatar/community.syncromsp.com/jeremy/32/167_2.png) [@jeremy](https://community.syncromsp.com/u/jeremy)\
**Post date:** [January 26, 2022, 1:03am UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/18 "2022-01-26T01:03:02Z")

</div>

> [@garyh](#):
>
> These scripts are easier to maintain and you have one location for maintaining them rather than having some duplication. The scripts are also more powerful with variables and calls to Syncro functions like logging and alerts…

I wonder if there are security implications with this that would make it unsafe? #thinkingoutloud

---

<div class="post-metadata">

**Author:** ![anon50555151](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@anon50555151](https://community.syncromsp.com/u/anon50555151)\
**Post date:** [January 26, 2022, 1:58am UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/19 "2022-01-26T01:58:03Z")

</div>

We understand that we can have scripts for all portal users, but that’s not feasible when you have many clients that each have scripts that would work great for them, and totally not at all for others.

Essentially, add a new try option for Scripts, Set the option name (same as we do with CMD) then have a dropdown of scripts (as we do on an asset queue), then add the selected script to the asset’s script queue, maybe with an option for a toaster notification after that says “action requested” or whatever.

---

<div class="post-metadata">

**Author:** ![drew](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@drew](https://community.syncromsp.com/u/drew)\
**Post date:** [January 26, 2022, 3:48am UTC](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693/20 "2022-01-26T03:48:10Z")

</div>

Take any powershell script. It doesn’t have to be a 1-liner. Then surround it with the following code:

```auto
$code = {
	#Put your code here
	rundll32.exe user32.dll,LockWorkStation
}
[convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($code))

```

Then it will output a 64-digit encoded string.

Use the one-liner string as follows (This string is a popup that shows your hostname):

```auto
powershell -EncodedCommand DQAKAAkAJAB3AHMAaABlAGwAbAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAALQBDAG8AbQBPAGIAagBlAGMAdAAgAFcAcwBjAHIAaQBwAHQALgBTAGgAZQBsAGwADQAKAAkAJAB3AHMAaABlAGwAbAAuAFAAbwBwAHUAcAAoACIAWQBvAHUAcgAgAGMAbwBtAHAAdQB0AGUAcgAgAG4AYQBtAGUAIABpAHMAOgAgACIAIAArACAAIAAkAGUAbgB2ADoAYwBvAG0AcAB1AHQAZQByAG4AYQBtAGUALAAwACwAIgBDAG8AbQBwAHUAdABlAHIAIABOAGEAbQBlACIALAAwAHgAMAApAA0ACgA=

```

You have successfully converted a full script to a 1-liner for the tray icon.

[Next page](https://community.syncromsp.com/t/system-tray-icon-one-liners/2693.md?page=2)
