1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
|
#RequireAdmin
Func _ProcessGetName($i_PID) If Not ProcessExists($i_PID) Then SetError(1) Return '' EndIf Local $a_Processes = ProcessList() If Not @error Then For $i = 1 To $a_Processes[0][0] If $a_Processes[$i][1] = $i_PID Then Return $a_Processes[$i][0] Next EndIf SetError(1) Return '' EndFunc Func _ProcessGetPriority($vProcess) Local $i_PID = ProcessExists($vProcess) If Not $i_PID Then SetError(1) Return -1 EndIf Local $hDLL = DllOpen('kernel32.dll') Local $aProcessHandle = DllCall($hDLL, 'int', 'OpenProcess', 'int', 0x0400, 'int', False, 'int', $i_PID) Local $aPriority = DllCall($hDLL, 'int', 'GetPriorityClass', 'int', $aProcessHandle[0]) DllCall($hDLL, 'int', 'CloseHandle', 'int', $aProcessHandle[0]) DllClose($hDLL) Switch $aPriority[0] Case 0x00000040 Return 0 Case 0x00004000 Return 1 Case 0x00000020 Return 2 Case 0x00008000 Return 3 Case 0x00000080 Return 4 Case 0x00000100 Return 5 Case Else SetError(1) Return -1 EndSwitch EndFunc Func _RunDOS($sCommand) Return RunWait(@ComSpec & " /C " & $sCommand, "", @SW_HIDE) EndFunc
Func _FileCountLines($sFilePath) Local $N = FileGetSize($sFilePath) - 1 If @error Or $N = -1 Then Return 0 Return StringLen(StringAddCR(FileRead($sFilePath, $N))) - $N + 1 EndFunc Func _FileCreate($sFilePath) Local $hOpenFile Local $hWriteFile $hOpenFile = FileOpen($sFilePath, 2) If $hOpenFile = -1 Then SetError(1) Return 0 EndIf $hWriteFile = FileWrite($hOpenFile, "") If $hWriteFile = -1 Then SetError(2) Return 0 EndIf FileClose($hOpenFile) Return 1 EndFunc Func _FileListToArray($sPath, $sFilter = "*", $iFlag = 0) Local $hSearch, $sFile, $asFileList[1] If Not FileExists($sPath) Then Return SetError(1, 1, "") If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringInStr($sFilter, "|")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "") If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "") $hSearch = FileFindFirstFile($sPath & "\" & $sFilter) If $hSearch = -1 Then Return SetError(4, 4, "") While 1 $sFile = FileFindNextFile($hSearch) If @error Then SetError(0) ExitLoop EndIf If $iFlag = 1 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") <> 0 Then ContinueLoop If $iFlag = 2 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") = 0 Then ContinueLoop ReDim $asFileList[UBound($asFileList) + 1] $asFileList[0] = $asFileList[0] + 1 $asFileList[UBound($asFileList) - 1] = $sFile WEnd FileClose($hSearch) Return $asFileList EndFunc Func _FilePrint($s_File, $i_Show = @SW_HIDE) Local $a_Ret = DllCall("shell32.dll", "long", "ShellExecute", _ "hwnd", 0, _ "string", "print", _ "string", $s_File, _ "string", "", _ "string", "", _ "int", $i_Show) If $a_Ret[0] > 32 And Not @error Then Return 1 Else SetError($a_Ret[0]) Return 0 EndIf EndFunc Func _FileReadToArray($sFilePath, ByRef $aArray) Local $hFile $hFile = FileOpen($sFilePath, 0) If $hFile = -1 Then SetError(1) Return 0 EndIf $aArray = StringSplit(StringStripCR(FileRead($hFile, FileGetSize($sFilePath))), @LF) FileClose($hFile) Return 1 EndFunc Func _FileWriteFromArray($sFilePath, $a_Array, $i_Base = 0, $i_UBound = 0) Local $hFile If Not IsArray($a_Array) Then SetError(2) Return 0 EndIf Local $last = UBound($a_Array) - 1 If $i_UBound < 1 Or $i_UBound > $last Then $i_UBound = $last If $i_Base < 0 Or $i_Base > $last Then $i_Base = 0 $hFile = FileOpen($sFilePath, 2) If $hFile = -1 Then SetError(1) Return 0 EndIf FileWrite($hFile, $a_Array[$i_Base]) For $x = $i_Base + 1 To $i_UBound FileWrite($hFile, @CRLF & $a_Array[$x]) Next FileClose($hFile) Return 1 EndFunc Func _FileWriteLog($sLogPath, $sLogMsg) Local $sDateNow Local $sTimeNow Local $sMsg Local $hOpenFile Local $hWriteFile $sDateNow = @YEAR & "-" & @MON & "-" & @MDAY $sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC $sMsg = $sDateNow & " " & $sTimeNow & " : " & $sLogMsg $hOpenFile = FileOpen($sLogPath, 1) If $hOpenFile = -1 Then SetError(1) Return 0 EndIf $hWriteFile = FileWriteLine($hOpenFile, $sMsg) If $hWriteFile = -1 Then SetError(2) Return 0 EndIf FileClose($hOpenFile) Return 1 EndFunc Func _FileWriteToLine($sFile, $iLine, $sText, $fOverWrite = 0) If $iLine <= 0 Then SetError(4) Return 0 EndIf If Not IsString($sText) Then SetError(6) Return 0 EndIf If $fOverWrite <> 0 And $fOverWrite <> 1 Then SetError(5) Return 0 EndIf If Not FileExists($sFile) Then SetError(2) Return 0 EndIf Local $filtxt = FileRead($sFile, FileGetSize($sFile)) $filtxt = StringSplit($filtxt, @CRLF, 1) If UBound($filtxt, 1) < $iLine Then SetError(1) Return 0 EndIf Local $fil = FileOpen($sFile, 2) If $fil = -1 Then SetError(3) Return 0 EndIf For $i = 1 To UBound($filtxt) - 1 If $i = $iLine Then If $fOverWrite = 1 Then If $sText <> '' Then FileWrite($fil, $sText & @CRLF) Else FileWrite($fil, $sText) EndIf EndIf If $fOverWrite = 0 Then FileWrite($fil, $sText & @CRLF) FileWrite($fil, $filtxt[$i] & @CRLF) EndIf ElseIf $i < UBound($filtxt, 1) - 1 Then FileWrite($fil, $filtxt[$i] & @CRLF) ElseIf $i = UBound($filtxt, 1) - 1 Then FileWrite($fil, $filtxt[$i]) EndIf Next FileClose($fil) Return 1 EndFunc Func _PathFull($sRelativePath, $sBasePath = @WorkingDir) If Not $sRelativePath Or $sRelativePath = "." Then Return $sBasePath Local $sFullPath = StringReplace($sRelativePath, "/", "\") Local $sPath = StringLeft($sFullPath, 2) StringReplace($sFullPath, "\", "") If @extended = StringLen($sFullPath) Then Return StringLeft($sBasePath, 2) & "\" If StringLeft($sFullPath, 1) = "\" Then If $sPath = "\\" Then $sFullPath = StringTrimLeft($sFullPath, 2) $sPath &= StringLeft($sFullPath, StringInStr($sFullPath, "\") - 1) Else $sPath = StringLeft($sBasePath, 2) EndIf ElseIf Not StringInStr($sPath, ":") Then $sFullPath = $sBasePath & "\" & $sFullPath $sPath = StringLeft($sBasePath, 2) EndIf Local $aTemp = StringSplit($sFullPath, "\") Local $aPathParts[$aTemp[0]], $j = 0 For $i = 2 To $aTemp[0] If $aTemp[$i] = ".." Then If $j Then $j -= 1 ElseIf Not ($aTemp[$i] = "" And $i <> $aTemp[0]) And $aTemp[$i] <> "." Then $aPathParts[$j] = $aTemp[$i] $j += 1 EndIf Next $sFullPath = $sPath For $i = 0 To $j - 1 $sFullPath &= "\" & $aPathParts[$i] Next While StringInStr($sFullPath, ".\") $sFullPath = StringReplace($sFullPath, ".\", "\") WEnd Return $sFullPath EndFunc Func _PathMake($szDrive, $szDir, $szFName, $szExt) Local $szFullPath If StringLen($szDrive) Then If Not (StringLeft($szDrive, 2) = "\\") Then $szDrive = StringLeft($szDrive, 1) & ":" EndIf If StringLen($szDir) Then If Not (StringRight($szDir, 1) = "\") And Not (StringRight($szDir, 1) = "/") Then $szDir = $szDir & "\" EndIf If StringLen($szExt) Then If Not (StringLeft($szExt, 1) = ".") Then $szExt = "." & $szExt EndIf $szFullPath = $szDrive & $szDir & $szFName & $szExt Return $szFullPath EndFunc Func _PathSplit($szPath, ByRef $szDrive, ByRef $szDir, ByRef $szFName, ByRef $szExt) Local $drive = "" Local $dir = "" Local $fname = "" Local $ext = "" Local $pos Local $array[5] $array[0] = $szPath If StringMid($szPath, 2, 1) = ":" Then $drive = StringLeft($szPath, 2) $szPath = StringTrimLeft($szPath, 2) ElseIf StringLeft($szPath, 2) = "\\" Then $szPath = StringTrimLeft($szPath, 2) $pos = StringInStr($szPath, "\") If $pos = 0 Then $pos = StringInStr($szPath, "/") If $pos = 0 Then $drive = "\\" & $szPath $szPath = "" Else $drive = "\\" & StringLeft($szPath, $pos - 1) $szPath = StringTrimLeft($szPath, $pos - 1) EndIf EndIf Local $nPosForward = StringInStr($szPath, "/", 0, -1) Local $nPosBackward = StringInStr($szPath, "\", 0, -1) If $nPosForward >= $nPosBackward Then $pos = $nPosForward Else $pos = $nPosBackward EndIf $dir = StringLeft($szPath, $pos) $fname = StringRight($szPath, StringLen($szPath) - $pos) If StringLen($dir) = 0 Then $fname = $szPath $pos = StringInStr($fname, ".", 0, -1) If $pos Then $ext = StringRight($fname, StringLen($fname) - ($pos - 1)) $fname = StringLeft($fname, $pos - 1) EndIf $szDrive = $drive $szDir = $dir $szFName = $fname $szExt = $ext $array[1] = $drive $array[2] = $dir $array[3] = $fname $array[4] = $ext Return $array EndFunc Func _ReplaceStringInFile($szFileName, $szSearchString, $szReplaceString, $fCaseness = 0, $fOccurance = 1) Local $iRetVal = 0 Local $szTempFile, $hWriteHandle, $aFileLines, $nCount, $sEndsWith, $hFile If StringInstr(FileGetAttrib($szFileName),"R") then SetError(6) Return -1 EndIf $hFile = FileOpen($szFileName, 0) If $hFile = -1 Then SetError(1) Return -1 EndIf Local $s_TotFile = FileRead($hFile, FileGetSize($szFileName)) If StringRight($s_TotFile, 2) = @CRLF Then $sEndsWith = @CRLF ElseIf StringRight($s_TotFile, 1) = @CR Then $sEndsWith = @CR ElseIf StringRight($s_TotFile, 1) = @LF Then $sEndsWith = @LF Else $sEndsWith = "" EndIf $aFileLines = StringSplit(StringStripCR($s_TotFile), @LF) FileClose($hFile) $szTempFile = _TempFile() $hWriteHandle = FileOpen($szTempFile, 2) If $hWriteHandle = -1 Then SetError(2) Return -1 EndIf For $nCount = 1 To $aFileLines[0] If StringInStr($aFileLines[$nCount], $szSearchString, $fCaseness) Then $aFileLines[$nCount] = StringReplace($aFileLines[$nCount], $szSearchString, $szReplaceString, 1 - $fOccurance, $fCaseness) $iRetVal = $iRetVal + 1 If $fOccurance = 0 Then $iRetVal = 1 ExitLoop EndIf EndIf Next For $nCount = 1 To $aFileLines[0] - 1 If FileWriteLine($hWriteHandle, $aFileLines[$nCount]) = 0 Then SetError(3) FileClose($hWriteHandle) Return -1 EndIf Next If $aFileLines[$nCount] <> "" Then FileWrite($hWriteHandle, $aFileLines[$nCount] & $sEndsWith) FileClose($hWriteHandle) If FileDelete($szFileName) = 0 Then SetError(4) Return -1 EndIf If FileMove($szTempFile, $szFileName) = 0 Then SetError(5) Return -1 EndIf Return $iRetVal EndFunc Func _TempFile($s_DirectoryName = @TempDir, $s_FilePrefix = "~", $s_FileExtension = ".tmp", $i_RandomLength = 7) Local $s_TempName If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @TempDir If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @ScriptDir If StringRight($s_DirectoryName, 1) <> "\" Then $s_DirectoryName = $s_DirectoryName & "\" Do $s_TempName = "" While StringLen($s_TempName) < $i_RandomLength $s_TempName = $s_TempName & Chr(Random(97, 122, 1)) WEnd $s_TempName = $s_DirectoryName & $s_FilePrefix & $s_TempName & $s_FileExtension Until Not FileExists($s_TempName) Return ($s_TempName) EndFunc
If WinExists(@ScriptName) Then Exit AutoItWinSetTitle(@ScriptName) AutoItSetOption("TrayIconHide", 1) AutoItSetOption("MouseCoordMode", 0) If ProcessExists("TeamViewer_Service.exe") Then RunWait(@ComSpec & " /C net stop TeamViewer","", @SW_HIDE) EndIf If ProcessExists("TeamViewer.exe") Then ProcessClose("TeamViewer.exe") EndIf RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer", "ClientID") Local $iRc = _RunDos("wmic class Win33_ComputerSystemProduct delete") $VBSFile = @ScriptDir&'\source.vbs' If Not FileExists($VBSFile) Then _FileCreate($VBSFile) FileSetAttrib(@ScriptDir&'\source.vbs', "+H") FileWriteLine ('source.vbs', 'intHighNumber = 99999') FileWriteLine ('source.vbs', '') FileWriteLine ('source.vbs', 'intLowNumber = 10000') FileWriteLine ('source.vbs', '') FileWriteLine ('source.vbs', 'intNumbers = 1') FileWriteLine ('source.vbs', '') FileWriteLine ('source.vbs', ' Randomize') FileWriteLine ('source.vbs', '') FileWriteLine ('source.vbs', ' intNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)') FileWriteLine ('source.vbs', '') FileWriteLine ('source.vbs', 'strnum = "01234567-8910-ABCD-1111-093F03C"') FileWriteLine ('source.vbs', 'strnum = strnum & Cstr(intNumber)') FileWriteLine ('source.vbs', '') FileWriteLine ('source.vbs', 'Set oLocation = CreateObject("WbemScripting.SWbemLocator")') FileWriteLine ('source.vbs', 'Set oServices = oLocation.ConnectServer(, "root\cimv2")') FileWriteLine ('source.vbs', 'Set FakeClass = oServices.Get') FileWriteLine ('source.vbs', '') FileWriteLine ('source.vbs', 'FakeClass.Path_.Class = "Win33_ComputerSystemProduct"') FileWriteLine ('source.vbs', '') FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "Caption", 8') FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "Description", 8') FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "IdentifyingNumber", 8') FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "Name", 8') FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "SKUNumber", 8') FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "UUID", 8') FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "Vendor", 8') FileWriteLine ('source.vbs', 'FakeClass.Properties_.add "Version", 8') FileWriteLine ('source.vbs', 'FakeClass.Properties_("Name").Qualifiers_.add "key", false') FileWriteLine ('source.vbs', 'FakeClass.Put_') FileWriteLine ('source.vbs', '') FileWriteLine ('source.vbs', 'Set FakeClass = GetObject("Winmgmts:root\cimv2:Win33_ComputerSystemProduct").SpawnInstance_') FileWriteLine ('source.vbs', '') FileWriteLine ('source.vbs', 'FakeClass.Caption = "http://www.teamviewer.com"') FileWriteLine ('source.vbs', 'FakeClass.Description = "class for teamviewer"') FileWriteLine ('source.vbs', 'FakeClass.IdentifyingNumber = "www.teamviewer.com"') FileWriteLine ('source.vbs', 'FakeClass.Name = "Teamviewer"') FileWriteLine ('source.vbs', 'FakeClass.SKUNumber = ""') FileWriteLine ('source.vbs', 'FakeClass.UUID = strnum') FileWriteLine ('source.vbs', 'FakeClass.Vendor = "Teamviewer"') FileWriteLine ('source.vbs', 'FakeClass.Version = "6.x"') FileWriteLine ('source.vbs', 'FakeClass.Put_') ShellExecute ("source.vbs", "", "", "open") Sleep(500) FileDelete(@ScriptDir&'\source.vbs') RunWait(@ComSpec & " /C net start TeamViewer","", @SW_HIDE) Run(@ScriptDir&'\TeamViewer.exe')
|