Jump to content

Micha1405

Active Members
  • Posts

    107
  • Joined

  • Last visited

Everything posted by Micha1405

  1. Hello Engine, it does not work on Windows 7, i think Windows Vista is the same.
  2. Try this http://www.autoitscript.com/forum/index.php?showtopic=19848
  3. This is the better one !!! http://www.autoitscript.com/forum/index.php?showtopic=104735 with a little modification you can build a runasloggedonUser and start programs from system as user (with user profile) ! great script from "wraithdu"
  4. Description: a process runnings as system will start a new process as user! Complile the script and start a system console an type: runasuser.exe notepad.exe the script works with Windows XP and Win7, but the Process will only start with the User Rights but without a Profile, can anyboddy help me to change it to "run as logged on user with using the profile of the user" #AutoIt3Wrapper_Outfile=RunAsUser.exe #NoTrayIcon #RequireAdmin #include <StructureConstants.au3> #include <WinAPI.au3> Global Const $STANDARD_RIGHTS_REQUIRED = 0x000F0000 Global Const $TOKEN_ALL_ACCESS_P = BitOR($STANDARD_RIGHTS_REQUIRED, $TOKEN_ASSIGN_PRIMARY, $TOKEN_DUPLICATE, $TOKEN_IMPERSONATE, $TOKEN_QUERY, $TOKEN_QUERY_SOURCE, $TOKEN_ADJUST_PRIVILEGES, $TOKEN_ADJUST_GROUPS, $TOKEN_ADJUST_DEFAULT) Global Const $TOKEN_ALL_ACCESS = BitOR($TOKEN_ALL_ACCESS_P, $TOKEN_ADJUST_SESSIONID) Global $ghADVAPI32 = DllOpen("advapi32.dll") $lpApplicationName = "" $lpCommandline = "Notepad.exe" $CustomProcess = $lpCommandline $lpProcessAttributes = DllStructCreate($tagSECURITY_ATTRIBUTES) $lpThreadAttributes = DllStructCreate($tagSECURITY_ATTRIBUTES) $bInheritHandles = False $dwCreationFlags = 0x0 $lpEnvironment = "" $lpCurrentDirectory = "" $si = DllStructCreate($tagSTARTUPINFO) $pi = DllStructCreate($tagPROCESS_INFORMATION) DllStructSetData($lpThreadAttributes, "Descriptor", "") $ta_size = DllStructGetSize($lpThreadAttributes) DllStructSetData($lpThreadAttributes, "Length", $ta_size) DllStructSetData($lpProcessAttributes, "Descriptor", "") $pa_size = DllStructGetSize($lpProcessAttributes) DllStructSetData($lpProcessAttributes, "Length", $pa_size) DllStructSetData($si, "lpDesktop", "winsta0\default") $pi_size = DllStructGetSize($pi) $si_size = DllStructGetSize($si) DllStructSetData($pi, "Size", $pi_size) DllStructSetData($si, "Size", $si_size) If $Cmdline[0] < 1 And $Cmdline[0] <> 1 Then Exit Else $lpCommandline = $Cmdline[1] $CustomProcess = $lpCommandline EndIf ; 1 Step GET Security TOKEN FROM EXPLORER process running as user If ProcessExists("DMW.exe") Then $ProcessID = ProcessExists("DWM.exe") ;Windows 7 Else $ProcessID = ProcessExists("EXPLORER.exe") EndIf ; 2 STEP GET HANDLE FROM PROCESS $ProcessHandle = _WinAPI_OpenProcess(0x0400, False, $ProcessID) ; 3 Step GEt TOKEN from Process $ProcessToken = _WinAPI_OpenProcessToken($ProcessHandle, $TOKEN_ALL_ACCESS) If $ProcessToken Then _WinAPI_ImpersonateLoggedOnUser($ProcessToken) ;$ProcessToken = DllCall("advapi32.dll", "int", "DuplicateTokenEx", "long_ptr", $ProcessToken, "int", $TOKEN_ALL_ACCESS, "long_ptr", "", "int", $TOKEN_TYPE_IMPERSONATION, "int", $TOKEN_TYPE_PRIMARY, "long_ptr*", "") LaunchProcessAsUser($CustomProcess) If $ProcessToken Then _WinAPI_CloseHandle($ProcessToken) If $ProcessHandle Then _WinAPI_CloseHandle($ProcessHandle) Func LaunchProcessAsUser($CustomProcess) Local Const $tagSTARTUPINFO = "dword cb;ptr lpReserved;ptr lpDesktop;ptr lpTitle;dword dwX;dword dwY;dword dwXSize;dword dwYSize;" & _ "dword dwXCountChars;dword dwYCountChars;dword dwFillAttribute;dword dwFlags;ushort wShowWindow;" & _ "ushort cbReserved2;ptr lpReserved2;ptr hStdInput;ptr hStdOutput;ptr hStdError" Local Const $tagPROCESSINFO = "ptr hProcess;ptr hThread;dword dwProcessId;dword dwThreadId" $hToken = $ProcessToken $si = DllStructCreate($tagSTARTUPINFO) $pi = DllStructCreate($tagPROCESS_INFORMATION) $pi_size = DllStructGetSize($pi) $si_size = DllStructGetSize($si) $si_lpDesktop = "" DllStructSetData($pi, "Size", $pi_size) DllStructSetData($si, "Size", $si_size) $console = "0x3" $a_PCall = DllCall("advapi32.dll", "bool", "CreateProcessAsUser", _ ; "handle", $hToken, _ "ptr", 0, _ ; you don't need this "str", $lpCommandline, _ ; wstr for CreateProcessAsUserW "ptr", DllStructGetPtr($lpProcessAttributes), _ "ptr", DllStructGetPtr($lpThreadAttributes), _ "bool", $bInheritHandles, _ "dword", $dwCreationFlags, _ "ptr", 0, _ ; you don't need this "ptr", 0, _ ; you don't need this "ptr", DllStructGetPtr($si), _ "ptr", DllStructGetPtr($pi)) $dllerr = @error EndFunc ;==>LaunchProcessAsUser Func _WinAPI_OpenProcessToken($pHandle, $iAccess) Local $aResult = DllCall("advapi32.dll", "int", "OpenProcessToken", "hwnd", $pHandle, "int", $iAccess, "int*", 0) If @error Or $aResult[0] = 0 Then Return SetError(1, 0, 0) Return SetError(0, 0, $aResult[3]) EndFunc ;==>_WinAPI_OpenProcessToken Func _WinAPI_ImpersonateLoggedOnUser($hToken) Local $aResult = DllCall("advapi32.dll", "int", "ImpersonateLoggedOnUser", "hwnd", $hToken) If @error Then Return SetError(@error, @extended, 0) Return SetError(0, 0, $aResult[0] <> 0) EndFunc ;==>_WinAPI_ImpersonateLoggedOnUser
  5. -- REMOVED ----
  6. take a look here http://www.das-download-archiv.de/software...eo-capture.html it is freeware
  7. @ejbmail This is MSI technology you do not need the MSI Name you only must know the MSi Product Code to uninstall the software
  8. Great Job !! what about move an user to another OU ? can anybody build this code ?
  9. @Arcker greate stuff, well done
  10. for me it works !! you have to open a command prompt and type "Service_Example.exe /i" type: SC QUERY you get the result: SERVICE_NAME: Autoit_Service DISPLAY_NAME: Autoit Service Test TYPE : 10 STATE : 4 R ( WIN32_EXIT_CODE : 0 ( SERVICE_EXIT_CODE : 0 ( CHECKPOINT : 0x0 WAIT_HINT : 0x0
  11. look here: http://www.autoitscript.com/forum/index.ph...p;hl=adfunction
  12. Try this RunAsWait ($UserName,$DomainName,$Password, 0, $RunProgram )
  13. Try this, use PSEXEC for REMOTE Executing _NetAPI_NetLocalGroupDelMembers("USERAccountName","Administrators","") ; =================================================================================================== ; Name...........: _NetAPI_NetLocalGroupDelMembers ; Description ...: Delete membership of one existing user or global group account to an existing local group ; Syntax.........: _NetAPI_NetLocalGroupDelMembers($sAccount, $sGroup, $sServer) ; Parameters ....: $sAccount - Account name of the Local Group member prefixed by the domain name and the "\" separator ; : $sGroup - Name of the Local Group to which the specified users or global groups will be deleted ; : $sServer - DNS or NetBIOS name of the remote Server or Null for Local use ; Return values .: Success - True ; Failure - False and @Extended set error code ; Author ........: micha1405 ; Example .......: _NetAPI_NetLocalGroupDelMembers("Domain\User", "Administrators") ; =================================================================================================== Func _NetAPI_NetLocalGroupDelMembers($sAccount, $sGroup, $sServer = '') Local $twUser = DllStructCreate("wchar["& StringLen($sAccount)+1 &"]") Local $tpUser = DllStructCreate("ptr") DllStructSetData($twUser, 1, $sAccount) DllStructSetData($tpUser, 1, DllStructGetPtr($twUser)) Local $aRet = DllCall("netapi32.dll", "int", "NetLocalGroupDelMembers", _ "wstr", $sServer, "wstr", $sGroup, "int", 3, "ptr", DllStructGetPtr($tpUser), "int", 1 ) If $aRet[0] Then Return SetError(1, $aRet[0], False) Return True EndFunc; ==> _NetAPI_NetLocalGroupDelMembers
  14. like this CODE #include <GuiConstants.au3> #include <WindowsConstants.au3> Opt ("GUIOnEventMode", 1) ;$GUI_EVENT_CLOSE ;$GUI_EVENT_MINIMIZE ;$GUI_EVENT_RESTORE ;$GUI_EVENT_MAXIMIZE ;$GUI_EVENT_PRIMARYDOWN ;$GUI_EVENT_PRIMARYUP ;$GUI_EVENT_SECONDARYDOWN ;$GUI_EVENT_SECONDARYUP ;$GUI_EVENT_MOUSEMOVE ;$GUI_EVENT_RESIZED ;$GUI_EVENT_DROPPED ;Global Const $HTCLIENT = 0x1 ;Global Const $HTCAPTION = 0x2 Global $MousePos, $WinPos, $PosDiff[2] Global $user32_dll = DllOpen ("user32.dll") $hGui = GUICreate("Test", 300, 200,-1,-1,BitOR($WS_POPUP, $WS_BORDER)) TrayTip ( "", "Click left button to move and right button to exit",30) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_MoveGui") GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_Exit") GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState() While 1 Sleep(100) WEnd Func WM_NCHITTEST($hWnd, $Msg, $wParam, $lParam) Local $iProc $iProc = DllCall("user32.dll", "int", "DefWindowProc", "hwnd", $hWnd, "int", $Msg, "wparam", $wParam, "lparam", $lParam) $iProc = $iProc[0] If $iProc = $HTCLIENT Then Return $HTCAPTION Return $GUI_RUNDEFMSG EndFunc func _MoveGui() GUISetCursor (9, 1) While 1 $MousePos = MouseGetPos () $WinPos = WinGetPos ("Test") $PosDiff[0] = $WinPos[0] - $MousePos[0] $PosDiff[1] = $WinPos[1] - $MousePos[1] If _IsPressed ("01", $user32_dll) Then While _IsPressed ("01", $user32_dll) $MousePos = MouseGetPos () WinMove ("Test", "", $MousePos[0] + $PosDiff[0], $MousePos[1] + $PosDiff[1]) $WinPos = WinGetPos ("Test") Sleep (10) WEnd GUISetCursor () ExitLoop EndIf Sleep (10) WEnd EndFunc Func _IsPressed($s_hexKey, $v_dll = 'user32.dll') Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFunc ;==>_IsPressed Func _Exit() MsgBox(0,"","exit...",1) Exit EndFunc
  15. Try this line: RunWait(@ComSpec & " /c " & "Rd /S /Q c:\testdir","",@SW_HIDE)
  16. look here: http://www.autoitscript.com/forum/index.ph...mp;#entry253174 or here: http://www.autoitscript.com/forum/index.php?showtopic=17581
  17. @Lar Thanks a lot !!! You are great in DLL Calls
  18. Thanks Larry, can you help with the DLLCall ?
  19. is it possible to read the MSI Productcode with dllcall from MSI File ??
  20. Maybe this is a solution for you http://www.serverwatch.com/tutorials/article.php/1548421
  21. Hi i found this in the forum AdlibEnable("Mem") MsgBox(0, "Started", @ScriptName & " has started.... F12 = Monitor off, F11 = Monitor on, Esc = Exit Program.") Opt ("WinTitleMatchMode", 4) While 1 Sleep(10) If _IsPressed(0x1B) Then $hwnd = WinGetHandle('classname=Progman') DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', $hwnd, 'int', 274, 'int', 61808, 'int', -1) MsgBox(0, "Closing...", "Closing program.....") Exit ElseIf _IsPressed(0x7A) Then $hwnd = WinGetHandle('classname=Progman') DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', $hwnd, 'int', 274, 'int', 61808, 'int', -1) Sleep(10) ElseIf _IsPressed(0x7B) Then $hwnd = WinGetHandle('classname=Progman') Sleep(500) DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', $hwnd, 'int', 274, 'int', 61808, 'int', 2) Sleep(10) EndIf Sleep(20) WEnd Func _IsPressed($hexKey) Global $aR, $bRv $dll = DllOpen("user32.dll") $aR = DllCall($dll, "int", "GetAsyncKeyState", "int", $hexKey) DllClose($dll) If $aR[0] <> 0 Then $bRv = 1 Else $bRv = 0 EndIf Return $bRv EndFunc;==>_IsPressed Func Mem() Local $aHandle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', False, 'int', -1), $aReturn = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $aHandle[0]) DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $aHandle[0]) Return $aReturn[0] EndFunc;==>Mem
  22. Very Cool I like it !! Where is the autoit code ?
  23. may be the settings @ power option are diffrent ?!? I use this on my notebook and it works ! Hibernate is deactivated on my Notebook
  24. you must call the function first ! ;Standby like this SetSuspend() Func SetSuspend($mode=true,$force=true) $result = DllCall("PowrProf.dll", "long", "SetSuspendState", "long",$mode, "long",$force, "long", false) EndFunc for me (XP system) it works ! Compile it and start it
  25. ;Standby like this SetSuspend() Func SetSuspend($mode=true,$force=true) $result = DllCall("PowrProf.dll", "long", "SetSuspendState", "long",$mode, "long",$force, "long", false) EndFunc
×
×
  • Create New...