Link to home
Start Free TrialLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

AutoHotkey: Run Skype or Skype for Business

Hello experts,

I use Skype to call people from abroad that don't use WhatsApp, (call centers etc...) when I am in Colombia, United States, France, India, Netherlands/Holland and United Arab Emirates (in particular in Dubai). I have a subscription that I pay every month.

I use the following AutoHotkey script to run Skype or Skype for Business (for professional purposes).

;====================================
;Run Skype Business or normal Skype
;====================================


#!y::
SkypeBusiness:="C:\Program Files (x86)\Microsoft Office\root\Office16\lync.exe"
Skype:="C:\Program Files (x86)\Microsoft\Skype for Desktop\Skype.exe"


If (FileExist(SkypeBusiness))
  Run,%SkypeBusiness%
Else
If (FileExist(Skype))
 Run,%Skype%
Else
 MsgBox,4112,Error,Neither Skype for Business nor Skype exists on your system.
Return

Open in new window

When I run it, I have the following error message: 

User generated image

Some questions come across:

  1.  How can I identify where is skype.exe and lync.exe?
  2. How can I avoid to have the same issue if I update Skype or Skype for Business version
  3. Is there an AutoHotkey script to identify quickly the .exe file related to the application that I am running?

 

Regards,

Luis.

Avatar of Richard Cole
Richard Cole
Flag of United Kingdom of Great Britain and Northern Ireland image

This script uses the where command to search for the Skype and Skype for Business executables in their default installation directories. 

The where command returns the full path of the executable file, which is stored in the A_Stdout variable. 

The script then uses regular expressions to remove any line breaks and store the path in the SkypeBusiness and Skype variables.

The script then checks if either SkypeBusiness or Skype are not empty. If one of them is found, it runs the executable file. If neither of them is found, it displays an error message.


#SingleInstance, Force


; Press Ctrl+Alt+Y to run Skype or Skype for Business
^!y::
SkypeBusiness := ""
Skype := ""


; Look for Skype for Business
RunWait, %comspec% /c "where /R "%ProgramFiles(x86)%\Microsoft Office" lync.exe", , Hide
If (!ErrorLevel)
    SkypeBusiness := RegExReplace(Trim(A_Stdout), "\r?\n", "")
    
; Look for Skype
RunWait, %comspec% /c "where /R "%ProgramFiles(x86)%\Microsoft\Skype for Desktop" skype.exe", , Hide
If (!ErrorLevel)
    Skype := RegExReplace(Trim(A_Stdout), "\r?\n", "")


; Run Skype or Skype for Business
If (SkypeBusiness != "")
    Run, %SkypeBusiness%
Else If (Skype != "")
    Run, %Skype%
Else
    MsgBox, 4112, Error, Neither Skype for Business nor Skype exists on your system.
Return

Open in new window



Note that this script assumes that Skype and Skype for Business are installed in their default directories. If they are installed in a custom directory that you do not know the location of you can search for them using this script instead:


#SingleInstance, Force


; Press Ctrl+Alt+Y to run Skype or Skype for Business
^!y::
SkypeBusiness := ""
Skype := ""


; Search for Skype for Business
Loop, Files, %A_Desktop%\..\..\lync.exe, FR
{
    If (InStr(A_LoopFileFullPath, "Microsoft Office"))
    {
        SkypeBusiness := A_LoopFileFullPath
        Break
    }
}


; Search for Skype
Loop, Files, %A_Desktop%\..\..\skype.exe, FR
{
    If (InStr(A_LoopFileFullPath, "Microsoft\Skype for Desktop"))
    {
        Skype := A_LoopFileFullPath
        Break
    }
}


; Run Skype or Skype for Business
If (SkypeBusiness != "")
    Run, %SkypeBusiness%
Else If (Skype != "")
    Run, %Skype%
Else
    MsgBox, 4112, Error, Neither Skype for Business nor Skype exists on your system.
Return

Open in new window


This script uses the Loop, Files command to search for the Skype and Skype for Business executables in all directories on your system. It starts the search from the desktop folder (%A_Desktop%) and goes up two levels (..\..\) to search in all directories on your system.


The script uses the InStr() function to check if the current file is the Skype or Skype for Business executable. If a match is found, the full path of the executable is stored in the SkypeBusiness or Skype variable, and the loop is exited using the Break command.


The script then checks if either SkypeBusiness or Skype are not empty. If one of them is found, it runs the executable file. If neither of them is found, it displays an error message.


Note that searching for the executables in all directories on your system can take a long time, especially if you have a large number of files on your computer.

It's also possible that this script may return false positives if there are other files on your system with similar names to the Skype or Skype for Business executables.

Therefore, it's recommended to use this script as a last resort if you're unable to locate the executables using the default installation directories.






ASKER CERTIFIED SOLUTION
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Luis Diaz

ASKER

Hello Joe,
I tested your proposal and it works perfectly (as always).
User generated imageUser generated imageI will test Skype for Business as soon as I receive my professional computer from France.
Thank you again for your help.
Regards,
Luis.
Richard,
Your solution also works !
Thank you for your help.
Regards,
Luis.
Hi Luis,
I tested your proposal and it works perfectly (as always).
Glad to hear it!
Richard,

Your solution also works !
Did you actually test those two scripts? When I ran the first one, I got this:

User generated image
That's an AutoHotkey syntax error...the script can't even run.

When I ran the second one, I got this, even though I have Skype (normal) on my W10 system.

User generated image
Regards, Joe
Hello Joe,
You are totally right. I tested your script and not Richard script. I don't know why I didn't save it Richard proposal. Bad manipulation. My wrong.
Mistake de junior :-)
¡Del afán solo queda el cansancio!
Of the eagerness only the tiredness remains!
I removed solution assignation of Richard proposal (If he replied it would be great. If not your proposal will remain as unique solution).
Regards,
Luis.