Forum Discussion
Command Line args to goto channels directly?
Hello! So in our custom tools we try to give quick access to the responsible people. Its already possible to chat with co-workers in Teams with a click. In the background: getting the executable from `LOCALAPPDATA` + \Microsoft\Teams\current\Teams.exe works pretty reliable then just call this with `sip:name@company.com` and Voilà we chat!
Now I'd like users to be able to goto public channels with a click. I can get a link with Get link to channel. But running Teams.exe with this link does nothing! Just opens up the Teams main window with whatever was just open. No change.
I CAN just "run" this link with the webbrowser but then the user has to accept to always open the according links with MS Teams which is do-able but rather crude for some simpler users. And STILL one would have a useless web page open. Maybe the user doesn't even have a browser open... However it would be quite great to just go like:
Teams.exe %channel_link%
What command line switch do I need?
Is there a list of command line switches? like the sip: one?
I'd love to do sth like Teams.exe /? or -help ...
btw: Currently there is a big fat ERROR msg when you do Teams on the console window:
Error while parsing hooks JSON. Error: "ENOENT: no such file or directory, open 'C:\\Users\\techarteric\\AppData\\Roaming\\Microsoft\\Teams\\hooks.json'"
(node:17212) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Alright I got it! the command line switch to do this is msteams:
I just took such a channel link, quit Teams from the sys tray, The browser opens it with the command I'm looking for and then it will still be on the command line args of the running Teams.exe! 🤘
What I noticed is that the link is UBER long! In my case 345 characters.
The app actually complains about a LOT of stuff in there:
'tenantId' is not recognized as an internal or external command, operable program or batch file. 'deeplinkId' is not recognized as an internal or external command, operable program or batch file. 'launchAgent' is not recognized as an internal or external command, operable program or batch file. The system cannot find the file specified. 'directDl' is not recognized as an internal or external command, operable program or batch file. 'msLaunch' is not recognized as an internal or external command, operable program or batch file. 'enableMobilePage' is not recognized as an internal or external command, operable program or batch file. 'fqdn' is not recognized as an internal or external command, operable program or batch file.
So these can ALL be stripped off the link already and even groupId and type aren't needed!
One can even shorten off the name up to the slash like:
msteams:/l/channel/19:vv8s7adsd9sdf7vs9fvd9f7v9d7s@thread.tacv2/
and that's all you need: convert %3a to : and %40 to @ , cut off after tacv2/ voilà!
If you'd like to store different channels: just take the ID between : and @ and use a template like
msteams:/l/channel/19:{channel_id}@thread.tacv2/
🙇:female_sign:
- ericw190Brass Contributor
Alright I got it! the command line switch to do this is msteams:
I just took such a channel link, quit Teams from the sys tray, The browser opens it with the command I'm looking for and then it will still be on the command line args of the running Teams.exe! 🤘
What I noticed is that the link is UBER long! In my case 345 characters.
The app actually complains about a LOT of stuff in there:
'tenantId' is not recognized as an internal or external command, operable program or batch file. 'deeplinkId' is not recognized as an internal or external command, operable program or batch file. 'launchAgent' is not recognized as an internal or external command, operable program or batch file. The system cannot find the file specified. 'directDl' is not recognized as an internal or external command, operable program or batch file. 'msLaunch' is not recognized as an internal or external command, operable program or batch file. 'enableMobilePage' is not recognized as an internal or external command, operable program or batch file. 'fqdn' is not recognized as an internal or external command, operable program or batch file.
So these can ALL be stripped off the link already and even groupId and type aren't needed!
One can even shorten off the name up to the slash like:
msteams:/l/channel/19:vv8s7adsd9sdf7vs9fvd9f7v9d7s@thread.tacv2/
and that's all you need: convert %3a to : and %40 to @ , cut off after tacv2/ voilà!
If you'd like to store different channels: just take the ID between : and @ and use a template like
msteams:/l/channel/19:{channel_id}@thread.tacv2/
🙇:female_sign:
- ericw190Brass Contributor
Another one. If you want to point to a message via command line and have it nicely highlighted this works very similarly:
msteams:l/message/19:{channel_id}@thread.tacv2/{message_id}?
So you can get rid of https://teams.microsoft.com/ in the front and all after ? in the end.
Turns out the ? at the end is important! Just like the / at the end of the channel template.
- erik-on-windowsCopper Contributor
ericw190 how do you retrieve the channel_id?
- Leroy_BifleCopper ContributorThanks! I had to replace tacv2 with skype.
- Meghana-MSFTMicrosoftCould you please provide us with the commands that you are using and repro steps? So that it would be helpful for us to repro the issue.
- ericw190Brass Contributor
Meghana-MSFTI'm sorry I get the strong feeling that my post was not read 😐 ok... commands
main issue: Command Line args to goto channels directly?
The main "command" I'm using is Teams.exe the executable to run the Teams application on Windows.
So from another application I want to be able to run the Teams.exe with a command line switch to open a certain channel directly WITHOUT going over the browser.
Another "command" I'm using is the :link:Get link to channel option from a channel I want to link to.
Now just like one can do Teams.exe sip:username@company.com to chat directly with a given user
I'd like to be able to do something like Teams.exe channel:https://teams.microsoft.com/l/channel/19%3acb55... to open up Teams with the desired channel.
Of course this does not work. What "works" is opening the channel link with a browser. But ONLY if the user already enabled all the required checks to make the Browser entitled to do so. And then one still has a Browser open and a website which does not close on its own.
So I'm asking for a command line argument to make that happen!
OK. How can I search on my own: DuckDuckGo? Google? Bing? .. There seems to be nothing of value 😕 sadly. Also the internal Help does not yield anything.
And finally like with any apps that do thing over the command line one can try "help" switches like: /? -help -h --help -? ... however nothing seems to work. All just open up the Teams app.
And whenever you do that ... also without ANY arguments the app will also print this DeprecationWarning to the console. Repro:
- Press Win key
- type cmd
- Press Enter key
- type or copy/paste
cd %LOCALAPPDATA%\Microsoft\Teams\current - type Teams.exe
- Press Enter key
Result:
- Teams app opens up
- message in the cmd window:
(node:9612) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
My version is 1.4.0.22976 at least that's the version detail on the executable.
- ericw190Brass Contributor
Since I call from Python eventually I was unable to use these calls without a path of teams.exe. (which is a solved problem ...) But I thought there was something to put on the Python subprocess.call() to make this work?
Was it .call(['start', cmd]) 🤔
Just prepending start works in a command line window no problem but not from subprocess.call().
What works there is getting os.getenv('COMSPEC') and calling it all together like:subprocess.call([os.getenv('COMSPEC'), '/c', 'start', cmd])
But it pops a command line window for a splitsecond and seems a bit weird that it doesn't work simpler? Any Ideas?
(I know how to solve the command line window popping but that makes it even longer)
- erik-on-windowsCopper Contributor
I use
subprocess.call("cmd /K start sip:" + email)
The python script is called from a vbs-wrapper-script, which suppresses the DOS-box.
- ericw190Brass Contributor
Oooh really?! pcheew. Well, If you want to know: there is also a python only way to do this. It's just 3 more lines:
startup_info = subprocess.STARTUPINFO() startup_info.wShowWindow = subprocess.SW_HIDE startup_info.dwFlags |= subprocess.STARTF_USESHOWWINDOW subprocess.call([com, '/k', 'start', cmd], startupinfo=startup_info)
where com is like com = os.getenv('COMSPEC') and cmd your msteams-call.
Oh! you put the /k there! Hmm. Also good. As the command is moving things into a thread and then returns it probably doesn't matter. But yea: it's probably better in case it does not return!