set tempFile = CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2)
If WScript.Arguments.Named.Exists("elevate") Then
call Common
Else GetAdminRights
end if

sub Common

' Деинсталляция
Set os = CreateObject("WScript.Shell")
os.Run "cmd /c start ""uninstall"" ""%COMMONPROGRAMFILES(x86)%\Autodesk Shared\AdskLicensing\uninstall.exe""", 0, True

WScript.Sleep 2000

' Вызываем метод проверки наличия процесса
WaitForProcess ".", "uninstall.exe"

' Удаляем папки
os.Run "cmd /c rd ""%COMMONPROGRAMFILES(x86)%\Autodesk Shared\Adlm"" /s /q & rd ""%COMMONPROGRAMFILES(x86)%\Autodesk Shared\AdskLicensing"" /s /q", 0, True

WScript.Sleep 2000

' Запускаем новый инсталлятор
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFile = tempFile & "\temporaryRead.txt"
Set objFile = objFSO.OpenTextFile(strFile)
Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
    os.Run """" & strLine & "\adsklicensinginstaller-9.2.2.2501.exe"""
Loop
objFile.Close

' Удалить временный файл
if objFSO.FileExists(strFile) then
objFSO.DeleteFile strFile

end if

end sub

Sub WaitForProcess(strComputer, strProcess)
    Dim wmiQuery : wmiQuery = "Select * From Win32_Process Where Name='" _
                          & strProcess & "'"
    Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\" & strComputer _
                                    & "\root\cimv2")
    Dim colItems : Set colItems = objWMIService.ExecQuery(wmiQuery)

    Dim intProcCount : intProcCount = colItems.Count
    Do While intProcCount > 0
        Set colItems = objWMIService.ExecQuery(wmiQuery)
        intProcCount = colItems.Count
        WScript.Sleep 500
    Loop
End Sub


sub GetAdminRights

Set objFSO = CreateObject("Scripting.FileSystemObject")
outFile = tempFile & "\temporaryRead.txt"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write CreateObject("WScript.Shell").CurrentDirectory & vbCrLf
objFile.Close

If Not WScript.Arguments.Named.Exists("elevate") Then
  CreateObject("Shell.Application").ShellExecute WScript.FullName _
    , """" & WScript.ScriptFullName & """ /elevate", "", "runas", 1
  WScript.Quit
End If
end sub