Janus Posted December 5, 2007 Posted December 5, 2007 Hallo I have a vbs that reg. a COM+ for a dll file. Help me translate this to autoit3 CODE' Arguments(0) : Pakke navn (bør altid hedde EposHR) ' Arguments(1) : Den fulde sti til den dll der skal gemmes som COM+ (med navn og drev- navn) ' Arguments(2) : Den fulde sti til der hvor dll- filen må ligge Dim packageName packageName = WScript.Arguments(0) 'First, we create the catalog object Dim catalog Set catalog = CreateObject("MTSAdmin.Catalog.1") 'Then we get the packages collection Dim packages Set packages = catalog.GetCollection("Packages") packages.populate Dim putil Set putil = packages.GetUtilInterface 'Remove all packages that go by the same name as the package we wish to uninstall numPackages = packages.Count For i = numPackages - 1 To 0 Step -1 If packages.Item(i).Value("Name") = packageName Then WScript.Echo("Stopper pakken: " & packageName )'& " ID " & packages.Item(i).Value("ID") & vbNewLine) putil.ShutdownPackage(packages.Item(i).Value("ID")) 'WScript.Echo("Shutdown done" &vbNewLine) WScript.Echo("Sletter objekter i pakken: " & packageName & vbNewLine) packages.Remove (i) 'WScript.Echo("Remove done" &vbNewLine &vbNewLine) ' Commit our deletions packages.savechanges exit for End If Next Set objFS = CreateObject("Scripting.FileSystemObject") objFs.copyfile "" & WScript.Arguments(1),WScript.Arguments(2) 'Uninstall complete 'Install package Dim newPackage Set newPackage = packages.Add newPackage.Value("Name") = packageName newPackage.Value("SecurityEnabled") = "N" newPackage.Value("ShutdownAfter") = "20" ' Commit new package packages.SaveChanges ' Refresh packages packages.Populate 'Get components collection for new package Dim components Set components = packages.GetCollection("ComponentsInPackage", newPackage.Value("ID")) ' Install components Dim util Set util = components.GetUtilInterface ' VB and VC WScript.Echo("Installerer: "& packageName & vbNewLine) 'WScript.Echo(newPackage.Value("ID") & vbNewLine) 'WScript.Echo(dllPath & vbNewLine) 'on error resume next util.InstallComponent WScript.Arguments(2), "", "" 'WScript.Echo(err.description):response.end 'if Error.err = "80110401" then WScript.Echo("Installed other place") components.SaveChanges components.Populate n = Components.Count components.SaveChanges WScript.Echo(n &" objekter blev installeret" &vbNewLine) 'response.redirect("install.asp?init=" & sInit & "&pack=" & packageName & "&dll=" & Server.URLEncode(Request("dll"))) I have a autoit3 script that use this here is my script expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.10.0 Author: Janus S. Andersen Script Function: 1. Åbner COM + registrings dialog 2. Forsøger at finde en komponet med navnet EposHR Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here Opt("SendKeyDelay", 50) ;5 milliseconds Opt("SendKeyDownDelay", 10) ;1 millisecond dim $x_1,$y_1 $x_1=@DesktopWidth/2 $y_1=20 ShellExecuteWait("TestInstallPackage","",@ScriptDir) ToolTip("Input data til komponet install", $x_1, $y_1) $user = InputBox("Indtast brugernavn", "Indtast brugernavn",""&@UserName) $password = InputBox("Indtast kodeord", "Indtast kodeord","","*") ToolTip("Starter program til komponet registringen", $x_1, $y_1) ShellExecute("C:\WINDOWS\system32\Com\comexp.msc", "", "C:\WINDOWS\system32\Com\") WinWait("[CLASS:MMCMainFrame]", "") WinActivate("[CLASS:MMCMainFrame]", "") WinSetState("[CLASS:MMCMainFrame]", "", @SW_MAXIMIZE) ToolTip("Finder COM +", $x_1, $y_1) Send("{DOWN}{RIGHT}") Sleep(1000) Send("{DOWN}{RIGHT}") Sleep(1000) Send("{DOWN}{RIGHT}") Sleep(1000) Send("{DOWN}{RIGHT}") Sleep(1000) Send("{CTRLDOWN}w{CTRLUP}") Sleep(1000) Send("{DOWN}{RIGHT}") Sleep(1000) Send("{DOWN}{RIGHT}") Sleep(1000) Send("{DOWN}{RIGHT}") Sleep(1000) Send("c") Sleep(1000) Send("{ALT}") Sleep(1000) Send("{RIGHT}{DOWN}{DOWN}{RIGHT}{ENTER}") ToolTip("Åbner opret ny COM + dialog", $x_1, $y_1) WinWait("[CLASS:#32770]", "") ;~ WinActivate("[CLASS:#32770]", "") WinSetState("[CLASS:#32770]", "", @SW_MAXIMIZE) Send("{ENTER}{TAB}") Sleep(1000) Send("{ENTER}") Sleep(1000) $t1 = WinGetTitle("", "") ;~ MsgBox(0,""&$t1,""&$t1) ToolTip("Navngiver COM +", $x_1, $y_1) Sleep(2000) Send("EposHR{TAB}") Sleep(1000) ;~ Send("{UP}") ;~ Sleep(1000) Send("{ENTER}") ToolTip("Undersøger om COM + findes", $x_1, $y_1) Sleep(2000) $t2 = WinGetTitle("", "") ;~ MsgBox(0,""&$t2,""&$t2) Sleep(2000) If StringCompare($t1, $t2) <> 0 Then ToolTip("COM + er fundet handles ud fra dette", $x_1, $y_1) ; MsgBox(0,"1","1") $t3=WinGetTitle("","") ControlClick($t3,"","[CLASS:Button; INSTANCE:1]") ;~ Send("{ENTER}") Sleep(1000) Send("{TAB 3}") Send("{ENTER}") Sleep(1000) Send("{RIGHT}") Send("E") Sleep(1000) Send("{ALT}{RIGHT}{UP 3}{ENTER}") WinWait("[CLASS:#32770]", "") ; WinActivate("[CLASS:#32770]", "") Send("{TAB 4}") Sleep(1000) Send("{RIGHT 2}") Sleep(1000) $t3=WinGetTitle("","") ControlClick($t3,"","[CLASS:Button; INSTANCE:3]") ControlSetText($t3,"","[CLASS:Edit; INSTANCE:1]",""& $user) ControlSetText($t3,"","[CLASS:Edit; INSTANCE:2]",""& $password) ControlSetText($t3,"","[CLASS:Edit; INSTANCE:3]",""& $password) Send("{ENTER}") Sleep(1000) Send("{RIGHT}") Sleep(1000) Send("{DOWN}") Sleep(1000) Send("{RIGHT}") Else ; MsgBox(0,"2","2") Sleep(500) Send("{DOWN}") Send("{TAB}") Sleep(1000) $t3=WinGetTitle("","") ControlClick($t3,"","[CLASS:Button; INSTANCE:3]") ControlSetText($t3,"","[CLASS:Edit; INSTANCE:1]",""& $user) ControlSetText($t3,"","[CLASS:Edit; INSTANCE:2]",""& $password) ControlSetText($t3,"","[CLASS:Edit; INSTANCE:3]",""& $password) ;~ Send("" & $user) ;~ Send("{TAB 2}") ;~ Send("" & $password) ;~ Send("{TAB}") ;~ Send("" & $password) Send("{ENTER}") Sleep(1000) Send("{ENTER}") Sleep(1000) Send("{RIGHT}") Sleep(1000) Send("e") Sleep(1000) Send("{RIGHT}") Sleep(1000) Send("{DOWN}") Sleep(1000) Send("{RIGHT}") Sleep(1000) ;~ Send("{ALT}{RIGHT}{DOWN 2}{RIGHT}{ENTER}") EndIf Best Regaard Janus S. Andersen
PsaltyDS Posted December 5, 2007 Posted December 5, 2007 Hallo I have a vbs that reg. a COM+ for a dll file. Help me translate this to autoit3Best RegaardJanus S. AndersenAs in another recent post:1. Take all the "Set" commands out, AutoIt doesn't need "Set" to do assignment2. Change CreateObject() to ObjCreate().2. Put a dollar sign "$" in front of every variable name instance (i.e. packagename, catalog, putil, etc.)3. Put parameters inside parens, i.e. $objFs.copyfile(WScript.Arguments(1),WScript.Arguments(2))Like the Water Boy, "You can do it!" Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Janus Posted December 5, 2007 Author Posted December 5, 2007 I have tryed expandcollapse popup; Arguments(0) : Packed name (Is EposHR) ; Arguments(1) : The full path of the dll that have to be stored as COM+ (Full path) ; Arguments(2) : The full path for the dll- file (the dest of the file) Dim $packageName $packageName= $CmdLine[0] ;First, we create the catalog object Dim $catalog $catalog = ObjCreate("MTSAdmin.Catalog.1") ;Then we get the packages collection Dim $packages $packages = $catalog.GetCollection("Packages") $packages.populate Dim $putil $putil = $packages.GetUtilInterface ;Remove all packages that go by the same name as the package we wish to uninstall $numPackages = $packages.Count For $i = $numPackages - 1 To 0 Step -1 If $packages.Item($i).Value("Name") = $packageName Then ConsoleWrite("Stopper pakken: " & $packageName );& " ID " & packages.Item(i).Value("ID") & vbNewLine) $putil.ShutdownPackage($packages.Item($i).Value("ID")) ;ConsoleWrite(("Shutdown done" &vbNewLine) ConsoleWrite("Sletter objekter i pakken: " & $packageName & @CRLF) $packages.Remove ($i) ;ConsoleWrite(("Remove done" &vbNewLine &vbNewLine) ; Commit our deletions $packages.savechanges EndIf Next ;~ $objFS = ObjCreate("Scripting.FileSystemObject") ;~ $objFs.copyfile "" & $CmdLine[1],$CmdLine[2] FileCopy($CmdLine[1],$CmdLine[2]) ;Uninstall complete ;Install package Dim $newPackage $newPackage = $packages.Add $newPackage.Value("Name") = $packageName $newPackage.Value("SecurityEnabled") = "N" $newPackage.Value("ShutdownAfter") = "20" ; Commit new package $packages.SaveChanges ; Refresh packages $packages.Populate ;Get components collection for new package Dim $components $components = $packages.GetCollection("ComponentsInPackage", $newPackage.Value("ID")) ; Install components Dim $util ObjCreate( $util = $components.GetUtilInterface) ; VB and VC ConsoleWrite("Installerer: "& $packageName & @CRLF) ;ConsoleWrite((newPackage.Value("ID") & vbNewLine) ;ConsoleWrite((dllPath & vbNewLine) ;on error resume next $util.InstallComponent($CmdLine[2], "", "") ;ConsoleWrite((err.description):response.end ;if Error.err = "80110401" then ConsoleWrite(("Installed other place") $components.SaveChanges $components.Populate $n = $Components.Count $components.SaveChanges ConsoleWrite($n &" objekter blev installeret" &@CRLF) ;response.redirect("install.asp?init=" & sInit & "&pack=" & packageName & "&dll=" & Server.URLEncode(Request("dll"))) But it is not working. Help me out. Janus S. Andersen
DjDeep00 Posted December 5, 2007 Posted December 5, 2007 @Janus...To make debugging easier...please add this to your script after objcreate()... $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") and the following MyErrFunc function... Func MyErrFunc() Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Local $err = $oMyError.number If $err = 0 Then $err = -1 SetError($err) ; to check for after this function returns Endfunc
PsaltyDS Posted December 5, 2007 Posted December 5, 2007 I have tryed But it is not working. Help me out. Janus S. Andersen "But it is not working" is pretty vague, but this looks suspicious: expandcollapse popup; Install components Dim $util ObjCreate( $util = $components.GetUtilInterface)oÝ÷ Ù:òÙbëaȧr[zÇ«®ájwez·ë¢`ã ç©ÓF§v·©¢»^ŧ-,!jØZ¦§²'âµÚ²}ý· +Ú-zØZµ×ªâ¯j¸nWÖ¬²('x-ëÚçjvÞvÞ¢{azƦzX§z)ÀºÚµ«¢+ØìÉÕµ¹ÑÌ À¤èA¹µ¡%ÌÁ½Í!H¤(ìÉÕµ¹ÑÌ Ä¤èQ¡Õ±°ÁÑ ½Ñ¡±°Ñ¡Ð¡ÙѼÍѽÉÌ =4¬¡Õ±°ÁÑ ¤(ìÉÕµ¹ÑÌ È¤èQ¡Õ±°ÁÑ ½ÈÑ¡±°´¥±¡Ñ¡Íнѡ¥±¤()±½°ÀÌØí½5åÉɽÈô=©Ù¹Ð ÅÕ½ÐíÕѽ%йÉɽÈÅÕ½Ðì°ÅÕ½Ðí5åÉÉÕ¹ÅÕ½Ðì¤()¥´ÀÌØíÁ9µôÀÌØí µ1¥¹lÁt((í¥ÉÍаÝÉÑѡѱ½½©Ð)¥´ÀÌØíѱ½ô=© ÉÑ ÅÕ½Ðí5QMµ¥¸¹ ѱ½¸ÄÅÕ½Ðì¤((íQ¡¸ÝÐÑ¡Á̽±±Ñ¥½¸)¥´ÀÌØíÁÌôÀÌØíѱ½¹Ñ ½±±Ñ¥½¸ ÅÕ½ÐíAÌÅÕ½Ðì¤(ÀÌØíÁ̹Á½ÁÕ±Ñ)¥´ÀÌØíÁÕÑ¥°ôÀÌØíÁ̹ÑUÑ¥±%¹ÑÉ((íIµ½Ù±°ÁÌѡмäѡ͵¹µÌÑ¡ÁÝÝ¥Í Ñ¼Õ¹¥¹Íѱ°(ÀÌØí¹ÕµAÌôÀÌØíÁ̹ ½Õ¹Ð)½ÈÀÌØí¤ôÀÌØí¹ÕµAÌ´ÄQ¼ÀMÑÀ´Ä(%%ÀÌØíÁ̹%Ñ´ ÀÌØí¤¤¹Y±Õ ÅÕ½Ðí9µÅÕ½Ðì¤ôÀÌØíÁ9µQ¡¸($% ½¹Í½±]É¥Ñ ÅÕ½ÐíMѽÁÁÈÁ¸èÅÕ½ÐìµÀìÀÌØíÁ9µ¤ìµÀìÅÕ½Ðì%ÅÕ½ÐìµÀìÁ̹%Ñ´¡¤¤¹Y±Õ ÅÕ½Ðí%ÅÕ½Ð줵ÀìÙ9Ý1¥¹¤($$ÀÌØíÁÕÑ¥°¹M¡ÕѽݹA ÀÌØíÁ̹%Ñ´ ÀÌØí¤¤¹Y±Õ ÅÕ½Ðí%ÅÕ½Ð줤($$í ½¹Í½±]É¥Ñ ÅÕ½ÐíM¡Õѽݸ½¹ÅÕ½ÐìµÀíÙ9Ý1¥¹¤($% ½¹Í½±]É¥Ñ ÅÕ½ÐíM±ÑÑȽ©ÑȤÁ¸èÅÕ½ÐìµÀìÀÌØíÁ9µµÀì I1¤($$ÀÌØíÁ̹Iµ½Ù ÀÌØí¤¤($$í ½¹Í½±]É¥Ñ ÅÕ½ÐíIµ½Ù½¹ÅÕ½ÐìµÀíÙ9Ý1¥¹µÀíÙ9Ý1¥¹¤($$ì ½µµ¥Ð½Õȱѥ½¹Ì($$ÀÌØíÁ̹ÍÙ¡¹Ì(%¹%)9áÐ(íøÀÌØí½©Lô=© ÉÑ ÅÕ½ÐíMÉ¥ÁÑ¥¹¹¥±MåÍѵ=©ÐÅÕ½Ðì¤(íøÀÌØí½©Ì¹½Á奱ÅÕ½ÐìÅÕ½ÐìµÀìÀÌØí µ1¥¹lÅt°ÀÌØí µ1¥¹lÉt)¥± ½Áä ÀÌØí µ1¥¹lÅt°ÀÌØí µ1¥¹lÉt¤(íU¹¥¹Íѱ°½µÁ±Ñ(í%¹Íѱ°Á)¥´ÀÌØí¹ÝA(ÀÌØí¹ÝAôÀÌØíÁ̹(ÀÌØí¹ÝA¹Y±Õ ÅÕ½Ðí9µÅÕ½Ðì¤ôÀÌØíÁ9µ(ÀÌØí¹ÝA¹Y±Õ ÅÕ½ÐíMÕÉ¥Ñå¹±ÅÕ½Ðì¤ôÅÕ½Ðí8ÅÕ½Ðì(ÀÌØí¹ÝA¹Y±Õ ÅÕ½ÐíM¡ÕѽݹÑÈÅÕ½Ðì¤ôÅÕ½ÐìÈÀÅÕ½Ðì(ì ½µµ¥Ð¹ÜÁ(ÀÌØíÁ̹MÙ ¡¹Ì((ìIÉÍ ÁÌ((ÀÌØíÁ̹A½ÁÕ±Ñ((íнµÁ½¹¹Ñ̽±±Ñ¥½¸½È¹ÜÁ()¥´ÀÌØí½µÁ½¹¹ÑÌ(ÀÌØí½µÁ½¹¹ÑÌôÀÌØíÁÌ¹Ñ ½±±Ñ¥½¸ ÅÕ½Ðí ½µÁ½¹¹ÑÍ%¹AÅÕ½Ðì°ÀÌØí¹ÝA¹Y±Õ ÅÕ½Ðí%ÅÕ½Ð줤((ì%¹Íѱ°½µÁ½¹¹ÑÌ)¥´ÀÌØíÕÑ¥°ôÀÌØí½µÁ½¹¹Ñ̹ÑUÑ¥±%¹ÑÉ) ½¹Í½±]É¥Ñ ÅÕ½Ðí%¹Íѱ±ÉÈèÅÕ½ÐìµÀìÀÌØíÁ9µµÀì I1¤(ÀÌØíÕÑ¥°¹%¹Íѱ± ½µÁ½¹¹Ð ÀÌØí µ1¥¹lÉt°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì¤(ÀÌØí½µÁ½¹¹Ñ̹MÙ ¡¹Ì(ÀÌØí½µÁ½¹¹Ñ̹A½ÁÕ±Ñ(ÀÌØí¸ôÀÌØí½µÁ½¹¹Ñ̹ ½Õ¹Ð(ÀÌØí½µÁ½¹¹Ñ̹MÙ ¡¹Ì) ½¹Í½±]É¥Ñ ÀÌØí¸µÀìÅÕ½Ð콩Ñȱإ¹Íѱ±ÉÐÅÕ½ÐìµÀì I1¤()Õ¹5åÉÉÕ¹ ¤(%5Í ½à À°ÅÕ½ÐíÕѽ%Ñ =4QÍÐÅÕ½Ðì°ÅÕ½Ðí]¥¹ÑÉÁÑ =4ÉɽÈÌÌìÅÕ½ÐìµÀì I1µÀì I1µÀì|($$$ÅÕ½ÐíÉȹÍÉ¥ÁÑ¥½¸¥ÌèÅÕ½ÐìµÀìQµÀìÀÌØí½5åÉɽȹÍÉ¥ÁÑ¥½¸µÀì I1µÀì|($$$ÅÕ½ÐíÉȹݥ¹ÍÉ¥ÁÑ¥½¸èÅÕ½ÐìµÀìQµÀìÀÌØí½5åÉɽȹݥ¹ÍÉ¥ÁÑ¥½¸µÀì I1µÀì|($$$ÅÕ½ÐíÉȹ¹ÕµÈ¥ÌèÅÕ½ÐìµÀìQµÀì!à ÀÌØí½5åÉɽȹ¹ÕµÈ°à¤µÀì I1µÀì|($$$ÅÕ½ÐíÉȹ±Íѱ±ÉɽȥÌèÅÕ½ÐìµÀìQµÀìÀÌØí½5åÉɽȹ±Íѱ±ÉɽȵÀì I1µÀì|($$$ÅÕ½ÐíÉȹÍÉ¥Áѱ¥¹¥ÌèÅÕ½ÐìµÀìQµÀìÀÌØí½5åÉɽȹÍÉ¥Áѱ¥¹µÀì I1µÀì|($$$ÅÕ½ÐíÉȹͽÕÉ¥ÌèÅÕ½ÐìµÀìQµÀìÀÌØí½5åÉɽȹͽÕɵÀì I1µÀì|($$$ÅÕ½ÐíÉȹ¡±Á¥±¥ÌèÅÕ½ÐìµÀìQµÀìÀÌØí½5åÉɽȹ¡±Á¥±µÀì I1µÀì|($$$ÅÕ½ÐíÉȹ¡±Á½¹ÑáÐ¥ÌèÅÕ½ÐìµÀìQµÀìÀÌØí½5åÉɽȹ¡±Á½¹ÑáÐ|($$$¤(%1½°ÀÌØíÉÈôÀÌØí½5åÉɽȹ¹ÕµÈ(%%ÀÌØíÉÈôÀQ¡¸ÀÌØíÉÈô´Ä(%MÑÉÉ½È ÀÌØíÉȤìѼ¡¬½ÈÑÈÑ¡¥Ìչѥ½¸ÉÑÕɹÌ)¹Õ¹ìôôÐí5åÉÉÕ¹ Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Janus Posted December 5, 2007 Author Posted December 5, 2007 Thanks all of you! It is not working but now a get a error message to work with! I am calling the script like this (from a cmd) COM_plus.exe EposHR autoexp.dll c:\temp\autoexp.dll The script that I am runing is expandcollapse popup; Script Start - Add your code below here ; Arguments(0) : Packed name (Is EposHR) ; Arguments(1) : The full path of the dll that have to be stored as COM+ (Full path) ; Arguments(2) : The full path for the dll- file (the dest of the file) Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Dim $packageName = $CmdLine[1] ;First, we create the catalog object Dim $catalog = ObjCreate("MTSAdmin.Catalog.1") ;Then we get the packages collection Dim $packages = $catalog.GetCollection("Packages") $packages.populate Dim $putil = $packages.GetUtilInterface ;Remove all packages that go by the same name as the package we wish to uninstall $numPackages = $packages.Count For $i = $numPackages - 1 To 0 Step - 1 If $packages.Item($i).Value("Name") = $packageName Then ConsoleWrite("Stopper pakken: " & $packageName);& " ID " & packages.Item(i).Value("ID") & vbNewLine) $putil.ShutdownPackage($packages.Item($i).Value("ID")) ;ConsoleWrite(("Shutdown done" &vbNewLine) ConsoleWrite("Sletter objekter i pakken: " & $packageName & @CRLF) $packages.Remove($i) ;ConsoleWrite(("Remove done" &vbNewLine &vbNewLine) ; Commit our deletions $packages.savechanges EndIf Next ;~ $objFS = ObjCreate("Scripting.FileSystemObject") ;~ $objFs.copyfile "" & $CmdLine[1],$CmdLine[2] FileCopy($CmdLine[2], $CmdLine[3]) ;Uninstall complete ;Install package Dim $newPackage $newPackage = $packages.Add $newPackage.Value("Name") = $packageName $newPackage.Value("SecurityEnabled") = "N" $newPackage.Value("ShutdownAfter") = "20" ; Commit new package $packages.SaveChanges ; Refresh packages $packages.Populate ;Get components collection for new package Dim $components $components = $packages.GetCollection("ComponentsInPackage", $newPackage.Value("ID")) ; Install components Dim $util = $components.GetUtilInterface ConsoleWrite("Installerer: " & $packageName & @CRLF) $util.InstallComponent($CmdLine[3], "", "") $components.SaveChanges $components.Populate $n = $components.Count $components.SaveChanges ConsoleWrite($n & " objekter blev installeret" & @CRLF) Func MyErrFunc() MsgBox(0, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Local $err = $oMyError.number If $err = 0 Then $err = -1 SetError($err) ; to check for after this function returns EndFunc ;==>MyErrFunc Best Regaards Janus S. Andersen And thanks for the help so far!
Janus Posted December 19, 2007 Author Posted December 19, 2007 Thanks PsaltyDS, DjDeep00 and PsaltyDS The code is doing: 1. find a predefined COM+ object and delete it 2. Install a new COM+ from a dll file 3. Put in the user rights on the COM+ ("Brugernavn" username and (kodeord) password) 4. It stores the COM+ object 5. It counts alle the methodes in it The script is a part of a installer (I am using nsis to make the installer part) It is working and here is my code!: expandcollapse popupGlobal $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Dim $packageName,$catalog,$packages,$putil,$numPackages,$i,$newPackage,$components, $util, $n, $dll_path, $strUsername,$strPassword,$file,$search #include <GUIConstants.au3> Dim $brugernavn, $kodeord, $COMNavn, $dllsti Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form=c:\documents and settings\tester\desktop\complus_gui.kxf\\\\ Global $AForm1 = GUICreate("COM plus installer", 547, 230, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "AForm1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "AForm1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "AForm1Restore") Global $ALabel1 = GUICtrlCreateLabel("Brugernavn", 16, 48, 59, 17) GUICtrlSetOnEvent($ALabel1, "ALabel1Click") Global $AInput1 = GUICtrlCreateInput("", 96, 48, 329, 21) GUICtrlSetOnEvent($AInput1, "AInput1Change") GUICtrlSetTip($AInput1, "Brugernavn") Global $ALabel2 = GUICtrlCreateLabel("Kodeord", 32, 80, 44, 17) GUICtrlSetOnEvent($ALabel2, "ALabel2Click") Global $AInput2 = GUICtrlCreateInput("", 96, 80, 329, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL)) GUICtrlSetOnEvent($AInput2, "AInput2Change") GUICtrlSetTip($AInput2, "Kodeord") Global $ALabel3 = GUICtrlCreateLabel("Sti til dll", 32, 112, 39, 17) GUICtrlSetOnEvent($ALabel3, "ALabel3Click") Global $AInput3 = GUICtrlCreateInput("", 96, 112, 329, 21) GUICtrlSetOnEvent($AInput3, "AInput3Change") GUICtrlSetTip($AInput3, "Sti til den dll fil der anvndes") Global $AButton1 = GUICtrlCreateButton("Gennemse", 440, 112, 75, 25, 0) GUICtrlSetOnEvent($AButton1, "AButton1Click") GUICtrlSetTip($AButton1, "Åbner en dialog til at finde dll filen med") Global $AInput4 = GUICtrlCreateInput("EposHR", 96, 144, 329, 21) GUICtrlSetOnEvent($AInput4, "AInput4Change") GUICtrlSetTip($AInput4, "Navn på pakken for dll COM+ elementet") Global $AButton2 = GUICtrlCreateButton("Udfør", 168, 184, 75, 25, 0) GUICtrlSetOnEvent($AButton2, "AButton2Click") GUICtrlSetTip($AButton2, "Udør program") Global $AButton3 = GUICtrlCreateButton("Fortryd", 272, 184, 75, 25, 0) GUICtrlSetOnEvent($AButton3, "AButton3Click") GUICtrlSetTip($AButton3, "Stop udførelsen af COM +") Global $AEdit1 = GUICtrlCreateEdit("", 16, 8, 497, 25, $ES_WANTRETURN) GUICtrlSetData($AEdit1, "Dette er et program til at installere COM+ med") GUICtrlSetOnEvent($AEdit1, "AEdit1Change") GUICtrlSetState($AEdit1, $GUI_DISABLE) Global $Label1 = GUICtrlCreateLabel("COM + Navn", 8, 144, 66, 17) GUICtrlSetOnEvent($Label1, "Label1Click") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ControlSetText("", "", $AInput1, "" & @UserName) Send("{TAB}") Dim $loop_status = 1 $search = FileFindFirstFile("*.dll") $file = FileFindNextFile($search) ;~ MsgBox(4096, "File:"&@ScriptDir&"\"&$file, @ScriptDir&"\"&$file) FileClose($search) ControlSetText("", "", $AInput3, @ScriptDir&"\"&$file) ; Sætter den sti filen har samt filens navn While 1 Sleep(100) If $loop_status = 0 Then WinSetTrans("","",0) ProgressOn("Epos HR COM", "Status", "0 pct") ExitLoop EndIf WEnd Func AButton1Click() $message = "Vælg den mappe hvor dll filen ligger" $dll_path = FileOpenDialog($message, @ScriptDir & "\", "Dll filer (*.dll)|Alle filer (*.*)", 1) If @error = 0 Then ; Tjekker om der er valgt en fil eller cancel ControlSetText("", "", $AInput3, $dll_path) ; Sætter den sti filen har samt filens navn EndIf EndFunc ;==>AButton1Click Func AButton2Click() ;~ MsgBox(0, "", "Brugernavn:" & ControlGetText("", "", $AInput1) & @CRLF & "Kodeord:" & ControlGetText("", "", $AInput2) & @CRLF & "Sti til dll:" & ControlGetText("", "", $AInput3) & @CRLF & "COM+ navn:" & ControlGetText("", "", $AInput4)) $strUsername = ControlGetText("", "", $AInput1) $strPassword = ControlGetText("", "", $AInput2) $dll_path = ControlGetText("", "", $AInput3) $packageName = ControlGetText("", "", $AInput4) $loop_status=0 EndFunc ;==>AButton2Click Func AButton3Click() Exit EndFunc ;==>AButton3Click Func AEdit1Change() EndFunc ;==>AEdit1Change Func AForm1Close() Exit EndFunc ;==>AForm1Close Func AForm1Maximize() EndFunc ;==>AForm1Maximize Func AForm1Minimize() EndFunc ;==>AForm1Minimize Func AForm1Restore() EndFunc ;==>AForm1Restore Func AInput1Change() EndFunc ;==>AInput1Change Func AInput2Change() EndFunc ;==>AInput2Change Func AInput3Change() EndFunc ;==>AInput3Change Func AInput4Change() EndFunc ;==>AInput4Change Func ALabel1Click() EndFunc ;==>ALabel1Click Func ALabel2Click() EndFunc ;==>ALabel2Click Func ALabel3Click() EndFunc ;==>ALabel3Click Func Label1Click() EndFunc ;==>Label1Click TrayTip("COM+ Installer", "Starter COM + ",60) ProgressSet( 1, 1 & " pct") ;$packageName="EposHR" $catalog=ObjCreate("MTSAdmin.Catalog.1") TrayTip("COM+ Installer", "Opretter MTSAdmin.Catalog.1 ",60) ProgressSet( 2, 2 & " pct") $packages=$catalog.GetCollection("Packages") TrayTip("COM+ Installer", "Henter Packages",60) ProgressSet( 3, 3 & " pct") $packages.populate TrayTip("COM+ Installer", "Henter Packages interface",60) ProgressSet( 4, 4 & " pct") $putil = $packages.GetUtilInterface TrayTip("COM+ Installer", "Henter antal Packages",60) ProgressSet( 5, 5 & " pct") ;Remove all packages that go by the same name as the package we wish to uninstall $numPackages = $packages.Count ;MsgBox(0,""&$numPackages,""&$numPackages) ProgressSet( 6, 6 & " pct") For $i = $numPackages - 1 To 0 Step -1 TrayTip("COM+ Installer", "Gennem søger pakker for at finde den rigtige pakke : "&$i&" af "&$numPackages,60) If $packages.Item($i).Value("Name") = $packageName Then TrayTip("COM+ Installer", "Pakke fundet : "&$i&" af "&$numPackages&" pakke slette osv.",60) ;WScript.Echo("Stopper pakken: " & packageName )'& " ID " & packages.Item(i).Value("ID") & vbNewLine) $putil.ShutdownPackage($packages.Item($i).Value("ID")) ;'WScript.Echo("Shutdown done" &vbNewLine) ;WScript.Echo("Sletter objekter i pakken: " & packageName & vbNewLine) $packages.Remove ($i) ;'WScript.Echo("Remove done" &vbNewLine &vbNewLine) ;' Commit our deletions $packages.savechanges ProgressSet( 7, 7 & " pct") ExitLoop EndIf Next TrayTip("COM+ Installer", "Sætter navn og andre oplysninger på COM+",60) ProgressSet( 8, 8 & " pct") ;Install package $newPackage = $packages.Add $newPackage.Value("Name") = $packageName $newPackage.Value("Description")="Dette er et COM element til EposHR som er en del af pbj program til styring af HR - systemet" $newPackage.Value("Activation") = "Local" $newPackage.Value("Identity") = $strUsername $newPackage.Value("Password") = $strPassword ;$newPackage.Value("Identity") = "Interactive User" ;~ $newPackage.Value("Identity") = "This user:" $newPackage.Value("SecurityEnabled") = "N" $newPackage.Value("ShutdownAfter") = "20" TrayTip("COM+ Installer", "Gemmer data", 60) ; Commit new package $packages.SaveChanges; Her mangler nnoget hvis brugeren taster et forkert kodeord ProgressSet( 9, 9 & " pct") TrayTip("COM+ Installer", "Opdatere pakker", 60) ; Refresh packages $packages.Populate ; Get components collection for new package TrayTip("COM+ Installer", "Hent alle pakker igen",60) ProgressSet( 10, 10 & " pct") $components = $packages.GetCollection("ComponentsInPackage",$newPackage.Value("ID")) ; Install components $util = $components.GetUtilInterface ; on error resume next ;$util.InstallComponent "C:\EposHR.dll", "", "" TrayTip("COM+ Installer", "Installere dll fra den file der indeholder COM+", 60) ProgressSet( 11, 11 & " pct (Dette step tager noget tid)") $util.InstallComponent($dll_path, "", "") ProgressSet( 50, 50 & " pct") $components.SaveChanges TrayTip("COM+ Installer", "Gemmer ændringerne",60) $components.Populate TrayTip("COM+ Installer", "Tilføjer metoder mm.",60) $n = $Components.Count TrayTip("COM+ Installer", "COM+ Antal Elementer : "&$n,60) ProgressSet( 90, 90 & " pct") ProgressOff() MsgBox(0,"Antal elementer installeret : "&$n,"Antal elementer "&$n&" installeret"&@CRLF&"Valider dette tal ikke er 0",30) ProgressOn("Epos HR COM", "Status", "100 pct") $components.SaveChanges ProgressSet( 100, 100 & " pct") Sleep(2000) Func MyErrFunc() MsgBox(0, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Local $err = $oMyError.number If $err = 0 Then $err = -1 SetError($err) ; to check for after this function returns EndFunc ;==>MyErrFunc Janus S. Andersen
PsaltyDS Posted December 19, 2007 Posted December 19, 2007 Thanks PsaltyDS, DjDeep00 and PsaltyDSThe code is doing:1. find a predefined COM+ object and delete it2. Install a new COM+ from a dll file3. Put in the user rights on the COM+ ("Brugernavn" username and (kodeord) password) 4. It stores the COM+ object5. It counts alle the methodes in itThe script is a part of a installer (I am using nsis to make the installer part)It is working and here is my code!:Janus S. AndersenGlad you got it working.Merry Christmas! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now