Advertisement
Guest User

Bene

a guest
Oct 8th, 2009
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.50 KB | None | 0 0
  1. ; check ob laufender firefox.exe prozess existiert
  2. If ProcessExists( "firefox.exe" ) Then
  3.     ; existiert bereits, prüfen ob fester oder portabler läuft
  4.     $laufender_prozess = _ProcessGetLocation( "firefox.exe" )
  5.     If $laufender_prozess <> @ScriptDir & "\Firefox\firefox.exe" Then
  6.         #cs
  7.             wenn laufender firefox prozess nicht von der portablen version ist,
  8.             dann starte firefox mit -no-remote und -profile, andernfalls mache nichts.
  9.             fest laufender firefox nimmt externe links an.
  10.         #ce
  11.         Run( "Firefox\firefox.exe -no-remote -profile Profilordner" )
  12.     EndIf
  13. Else
  14.     ; existiert nicht, firefox starten mit -profile. portabler Firefox nimmt links an
  15.     Run( "Firefox\firefox.exe -profile Profilordner" )
  16. EndIf
  17.  
  18. ; Pfad zu einem Prozess auslesen
  19. Func _ProcessGetLocation($sProc = @ScriptFullPath)
  20.     Local $iPID = ProcessExists($sProc)
  21.     If $iPID = 0 Then Return SetError(1, 0, -1)
  22.  
  23.     Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID)
  24.     If $aProc[0] = 0 Then Return SetError(1, 0, -1)
  25.  
  26.     Local $vStruct = DllStructCreate('int[1024]')
  27.     DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int*', 0)
  28.  
  29.     Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048)
  30.     If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '')
  31.     Return $aReturn[3]
  32. EndFunc
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement