Jump to content

Emolas

Active Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by Emolas

  1. I have a batch file calling a compiled autoit file and I want the autoit to write to the DOS window that the batch file opened. For instance: test.bat contains the following start /wait script.exe script.exe contains the following: ConsoleWrite("this is a test") Exit I know consolewrite isn't the way to do it but I can't seem to find a way to write to the window that ran the script. Lots of ways to write to windows that the script opens but nothing the other way around.
  2. it has a check box in the compiler. Whether it actually does anything or not I couldn't tell you. Size really isn't an issue I was just interested at the fact that a one line script compiled was larger than a 3000 line one. I had already chalked it up to one of those "weird things programs do" but figured I would ask if anyone had any solid reasons as to why just to satisfy my curiosity. Common sense would say that the size difference between a 45 kb file and a 1 kb file would be 44 kb since they would both need the same interpreters and stuff so the smaller file compiling larger than the other one threw me. Thanks for all the answers.
  3. Both are using UPX. I did discover the smaller one was x86 and the larger was x64 so that had something to do with it. Compiling the single line script in x86 shrunk it to 396KB but that still seems inordinately large especially when comparing it to another script 45X larger with probably 2000X the amount of code.
  4. So I have a script of about 1100 or so lines with several includes and other stuff making the .au3 about 45kb that compiles to 364KB. I have another 1KB script of ONE LINE "run(program.exe /q)" that compiles to 760KB. I'm completely baffled as to why that would be. Like I said in the title, the size isn't a problem but it is very weird and I was wondering if anyone knew why something like this might occur.
  5. Is it possible to get splash text to show up on a locked workstation? Basically, I want to kick off my script then lock the workstation while it runs but I want a warning saying not to reboot or log me off. I know I could make a bmp that says it and change the Windows background while the script is running but if it is possible to just make the splash text show up that would be easier.
  6. Thank you, I'll give them both a try.
  7. Thank you for the quick responses. Usually I am able to find just about anything I need by searching the forums here but I was unable to locate anything like this so I posted in hopes that someone recalled whether they had seen one. @jlogan3013 - I considered doing that but it goes against my desires by still having several files and calling external commands when I am trying to consolidate. @BrewManNH - I like that idea, it will make the string manipulation easier than just reading the lines and parsing the text.
  8. It bothers me trying to troubleshoot a .vbs calling a .bat that calls a .exe that imports a file so I'm converting all of our old batch files and assorted scripting messes into a more simplified single script with as much as possible running native AutoIT commands. Unfortunately, there are several .reg files that have hundreds of entries. I could rewrite them all but programming is supposed to enable lazy guys like me to let computers do the work for them and I forsee a use for something like this in the future. So, before I start writing a script to convert the text in a .reg file into useable AutoIT commands, has someone already done it?
  9. added variables to each command to log errors and msgboxes to report them but there are no errors. It loads up the User Accounts windows and sits there. If I click on the next two steps manually (ControlClick("User Accounts","","[CLASS:Button; INSTANCE:1]") & ControlClick("User Accounts","","[CLASS:Button; INSTANCE:9]")), it finishes the rest without a problem but it seems WinWaitActive("User Accounts") never realizes it is active so it hangs there. Interestingly, this is a snip from a much larger script and it works alone but not within the original script.
  10. I'm trying to set auto logon using the userpasswords2 control because it is a bit more secure than plain text passwords in the registry. I tried a few approaches but none of them work. here is what I have that goes the farthest: $User = "TestUser" $Pass = "Password1" Run(@ComSpec & " /c " & 'control userpasswords2', "", @SW_HIDE) WinWaitActive ("User Accounts", "Users must &enter a user name and password to use this computer.") Send("!e" & "!a") WinWaitActive ("Automatically Log On") Send("!u" & $user & "!p" & $pass & "!c" & $pass & "{ENTER}") WinWaitActive ("User Accounts") Send("{ENTER}") Everything works fine right up until it gets to the "ENTER" part of the Send("!u" & $user & "!p" & $pass & "!c" & $pass & "{ENTER}") line. Windows gives one of those "you did something wrong" noises and the window stays open. I can manually hit the enter key and it proceeds as normal but the scripting of it does not work. This one goes almost as far as the previous one: $User = "TestUser" $Pass = "Password1" Run("control userpasswords2") WinWaitActive("User Accounts") Send("{space}{ENTER}") WinWaitActive("Automatically Log On") Send("+{TAB}" & $User & "{TAB}" & $pass & "{TAB}" & $pass & "{ENTER}") WinWaitActive ("User Accounts") Send("{ENTER}") It one works right up until it is supposed to tab to the second password and then it tabs to a different window like alt-tab. The final one I tried does nothing after running the control. I'm not even certain if I am using the commands correctly. $User = "TestUser" $pass = "Password1" Run("control userpasswords2") WinWaitActive("User Accounts") ControlClick("User Accounts","","[CLASS:Button; INSTANCE:1]") ControlClick("User Accounts","","[CLASS:Button; INSTANCE:9]") WinWaitActive("Automatically Log On") ControlSetText("Automatically Log On","","[CLASS:Edit; INSTANCE:1]",$User) ControlSetText("Automatically Log On","","[CLASS:Edit; INSTANCE:2]",$pass) ControlSetText("Automatically Log On","","[CLASS:Edit; INSTANCE:3]",$pass) ControlClick("Automatically Log On","","[CLASS:Button; INSTANCE:1]") WinWaitActive("User Accounts") ControlClick("User Accounts","","[CLASS:Button; INSTANCE:7]") So I have three options, all of which look like they should work (to me anyway) but none of which work. Is there something stupid I am missing?
  11. Thanks for the suggestion but that's really not what I was looking for. I have a script that throws up an input box to enter a computer name then it queries AD and returns a list of all possible matches to select from for use later in the script. I wanted to avoid using a GUI altogether and just use popup boxes but it doesn't look to be possible. It took less than 5 minutes to make a small GUI and make the whole thing a listbox but I was thinking it would be nice to do it the other way. Edit: I really should check spelling before hitting submit...
  12. I know I could just make a small GUI with a listbox to select from and an OK button but I was curious if there is a function for a popup listbox like inputbox only displaying a list of items to choose from instead of a text entry field.
  13. Excellent, thank you. I always compile from within SciTE so I was unaware there was a command-line compiler.
  14. Wow, that was quick! I don't think I explained my problem correctly. What I am doing is making a script that will write another script and then compile it. It sounds like a strange way of going about it but the reason behind it is that one admin has a service account with exceptional rights and he wants a script that uses it and will have the password encoded and compiled into itself. That in itself would be simple but I do not want to ever see the password (no chance of misuse accusations) so I can write a script and give it to him to run. It asks him for the password, encrypts it, and adds it to the second script. What I want to do is compile the second script after I add the password line to it. here's a snippet: #Include <String.au3> $passIn = InputBox("Password", "enter password:", "", "*") $passEnc = _StringEncrypt(1,$passIn,"encrypt",1) $File = FileOpen("test2.au3",1) FileWriteLine($File,"$Password = " & "_StringEncrypt(0,""" & $passEnc & """,""encrypt"",1)") FileClose($File) ;here I want to compile $File
  15. Is it possible to compile an au3 file with an AutoIT script?
  16. Awesome script and very useful. Is there any way to get it to block USER mouse input but still enable script input via mousemove()?
  17. I KNEW it was something stupid. Thanks
  18. I have two buttons in my script and for some reason, I am unable to click on the second one. #include <GUIConstants.au3> opt("GUIOnEventMode", 1) $DomainJoin = GUICreate("OU Switch ",700, 200, 170, 115) GUICtrlCreateLabel("Are you switching this computer or a remote computer?", 75, 10, 650, 30) GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("This computer:", 75, 43, 100) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Local = GUICtrlCreateButton(@ComputerName,195, 40) GUICtrlCreateLabel("A remote computer:", 350, 43, 200) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Remote = GUICtrlCreateButton("Remote",485, 40, 100) GUISetState(@SW_SHOW) ; Read Clicks GUICtrlSetOnEvent($Local, "GetDN") GUICtrlSetOnEvent($Remote, "SetRemote") GUISetOnEvent($GUI_EVENT_ClOSE,"ExitMessage") ; wait for a click While 1 Sleep(500) WEnd Func getDN() EndFunc Func setremote() MsgBox(0,"good", "tests good") EndFunc Func ExitMessage() Exit EndFunc The $Remote button works if you tab to it and hit the spacebar but it is unclickable. Has anyone ever experienced this? Edited to make code standalone
  19. Well I couldn't figure out how to do it using _ADFunctions.au3. However, this post was EXTREMELY helpful and I was able cut out several lines and replaced them with this little gem: $run = @ComSpec & " /c dsmove.exe """& $OldDN &""" -newparent """ & $NewDN & """ -u !"& @UserName & " -p " & $password
  20. Use the _FileListToArray function: #Include <File.au3> $Path = @HomeDrive & "\Users\" & @UserName & "\AppData\Roaming\Mozilla\Firefox\Profiles\" $Folders = _FileListToArray($Path,"*",2) $Loop = UBound($Folders) For $i = 1 to $Loop FileDelete(@HomeDrive & "\Users\" & @UserName & "\AppData\Roaming\Mozilla\Firefox\Profiles\" & $Folders[$i] & "\formhistory.sqlite") FileDelete(@HomeDrive & "\Users\" & @UserName & "\AppData\Roaming\Mozilla\Firefox\Profiles\" & $Folders[$i] & "\cookies.sqlite") FileDelete(@HomeDrive & "\Users\" & @UserName & "\AppData\Roaming\Mozilla\Firefox\Profiles\" & $Folders[$i] & "\search.sqlite") next
  21. First off I would like to thank all the helpful people on these boards, I have learned so much just by reading other people's questions and answers. I'm a super newb at AutoIT (This is my first script) but have an understanding of programming (BASIC, assembly, and COBOL from the 80's along with a smattering of VB). Now on to my question: I need to move a computer from one OU to another within the same domain. for example: I want to move CN=bobsmachine,OU=Computers,OU=London,OU=anotherOU,OU=lastOU,DC=testdomain,DC=net to CN=bobsmachine,OU=Computers,OU=Paris,OU=anotherOU,OU=lastOU,DC=testdomain,DC=net Edited to remove corporate AD structure and to remove use of .ini files but essentially it's the same. #include <Constants.au3> #include <GUIConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <String.au3> Global $PCType, $DomainJoin, $Local, $Remote, $ComputerName, $domain, $SiteCombo, $i, $Varw, $Switch, $Confirm Global $objTrans, $objDomain, $Sou, $GetDN, $NewDN, $sSourceDN, $sDestCN $wshShell = ObjCreate("WScript.Shell") $wshNetwork = ObjCreate("WScript.Network") ;################################################### GUI opt("GUIOnEventMode", 1) ; Build it $DomainJoin = GUICreate("Domain Join ",700, 200, 170, 115) GUICtrlCreateLabel("Are you switching this computer or a remote computer?", 75, 10, 650, 30) GUICtrlSetFont(-1, 15, 800, 0, "MS Sans Serif") GUICtrlCreateLabel("This computer:", 75, 43, 100) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Local = GUICtrlCreateButton(@ComputerName,195, 40) GUICtrlCreateLabel("A remote computer:", 350, 43, 200) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Remote = GUICtrlCreateButton("Remote",485, 40, 100) GUISetState(@SW_SHOW) ; Read Clicks GUICtrlSetOnEvent($Local, "GetDN") GUICtrlSetOnEvent($Remote, "SetRemote") GUISetOnEvent($GUI_EVENT_ClOSE,"ExitMessage") ; Do nothing for a while While 1 Sleep(500) WEnd ;##################################################### Get the remote machine name Func SetRemote() $ComputerName = InputBox("Remote Machine", "Enter Machine Name", "") if $ComputerName <> "" Then GetDN() EndIf EndFunc ;#################################################### Get the current DN Func GetDN() ; assign computer name to local machine if applicable if @GUI_CtrlId = $Local Then $ComputerName= @ComputerName EndIf ; Constants for the NameTranslate object. Const $ADS_NAME_INITTYPE_GC = 3 Const $ADS_NAME_TYPE_NT4 = 3 Const $ADS_NAME_TYPE_1779 = 1 ; Grab the current full name and path $objTrans = ObjCreate("NameTranslate") $objDomain = Objget("LDAP://rootDse") $objTrans.Init ($ADS_NAME_INITTYPE_GC, "") $objTrans.Set ($ADS_NAME_TYPE_NT4, $wshNetwork.UserDomain & "\" & $ComputerName & "$") $GetDN = $objTrans.Get($ADS_NAME_TYPE_1779) ;display current computer info and create combo to select new site GUICtrlCreateLabel("Current DN: " & $GetDN, 10, 110, 650, 100) GUICtrlCreateLabel("PC Type: " & $PCType & " Domain: " & $domain, 10, 125) GUICtrlCreateLabel("Select new site: ", 10, 77) $SiteCombo = GUICtrlCreateCombo("", 110, 75, 50, 25,$CBS_DROPDOWNLIST) GUICtrlSetData(-1, "NewYork|London|Paris|Berlin|Sofia") GUICtrlSetOnEvent($SiteCombo, "NewSite") EndFunc ;######################################################### Set new site OU Func NewSite() $Site = GUICtrlRead($SiteCombo) $SOU = "Computers,OU=" & $Site $NewDN = "OU="& $SOU & ",OU=FirstOU,OU=SecondOU,DC=testdomain,DC=net" GUICtrlCreateLabel("New DN: " & "CN=" & $ComputerName & "," & $NewDN, 10, 150, 650, 100) $Switch = GUICtrlCreateButton("MAKE THE SWITCH", 195, 75, 150, -1) GUICtrlSetOnEvent($Switch, "Confirm") EndFunc ;########################################################## Confirm change Func Confirm() $Confirm = MsgBox(1, "Confirm Switch", "Are you certain you want to move " & $ComputerName & " to the " & $Sou & " OU?") if $Confirm = 1 Then MoveIt() EndIf EndFunc ;########################################################### move PC to new OU Func MoveIt() ; Set query source and destination $SourceCN = "LDAP://" & $GetDN $DestCN = "LDAP://" & $NEWDN ; Set Target OU $objCont = ObjGet($DestCN) ; Move the Computer into Target OU $objPC = $objCont.MoveHere($SourceDN) EndFunc ;############################################################ Exit button pushed Func ExitMessage() Exit EndFunc I think my whole problem is not knowing the syntax for "$objCont.MoveHere($sSourceDN)" What must those variables contain? C:\Documents and Settings\john.salome\Desktop\script\MoveBuilding.au3 (148) : ==> The requested action with this object has failed.: $objPC = $objCont.MoveHere($sSourceDN) $objPC = $objCont.MoveHere($sSourceDN)^ ERROR
×
×
  • Create New...