RunAS

  • Hallo zusammen :)

    wie bekommt man den im RunAs übergegeben Benutzer wieder los?

    habe hier ein Script, welches bei jedem start eine update.exe ausführt
    in dieser update.exe ist der RunAs befehl eingebaut und startet bei vorhanden sein, eines updates einen kopiervorgang und beendet das vorherige script, danach wird das eigentliche script wieder getstartet!

    hier gibt es die probleme, das der user "@username", dann nicht mehr erkannt wird, sonder der von RunAs genommen wird!

    Tool

    Spoiler anzeigen
    [autoit]


    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_icon=..\..\Vista Icon Pack ST\Applications\App061.ico
    #AutoIt3Wrapper_outfile=CallCenterErfassungsbogen_1.0.7.exe
    #AutoIt3Wrapper_Res_Description=Erfassungsbogen
    #AutoIt3Wrapper_Res_Fileversion=3.0.1.7
    #AutoIt3Wrapper_Res_Language=1031
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

    [/autoit] [autoit][/autoit] [autoit]

    #include <GuiStatusBar.au3>
    #include <File.au3>
    #include <GUIConstants.au3>
    #Include <Array.au3>
    #include <adfunctions.au3>
    #include <Date.au3>
    #include <GUIListBox.au3>
    #Include <GuiComboBox.au3>

    [/autoit] [autoit][/autoit] [autoit]

    DIM $Input7, $Input8 , $Input9, $Input10, $Input11, $Input12, $Input13, $Input14, $Input15
    DIM $Label10, $Label11, $Label12, $Label13, $Label14, $Label15, $Label16, $Label17, $Label18
    DIM $Group3

    [/autoit] [autoit][/autoit] [autoit]

    $mail = _ADGetObjectAttribute(@UserName,"mail")
    $muser = @UserName

    [/autoit] [autoit][/autoit] [autoit]

    $file = (@ScriptDir & "\portale.txt")
    Dim $aRecords
    Dim $sString
    If Not _FileReadToArray($file,$aRecords) Then
    MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    For $x = 1 to $aRecords[0]
    ; Msgbox(0,'Record:' & $x, $aRecords[$x])
    ;Next

    [/autoit] [autoit][/autoit] [autoit]

    $sString &= $aRecords[$x]
    Next
    ;MsgBox(0,"", $sString)

    [/autoit] [autoit][/autoit] [autoit]

    $DATAC1 = "Angebot|Rückfrage|Stornierung|Umbuchung|RSB Buchung"
    $DATAC2 = $sString

    [/autoit] [autoit][/autoit] [autoit]

    ;===========================================
    ; database
    ;===========================================
    $dbn = @ScriptDir & "\portale.mdb"

    [/autoit] [autoit][/autoit] [autoit]

    ;===========================================
    ; table portale
    ;===========================================
    $tbln_1 = "portale"
    ;$fldname_tbl1_0 = "pr" ;bla
    ;$format = "Text(150)"
    $fldn_tbl1_1 = "projekt" ;bla
    $format = "Text(150)"
    $fldn_tbl1_2 = "teilprojekt" ;bla
    $format = "Text(200)"
    $fldn_tbl1_3 = "mail" ;bla
    $format = "Text(150)"

    [/autoit] [autoit][/autoit] [autoit]

    ;===========================================
    ; table mails
    ;===========================================

    [/autoit] [autoit][/autoit] [autoit]

    $tbln_2 = "mails"

    [/autoit] [autoit][/autoit] [autoit]

    $fldn_tbl2_1 = "teilprojekt" ;bla
    $format = "Text(150)"
    $fldn_tbl2_2 = "mail" ;bla
    $format = "Text(150)"

    [/autoit] [autoit][/autoit] [autoit]

    $query = "SELECT * FROM "& $tbln_1
    $strData = _ReadOneFld($query, $dbn, $fldn_tbl1_1) ; db auslesen
    ;MsgBox(0,"",$strData)
    $E1 = StringStripWS($strData,3)

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=C:\Erfassungsbogen\Form1.kxf
    $erfbo = GUICreate("Erfassungsbogen 3.0.1.7", 740, 530, 219, 137)
    GUISetBkColor(0x00708090) ; setzt hintergrundfarbe
    ;$Label1 = GUICtrlCreateLabel("Portal", 16, 16, 39, 20)
    ;GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Anrufgrund", 16, 44, 120, 20)
    GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label2 = GUICtrlCreateLabel("Vorname, Name", 16, 68, 120, 20)
    GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label4 = GUICtrlCreateLabel("Telefon", 16, 92, 120, 20)
    GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label5 = GUICtrlCreateLabel("E-Mail", 16, 114, 120, 20)
    GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label6 = GUICtrlCreateLabel("Veranstalter", 16, 136, 120, 20)
    GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label7 = GUICtrlCreateLabel("Vorgang", 16, 160, 120, 20)
    GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label8 = GUICtrlCreateLabel("Fakten", 16, 184, 120, 20)
    GUICtrlSetFont(-1, 10, 600, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFFFFFF)
    ;$Input1 = GUICtrlCreateInput("", 136, 16, 249, 21)
    $Combo1 = GUICtrlCreateCombo(" ... Bitte auswählen", 145, 40, 240, 25 )
    GUICtrlSetData(-1, $DATAC1, " ... Bitte auswählen")
    $Input2 = GUICtrlCreateInput("", 145, 64, 240, 21)
    $Input3 = GUICtrlCreateInput("", 145, 88, 240, 21)
    $Input4 = GUICtrlCreateInput("", 145, 112, 240, 21)
    $Input5 = GUICtrlCreateInput("", 145, 136, 240, 21)
    $Input6 = GUICtrlCreateInput("", 145, 160, 240, 21)
    $Edit2 = GUICtrlCreateEdit("", 145, 184, 240, 81)
    GUICtrlSetData(-1, "")
    $Group2 = GUICtrlCreateGroup("ITYX", 16, 272, 497, 249)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFFFFFF)

    [/autoit] [autoit][/autoit] [autoit]

    ;DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
    ; Local $group = GUICtrlCreateGroup("Group 1", 190, 60, 90, 140)
    ; GUICtrlSetColor(-1,0x0000FF)
    ;DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 1)

    [/autoit] [autoit][/autoit] [autoit]

    $List1 = GUICtrlCreateList("", 32, 296, 249, 214)
    GUICtrlSetData(-1, $DATAC2)
    $List2 = GUICtrlCreateList("", 296, 296, 201, 214)
    GUICtrlSetData(-1, "")
    $Button1 = GUICtrlCreateButton("Löschen", 584, 392, 97, 25, 0)
    GUICtrlSetBkColor(-1,0xff4D00)
    $Button2 = GUICtrlCreateButton("Senden", 584, 432, 97, 25, 0)
    GUICtrlSetBkColor(-1,0x66CC00)
    $Label9 = GUICtrlCreateLabel("mail gesendet!", 600, 480, 104, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetState(-1, $GUI_HIDE)
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
    $Checkbox1 = GUICtrlCreateCheckbox("Dringend", 600, 360, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 7)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    Sleep(2000)

    [/autoit] [autoit][/autoit] [autoit]

    Run(@ScriptDir & "\updater.exe") ; run updater.exe

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $List1

    [/autoit] [autoit][/autoit] [autoit]

    ;~ If GUICtrlRead($List1) = "abocard" Then
    ;~ GUICtrlSetData($List2, "")
    ;~ GUICtrlSetData($List2, "A1|A3|A3")
    ;~ EndIf
    ;If GUICtrlRead($List1) = "abocard" Then GUICtrlSetData($List2, $DATAC2)

    [/autoit] [autoit][/autoit] [autoit]

    $wert1 = GUICtrlRead($List1)
    $query1 = "SELECT * FROM "& $tbln_1 & " WHERE projekt = " & "'" & $wert1 & "'"
    $strData1 = _ReadOneFld($query1, $dbn, $fldn_tbl1_2) ; db auslesen

    [/autoit] [autoit][/autoit] [autoit]

    ;MsgBox(64,"", StringStripWS($strData1,3)) ;leerzeichen abschneiden
    ;MsgBox(0,"",$strData1)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetData($List2, "")
    GUICtrlSetData($List2, StringStripWS($strData1,3))

    [/autoit] [autoit][/autoit] [autoit]

    Case $Button2

    [/autoit] [autoit][/autoit] [autoit]

    $wert2 = GUICtrlRead($List2)
    $query2 = "SELECT * FROM "& $tbln_2 & " WHERE teilprojekt = " & "'" & $wert2 & "'"
    $strData2 = _ReadOneFld($query2, $dbn, $fldn_tbl2_2) ; db auslesen

    [/autoit] [autoit][/autoit] [autoit]

    $portal = GUICtrlRead($List1)
    $teilp = GUICtrlRead($List2)
    $name = GUICtrlRead($Input2)
    $tel = GUICtrlRead($Input3)
    $tmail = GUICtrlRead($Input4)
    $ver = GUICtrlRead($Input5)
    $vor = GUICtrlRead($Input6)
    $fakt = GUICtrlRead($Edit2)
    $gda = GUICtrlRead($Combo1)
    ;--------------------------
    $i1 = GUICtrlRead($Input7)
    $i2 = GUICtrlRead($Input8)
    $i3 = GUICtrlRead($Input9)
    $i4 = GUICtrlRead($Input10)
    $i5 = GUICtrlRead($Input11)
    $i6 = GUICtrlRead($Input12)
    $i7 = GUICtrlRead($Input13)
    $i8 = GUICtrlRead($Input14)
    $i9 = GUICtrlRead($Input15)
    ;--------------------------
    $cb1 = GUICtrlRead($Checkbox1)
    ;MsgBox(0,"",$cb1 & "checked")
    If $cb1 = 1 Then $cbtext = "Dringend"
    If $cb1 = 4 Then $cbtext = ""

    [/autoit] [autoit][/autoit] [autoit]

    $date = _Now()
    $sp = "-----------------------------------------"
    $sp1 = "#########################################"
    ;--------------------subjekt-------------------
    $sb = "Erfassungsbogen " & $portal & " / " & $teilp & " / " & $cbtext
    ;----------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    ;-------------------mail body------------------
    $mbody1 = $sp1 & @CRLF & $date & @CRLF & $sp1 & @CRLF & "Portal: " & $portal & @CRLF & $sp & @CRLF & "Vorname, Name: " & $name & @CRLF & $sp & @CRLF & "Telefon: " & $tel & @CRLF & $sp & @CRLF & "Mail: " & $tmail & @CRLF & $sp & @CRLF & "Veranstalter: " & $ver & @CRLF & $sp & @CRLF & "Vorgang: " & $vor & @CRLF & $sp & @CRLF & "Fakten: " & @CRLF & @CRLF & $fakt & @CRLF & @CRLF
    ;----------------------------------------------
    $mbody_angebot = $gda & @CRLF & $sp1 & @CRLF & "Erwachsene: " & $i1 & @CRLF & $sp & @CRLF & "Kinder: " & $i2 & @CRLF & $sp & @CRLF & "Reiseziel: " & $i3 & @CRLF & $sp & @CRLF & "1. Flughafen: " & $i4 & @CRLF & $sp & @CRLF & "2. Flughafen: " & $i5 & @CRLF & $sp & @CRLF & "Verpflegung: " & $i6 & @CRLF & $sp & @CRLF & "Zimmer: " & $i7
    ;----------------------------------------------
    $mbody_umbuchung = $gda & @CRLF & $sp1 & @CRLF & "Hotel: " & $i1 & @CRLF & $sp & @CRLF & "Zimmer: " & $i2 & @CRLF & $sp & @CRLF & "Verpflegung: " & $i3 & @CRLF & $sp & @CRLF & "Termin: " & $i4 & @CRLF & $sp & @CRLF & "Flughafen: " & $i5 & @CRLF & $sp & @CRLF & "Dauer: " & $i6 & @CRLF & $sp & @CRLF & "Personen: " & $i7 & @CRLF & $sp & @CRLF & "Reiseziel: " & $i8 & @CRLF & $sp & @CRLF & "Zimmer: " & $i9
    ;----------------------------------------------
    $mbody_rsbbuchung = $gda & @CRLF & $sp1 & @CRLF & "Agenturnummer: " & $i1 & @CRLF & $sp & @CRLF & "Telefonnummer: " & $i2
    ;----------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    ;MsgBox(0,"",$mbody)

    [/autoit] [autoit][/autoit] [autoit]

    If $gda = " ... Bitte auswählen" Then
    MsgBox(0,"Info","Bitte Grund des Anrufes auswählen!")
    Else
    If $portal = "" Then ; MsgBox(0,"",$portal)
    MsgBox(0,"Info","Bitte Projekt auswählen!")
    Else
    If $teilp = "" Then ; MsgBox(0,"",$portal)
    MsgBox(0,"Info","Bitte Teilprojekt auswählen!")
    Else

    [/autoit] [autoit][/autoit] [autoit]

    BlockInput (1)

    [/autoit] [autoit][/autoit] [autoit]

    Sendmail()
    GUICtrlSetState($Button2, $GUI_DISABLE)
    _GUICtrlListBox_ResetContent($List1)
    GUICtrlSetData($List1, $DATAC2)
    _GUICtrlListBox_ResetContent($List2)
    BlockInput (0)
    Sleep (3000)
    GUICtrlSetState($Label9, $GUI_SHOW)
    ;MsgBox(64,"","Mail gesendet",3)
    Sleep (8000) ;8 sekunden
    GUICtrlSetState($Label9, $GUI_HIDE)
    GUICtrlSetState($Button2, $GUI_ENABLE)

    [/autoit] [autoit][/autoit] [autoit]

    EndIf
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Case $Button1 ;löschen

    [/autoit] [autoit][/autoit] [autoit]

    _Del()
    GUICtrlSetData($Input2, "")
    GUICtrlSetData($Input3, "")
    GUICtrlSetData($Input4, "")
    GUICtrlSetData($Input5, "")
    GUICtrlSetData($Input6, "")
    GUICtrlSetData($Edit2, "")

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlDelete($Combo1)
    $Combo1 = GUICtrlCreateCombo(" ... Bitte auswählen", 145, 40, 240, 25 )
    GUICtrlSetData(-1, $DATAC1, " ... Bitte auswählen")

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlListBox_ResetContent($List1)
    GUICtrlSetData($List1, $DATAC2)
    _GUICtrlListBox_ResetContent($List2)

    [/autoit] [autoit][/autoit] [autoit]

    ControlCommand("","Dringend",$Checkbox1, "UnCheck", "") ;checkbox unchecked

    [/autoit] [autoit][/autoit] [autoit]

    Case $Combo1

    [/autoit] [autoit][/autoit] [autoit]

    $gda = GUICtrlRead($Combo1)

    [/autoit] [autoit][/autoit] [autoit]

    ;MsgBox(0,"",$gda)
    IF $gda = " ... Bitte auswählen" Then _Del()
    IF $gda = "Angebot" Then _AngebotShow()
    IF $gda = "Rückfrage" Then _Del()
    IF $gda = "Stornierung" Then _Del()
    IF $gda = "Umbuchung" Then _UmbuchungShow()
    IF $gda = "RSB Buchung" Then _RSBBuchungShow()

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func Sendmail()

    [/autoit] [autoit][/autoit] [autoit]

    Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc_1")
    ;##################################
    ; Variables
    ;##################################
    $s_SmtpServer = "0.0.0.0" ; address for the smtp-server to use - REQUIRED
    $s_FromName = $muser ; name from who the email was sent
    $s_FromAddress = $mail ; address from where the mail should come
    $s_ToAddress = $strData2 ; destination address of the email - REQUIRED
    $s_Subject = $sb ; subject from the email - can be anything you want it to be
    ;$as_Body = $mbody1 ; the messagebody from the mail - can be left blank but then you get a blank mail
    IF $gda = "Stornierung" Then $as_Body = $mbody1
    IF $gda = "Rückfrage" Then $as_Body = $mbody1
    If $gda = "Angebot" Then $as_Body = $mbody1 & @CRLF & $sp1 & @CRLF & $mbody_angebot
    If $gda = "Umbuchung" Then $as_Body = $mbody1 & @CRLF & $sp1 & @CRLF & $mbody_umbuchung
    If $gda = "RSB Buchung" Then $as_Body = $mbody1 & @CRLF & $sp1 & @CRLF & $mbody_rsbbuchung
    $s_AttachFiles = "" ; the file you want to attach- leave blank if not needed
    $s_CcAddress = "" ; address for cc - leave blank if not needed
    $s_BccAddress = "" ; address for bcc - leave blank if not needed
    $s_Username = "xxxl" ; username for the account used from where the mail gets sent - Optional (Needed for eg GMail)
    $s_Password = "xxxxxxx" ; password for the account used from where the mail gets sent - Optional (Needed for eg GMail)
    $IPPort = 25 ; port used for sending the mail
    $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS
    ;~ $IPPort=465 ; GMAIL port used for sending the mail
    ;~ $ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS

    [/autoit] [autoit][/autoit] [autoit]

    ;##################################
    ; Script
    ;##################################
    Global $oMyRet[2]
    Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc_1")
    $rc = _INetSmtpMailCom_1($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)
    If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>Sendmail

    [/autoit] [autoit][/autoit] [autoit]

    ;###################################################

    [/autoit] [autoit][/autoit] [autoit]

    Func _INetSmtpMailCom_1($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "",$IPPort=25, $ssl=0)
    $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body,"<") and StringInStr($as_Body,">") Then
    $objEmail.HTMLBody = $as_Body
    Else
    $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
    Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
    For $x = 1 To $S_Files2Attach[0]
    $S_Files2Attach[$x] = _PathFull ($S_Files2Attach[$x])
    If FileExists($S_Files2Attach[$x]) Then
    $objEmail.AddAttachment ($S_Files2Attach[$x])
    Else
    $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x]
    SetError(1)
    return 0
    EndIf
    Next
    EndIf
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
    ;Authenticated SMTP
    If $s_Username <> "" Then
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $Ssl Then
    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
    ;Update settings
    $objEmail.Configuration.Fields.Update
    ; Sent the Message
    $objEmail.Send
    If @error Then
    SetError(2)
    return $oMyRet[1]
    EndIf
    EndFunc ;==>_INetSmtpMailCom
    ;
    ;
    ; Com Error Handler
    Func MyErrFunc_1()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description,3)
    ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
    EndFunc ;==>MyErrFunc_1

    [/autoit] [autoit][/autoit] [autoit]

    ;###################################################

    [/autoit] [autoit][/autoit] [autoit]

    Func _ReadOneFld($_sql, $_dbname, $_field)
    Dim $_output
    $adoCon = ObjCreate ("ADODB.Connection")
    $adoCon.Open ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $_dbname)
    $adoRs = ObjCreate ("ADODB.Recordset")
    $adoRs.CursorType = 1
    $adoRs.LockType = 3
    $adoRs.Open ($_sql, $adoCon)

    [/autoit] [autoit][/autoit] [autoit]

    With $adoRs
    If .RecordCount Then
    While Not .EOF
    $_output = $_output & .Fields ($_field).Value & @CRLF
    .MoveNext
    WEnd
    EndIf
    EndWith
    $adoCon.Close
    Return $_output
    EndFunc ;==>_ReadOneFld

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _AngebotShow()

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlDelete($Group3)
    GUICtrlDelete($Input7)
    GUICtrlDelete($Input8)
    GUICtrlDelete($Input9)
    GUICtrlDelete($Input10)
    GUICtrlDelete($Input11)
    GUICtrlDelete($Input12)
    GUICtrlDelete($Input13)
    GUICtrlDelete($Input14)
    GUICtrlDelete($Input15)
    ;----------------------
    GUICtrlDelete($Label10)
    GUICtrlDelete($Label11)
    GUICtrlDelete($Label12)
    GUICtrlDelete($Label13)
    GUICtrlDelete($Label14)
    GUICtrlDelete($Label15)
    GUICtrlDelete($Label16)
    GUICtrlDelete($Label17)
    GUICtrlDelete($Label18)
    ;----------------------
    $Group3 = GUICtrlCreateGroup("Angebot", 400, 16, 321, 249)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label10 = GUICtrlCreateLabel("Erwachsene", 416, 48, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label11 = GUICtrlCreateLabel("Kinder", 416, 72, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label12 = GUICtrlCreateLabel("Reiseziel", 416, 96, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label13 = GUICtrlCreateLabel("1. Flughafen", 416, 120, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label14 = GUICtrlCreateLabel("2. Flughafen", 416, 144, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label15 = GUICtrlCreateLabel("Verpflegung", 416, 168, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label16 = GUICtrlCreateLabel("Zimmer", 416, 192, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Input7 = GUICtrlCreateInput("", 510, 48, 195, 21)
    $Input8 = GUICtrlCreateInput("", 510, 72, 195, 21)
    $Input9 = GUICtrlCreateInput("", 510, 96, 195, 21)
    $Input10 = GUICtrlCreateInput("", 510, 120, 195, 21)
    $Input11 = GUICtrlCreateInput("", 510, 144, 195, 21)
    $Input12 = GUICtrlCreateInput("", 510, 168, 195, 21)
    $Input13 = GUICtrlCreateInput("", 510, 192, 195, 21)
    ;GUICtrlSetTip($Input13, "test")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _UmbuchungShow()

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlDelete($Group3)
    GUICtrlDelete($Input7)
    GUICtrlDelete($Input8)
    GUICtrlDelete($Input9)
    GUICtrlDelete($Input10)
    GUICtrlDelete($Input11)
    GUICtrlDelete($Input12)
    GUICtrlDelete($Input13)
    GUICtrlDelete($Input14)
    GUICtrlDelete($Input15)
    ;----------------------
    GUICtrlDelete($Label10)
    GUICtrlDelete($Label11)
    GUICtrlDelete($Label12)
    GUICtrlDelete($Label13)
    GUICtrlDelete($Label14)
    GUICtrlDelete($Label15)
    GUICtrlDelete($Label16)
    GUICtrlDelete($Label17)
    GUICtrlDelete($Label18)
    ;----------------------
    $Group3 = GUICtrlCreateGroup("Umbuchung", 400, 16, 321, 258)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    $Label10 = GUICtrlCreateLabel("Hotel", 416, 48, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label11 = GUICtrlCreateLabel("Zimmer", 416, 72, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label12 = GUICtrlCreateLabel("Verpflegung", 416, 96, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label13 = GUICtrlCreateLabel("Termin", 416, 120, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label14 = GUICtrlCreateLabel("Flughafen", 416, 144, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label15 = GUICtrlCreateLabel("Dauer", 416, 168, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label16 = GUICtrlCreateLabel("Personen", 416, 192, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label17 = GUICtrlCreateLabel("Reiseziel", 416, 216, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label18 = GUICtrlCreateLabel("Zimmer", 416, 240, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    ;----------------------
    $Input7 = GUICtrlCreateInput("", 510, 48, 195, 21)
    $Input8 = GUICtrlCreateInput("", 510, 72, 195, 21)
    $Input9 = GUICtrlCreateInput("", 510, 96, 195, 21)
    $Input10 = GUICtrlCreateInput("", 510, 120, 195, 21)
    $Input11 = GUICtrlCreateInput("", 510, 144, 195, 21)
    $Input12 = GUICtrlCreateInput("", 510, 168, 195, 21)
    $Input13 = GUICtrlCreateInput("", 510, 192, 195, 21)
    $Input14 = GUICtrlCreateInput("", 510, 216, 195, 21)
    $Input15 = GUICtrlCreateInput("", 510, 240, 195, 21)

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _RSBBuchungShow()

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlDelete($Group3)
    GUICtrlDelete($Input7)
    GUICtrlDelete($Input8)
    GUICtrlDelete($Input9)
    GUICtrlDelete($Input10)
    GUICtrlDelete($Input11)
    GUICtrlDelete($Input12)
    GUICtrlDelete($Input13)
    GUICtrlDelete($Input14)
    GUICtrlDelete($Input15)
    ;----------------------
    GUICtrlDelete($Label10)
    GUICtrlDelete($Label11)
    GUICtrlDelete($Label12)
    GUICtrlDelete($Label13)
    GUICtrlDelete($Label14)
    GUICtrlDelete($Label15)
    GUICtrlDelete($Label16)
    GUICtrlDelete($Label17)
    GUICtrlDelete($Label18)
    ;----------------------
    $Group3 = GUICtrlCreateGroup("RSB Buchung", 400, 16, 321, 249)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label10 = GUICtrlCreateLabel("Agentur", 416, 48, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    $Label11 = GUICtrlCreateLabel("Telefon", 416, 72, 90, 17)
    GUICtrlSetColor(-1, 0xFFFFFF)
    ;----------------------
    $Input7 = GUICtrlCreateInput("", 510, 48, 195, 21)
    GUICtrlSetTip(-1, "Agenturnummer")
    $Input8 = GUICtrlCreateInput("", 510, 72, 195, 21)
    GUICtrlSetTip(-1, "Telefonnummer")

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _Del()

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlDelete($Group3)
    GUICtrlDelete($Input7)
    GUICtrlDelete($Input8)
    GUICtrlDelete($Input9)
    GUICtrlDelete($Input10)
    GUICtrlDelete($Input11)
    GUICtrlDelete($Input12)
    GUICtrlDelete($Input13)
    GUICtrlDelete($Input14)
    GUICtrlDelete($Input15)
    ;----------------------
    GUICtrlDelete($Label10)
    GUICtrlDelete($Label11)
    GUICtrlDelete($Label12)
    GUICtrlDelete($Label13)
    GUICtrlDelete($Label14)
    GUICtrlDelete($Label15)
    GUICtrlDelete($Label16)
    GUICtrlDelete($Label17)
    GUICtrlDelete($Label18)

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit]


    Updater

    Spoiler anzeigen
    [autoit]


    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_icon=..\..\Vista Icon Pack ST\Signs\Sign012.ico
    #AutoIt3Wrapper_outfile=Updater.exe
    #AutoIt3Wrapper_Res_Fileversion=1.0.0.0
    #AutoIt3Wrapper_Res_Language=1031
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #Include <Misc.au3>
    #include <File.au3>
    #include <Process.au3>
    #include <String.au3>

    [/autoit] [autoit][/autoit] [autoit]

    If Not IsAdmin() Then
    ; Bis Version 3.2.10.0
    ;~ RRunAsSet("user", @LogonDomain, "xxxxxxx")
    ;~ Run(@ScriptFullPath, @ScriptDir, @SW_HIDE)
    ;~ RunAsSet()
    ; AB Version 3.2.12.0
    RunAs("adminuser", @LogonDomain, "xxxxxxxxx", 0, @ScriptFullPath, @ScriptDir, @SW_HIDE)
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    If IsAdmin() Then
    ;MsgBox(0, "", "Admin-Rechte erkannt.",1)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;updater 11.06.2009 versionsvergleich
    $path1 = "\\server\netlogon\ErfassungsbogenUpdate\"
    $path2 = "C:\Tools\Erfassungsbogen\"

    [/autoit] [autoit][/autoit] [autoit]

    $file = "CallCenterErfassungsbogen.exe"
    $file1 = "portale.mdb"
    $file2 = "portale.txt"

    [/autoit] [autoit][/autoit] [autoit]

    $sVersion1 = $path1 & $file
    $sVersion2 = $path2 & $file

    [/autoit] [autoit][/autoit] [autoit]

    $quelle = $path1 & $file
    $quelle1 = $path1 & $file1
    $quelle2 = $path1 & $file2

    [/autoit] [autoit][/autoit] [autoit]

    $ziel = $path2

    [/autoit] [autoit][/autoit] [autoit]

    $ver1 = FileGetVersion($sVersion1) ;server
    $ver2 = FileGetVersion($sVersion2) ;local

    [/autoit] [autoit][/autoit] [autoit]

    ;MsgBox(0, "Explorer version", $ver1 & " / " & $ver2)

    [/autoit] [autoit][/autoit] [autoit]

    IF $ver1 > $ver2 Then
    MsgBox(0,"","Update vorhanden!",1)

    [/autoit] [autoit][/autoit] [autoit]

    ;If WinExists("Erfassungsbogen") Then

    [/autoit] [autoit][/autoit] [autoit]

    ;MsgBox(0, "", "Window exists",1)
    WinWaitNotActive("Erfassungsbogen", "", 5)
    WinKill("Erfassungsbogen", "")

    [/autoit] [autoit][/autoit] [autoit]

    ;EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;WinClose("Erfassungsbogen", "")
    ;Wait a maximum of 5 seconds for "Untitled" to not exist
    ;WinWaitClose("Erfassungsbogen", "", 5)
    ;Sleep(2000)

    [/autoit] [autoit][/autoit] [autoit]

    $SourceFile1 = "Bitte warten ... Update wird durchgeführt!"
    $SourceFile2 = "Programm startet danach automatisch ...."
    $DestinationFile1 = ""
    _ProgressCopy()

    [/autoit] [autoit][/autoit] [autoit]

    ;_copy($quelle,$ziel)
    ;_copy($quelle1,$ziel)
    ;_copy($quelle2,$ziel)

    [/autoit] [autoit][/autoit] [autoit]

    ;MsgBox(0,"", "update erfolgt",1)
    Sleep(1000)

    [/autoit] [autoit][/autoit] [autoit]

    Run($sVersion2, "", @SW_MAXIMIZE)
    Exit
    Else
    MsgBox(0,"","kein Update vorhanden!",1)
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ProgressCopy()

    [/autoit] [autoit][/autoit] [autoit]

    #region------------------------------------Declare Variables-------------------------------
    Local $ByteBlock, $Counter
    Local Const $BlockSize = 99
    Local Const $Opt = Opt("GUIOnEventMode", 0)
    #endregion---------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    #region------------------------------------GUI create--------------------------------------
    Local $GUI = GUICreate('', 400, 90, Default, Default, 0x80880000)
    Local $Label1 = GUICtrlCreateLabel($SourceFile1, 8, 8)
    ;Local $Label2 = GUICtrlCreateLabel($DestinationFile1, 8, 30)
    Local $Label3 = GUICtrlCreateLabel("0%", 360, 12, 30, 20, 0x2)
    ;Local $Button = GUICtrlCreateButton("Abbrechen", 160, 75, 80)
    Local $PBar = GUICtrlCreateProgress(8, 35, 384, 20)
    Local $Label2 = GUICtrlCreateLabel($SourceFile2, 8, 65)
    GUISetState()
    #endregion---------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    _copy($quelle,$ziel)
    _copy($quelle1,$ziel)
    _copy($quelle2,$ziel)

    [/autoit] [autoit][/autoit] [autoit]

    #region----------------------------------Copy File-----------------------------------------
    Do
    $ByteBlock = $BlockSize
    If @error Then ExitLoop
    $Counter += 1
    GUICtrlSetData($PBar, $Counter)
    GUICtrlSetData($Label3, $Counter & ' %')

    [/autoit] [autoit][/autoit] [autoit]

    If $Counter = 100 Then ExitLoop ;GUIDelete($GUI)

    [/autoit] [autoit][/autoit] [autoit]

    ;If GUIGetMsg() = $Button Then EXIT
    ;~ Opt("GUIOnEventMode", $Opt)
    ;~ GUIDelete($GUI)
    ;~ Return SetError(4,4,0)
    ;~ EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Sleep(10) ;Bremse - Auskommentieren für maximale Geschwindigkeit

    [/autoit] [autoit][/autoit] [autoit]

    Until 0
    #endregion---------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", $Opt)
    GUIDelete($GUI)
    Return 1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;---functions----

    [/autoit] [autoit][/autoit] [autoit]

    Func _copy($fromFile, $tofile)
    Local $FOF_RESPOND_YES = 16
    Local $FOF_SIMPLEPROGRESS = 256
    $winShell = ObjCreate("shell.application")
    $winShell.namespace ($tofile).CopyHere ($fromFile, $FOF_RESPOND_YES)
    If @error Then
    MsgBox(0, "", "the previous line got an error.")
    EndIf
    EndFunc ;==>copy

    [/autoit]

    hat einer eine idee bzw. lösung?
    hab mal beide quelltexte angehangen!

    gruß gmmg

  • Hi,

    habe Deinen Code mal grob überflogen. Im ersten Ansatz vermute ich, dass Dein Problem nur dann auftaucht, wenn der User kein Admin ist und ein Update vorliegt. Wenn dem so sein sollte, ist Deine Programmablauflogik nicht ganz richtig.

    Es scheint meiner Meinung nach zu sein, dass durch Deinen RunAs Aufruf die updater.exe mit Admin Rechten ausgeführt wird. Im Falle eines Updates, rufst Du dann mit Run($sVersion2, "", @SW_MAXIMIZE) Deine neue Version auf. Dieses geschieht natürlich im RunAs Context. 

    Wenn ich richtig liegen sollte, musst Du Deinen Ablauf überlegen und neu gestalten. Falls nicht, liegt der Fehler woanders. 

    ;-))

    Stefan

  • hallo ojo,

    danke dir erstmal ...

    wir sind darauf aufmerksam geworden, weil das tool ja ne mail verschickt und die unter faschem absendernamen (dem in RunAs übergegeben) angekommen war!
    du hast vollkommen recht, dass der updater dann im kontext als user mit admin rechten die neue version aufruft!
    wie bekommt man denn, den über RunAS übergebenen user wieder los? früher gabs ja mal die RunAs()
    oder liege ich falsch, das jedes weitere programm dann mit diesen rechten ausgeführt werden!

    hab es jetzt vorübergehend ohne start der neuen version umgebaut, aber das sollte nicht meine endgültige lösung sein :)

    gruß
    gmmg

  • Hi,

    1) Du kopierst doch nur Files, soweit ich das in Erinnerung habe. Also müsste meiner Meinung nach, Lesen Recht auf dem Update Source und Ändern Recht auf dem lokalen Source für die Benutzer reichen. Damit würde Dein RunAs wegfallen.

    2) Wenn kein Ändern Recht für den User auf dem lokalen Source gewünscht ist, brauchst Du für Deine Logik ein Steuerprogramm:

    a) Starte Update gffs. mit RunAsWait() ( die update Version ohne Start der neuen Version )

    b) Starte neue Version / Version

    Code mässig sieht das dann grob so aus:

    RunAsWait ("Update.exe")

    Run ("Neue Version")

    3) Dein Ablauf sieht ungefähr so aus, sowie ich das verstanden habe:

    a) Starte Version

    b) Starte Update, gffs. mit erneut mit Admin Rechten

    - wenn neue Version, dann schliesse Version, führe Update durch und starte neue Version

    Und da liegt der Hund begraben............

    Ich hoffe ich habe das einigermassen verständlich ausgerückt.

    ;-))

    Stefan

    2 Mal editiert, zuletzt von ojo (17. Juni 2009 um 15:57)

  • hi stefan,

    nein, das programm wird per gruppenrichtlinie verpackt in einem msi auf alle pc's verteilt! da stimmen die rechte nicht!
    das ist auch ne gute idee mit dem steuerprogramm :)
    würde das dann aber so machen:

    [autoit]


    --> hauptprogramm starten
    --> prüfen ob update
    --> wenn nein --> macht nichts
    --> wenn ja
    --> steuerprogramm starten
    --> hauptprogramm schließen
    --> updater.exe mit RunAsWait() aus dem steuerprogramm starten, nach update beenden

    --> steuerprogramm startet danach hauptprogramm

    [/autoit]

    so könnte doch der ablauf funktionieren oder?

    gruß gmmg

  • Jup, auch ich würde den Updater zweistufig machen, dabei aber alles in einem Skript lassen:

    Spoiler anzeigen
    [autoit]

    Global Const $Error_None = 0
    Global Const $Error_RunAdmin = -45
    If $CMDLINE[0]>0 And $CMDLINE[1] = "-child" Then ; Wenn der Prozess mit dem Parameter "-child" gestartet wird, nur das update und nicht den Rest ausführen.
    If Not IsAdmin() Then Exit $Error_RunAdmin
    _Updaten(True)
    Exit $Error_None ; Erfolg
    Else
    _ProgrammBeenden()
    Switch IsAdmin()
    Case True
    _Updaten()
    Case False
    Switch RunAsWait($ADMINUSER, $DOMAIN, $ADMINPASS, 0, '"' & @ScriptFullPath & '" -child', @ScriptDir, @SW_HIDE)
    ;Switch ShellExecuteWait(@AutoItExe, $CMDLINERAW & ' -child', @ScriptDir, "")
    Case $Error_None
    If @error Then
    ; Fehler beim Starten
    Else
    ; Erfolg
    EndIf
    Case $Error_RunAdmin
    MsgBox(0, '', "Konnte den Kopiervorgang nicht mit Adminrechten starten")
    Case Else
    MsgBox(0, '', "unbekannter Fehler")
    EndSwitch
    EndSwitch
    _ProgrammStarten()
    EndIf

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Updaten($NeuerProzess = False)
    MsgBox(0, '', "Update läuft als neuer Prozess: " & $NeuerProzess)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _ProgrammStarten()
    MsgBox(0, '', "Programm starten")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _ProgrammBeenden()
    MsgBox(0, '', "Programm beenden")
    EndFunc

    [/autoit]
  • @progandy

    du startest aber vom hauptprog den updater oder?

    ich probier das morgen mal auf arbeit :)
    wenn ich nochmal hilfe benötige, kann ich doch auf euch zurückkommen oder?

    danke vorerst

    gruß gmmg

  • @progandy

    hab deine version mal in den updater übernommen!
    am nachmittag läuft dann ein livetest auf 50 pc's.

    wenn alles klappt, poste ich meine version ....

    gruß gmmg