langFixUrl = "http://www.skaip.su/avtomaticheskoe-ustranenie-oshibki-s-otsutstviem-api-ms-dll" langSkypepathNotFound = "Не удалось найти папку установки Skype. Вы должны указать путь к файлу Skype.exe" langGetHelp = "Хотите посетить блог и обратиться за помощью?" langNotFixed = "Кажется, что-то пошло не так." langFixComplete = "Скрипт решил свою работу и, кажется, удалось решить проблему. Хотите посетить блог автора и поблагодарить его, оставив отзыв или оценку?" Set App = CreateObject("Shell.Application") Set Shell = CreateObject("WScript.Shell") Set Fso = CreateObject("Scripting.FileSystemObject") Function RunAsAdministrator() If WScript.Arguments.Length = 0 Then Set Systems = WmiQuery("Select Caption From Win32_OperatingSystem") For Each System In Systems If InStr(System.Caption, "Windows XP") Then Exit Function End If Next App.ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ RunAsAdministrator", , "runas", 1 WScript.Quit End if End Function Function GetOsName() Set Systems = WmiQuery("Select Caption From Win32_OperatingSystem") End Function Function DownloadFile(url, file) CreateFolder(Fso.GetParentFolderName(file)) Set Http = CreateObject("Microsoft.XMLHTTP") Http.Open "GET", url, False Http.Send Set Stream = CreateObject("Adodb.Stream") Stream.type = 1 Stream.open Stream.write Http.responseBody Stream.savetofile file, 2 End Function Function ProcessIsRunning(name) query = "Select * From Win32_Process Where Name Like '" & name & "'" ProcessIsRunning = WmiQuery(query).Count > 0 End Function Function WmiQuery(query) Set Wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set WmiQuery = Wmi.ExecQuery(query) End Function Function CreateFolder(path) If Not Fso.FolderExists(path) Then CreateFolder(Fso.GetParentFolderName(path)) Fso.CreateFolder(path) End If End Function Function Unzip(file, folder) CreateFolder(folder) Set Files = App.NameSpace(file).items App.NameSpace(folder).CopyHere Files, 16 End Function Function StartSkype(file) Shell.Run """" + file + """", 1, False i = 0 Do While i < 60 i = i + 1 If ProcessIsRunning("Skype.exe") Then FixComplete() Exit Function End If WScript.Sleep 1000 Loop ShowError(langNotFixed) End Function Function CloseSkype() Shell.Run "cmd /c taskkill /F /IM Skype.exe", 0, True Shell.Run "cmd /c taskkill /F /IM SkypeBrowserHost.exe", 0, True End Function Function GetSkypePath(path) If path = False Then GetSkypePath = Shell.ExpandEnvironmentStrings("%ProgramFiles(x86)%\Skype\Phone\Skype.exe") If Not Fso.FileExists(GetSkypePath) Then GetSkypePath = Shell.ExpandEnvironmentStrings("%ProgramFiles%\Skype\Phone\Skype.exe") End If Else GetSkypePath = path End If If Not Fso.FileExists(GetSkypePath) Then GetSkypePath = InputBox(langSkypepathNotFound, "ERROR!") If GetSkypePath = "" Then WScript.Quit Else GetSkypePath(GetSkypePath) End If End If End Function Function ShowError(msg) btn = MsgBox(msg + vbNewLine + langGetHelp, 20, "ERROR!") If btn = 6 Then Shell.Run langFixUrl End If End Function Function FixComplete() btn = MsgBox(langFixComplete, 4) If btn = 6 Then Shell.Run langFixUrl End If End Function Function AppStart() RunAsAdministrator() skypeExeFile = GetSkypePath(False) If Fso.FileExists(skypeExeFile) Then CloseSkype() zipFile = WScript.ScriptFullName & ".zip" DownloadFile "http://download.skaip.org/other/api-ms-win.zip", zipFile Unzip zipFile, Fso.GetParentFolderName(skypeExeFile) Fso.DeleteFile(zipFile) StartSkype(skypeExeFile) End If End Function AppStart()