Jump to content

triodz

Active Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by triodz

  1. Thanks for the help with this one, but it unfortunately it just created a blank file. This worked perfectly! Thanks so much for your help. You actually went above and beyond and got me on my way with my next challenge of having the number on the button update (well it will be on a label, but same-same!)
  2. I want the number in a file to be overwritten with the next number up each time a button is pressed. So it is pressed once, the number '1' is written to the file. It is pressed again and the number '2' overwrites the first number. At the moment I get the number 1 written, but can't get it to overwrite. What I have so far: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #Region ### START Koda GUI section ### Form=C:\Users\soulf\Desktop\CalcGui\RLCalc.kxf $Form1 = GUICreate("Form1", 615, 437, 426, 141) $One = GUICtrlCreateButton("1", 32, 72, 25, 25) GUICtrlSetBkColor(-1, 0xFF0000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Func First ()     $fPath = "C:\temp\First.txt"     $fOpen = FileOpen ($fPath, 2)     $Counter = FileReadLine ($fpath)     $counter = $counter + 1     $fWrite = filewriteline ($fPath, $counter)     FileClose ($fpath) EndFunc While 1     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE             Exit         Case $One             Call ("First")     EndSwitch WEnd I tried a Do Until statement, but that just puts the numbers 1 to 5 in the file. Any help would be greatly appreciated!
  3. Sorry mate, just overwrites the file It's OK, I did a for...next loop, then used a different program to rename them in chronological order. It can start renaming from the last number too, which is handy. It's heaps easier and doesn't take long. Thanks anyways guys. Have a great night!
  4. Thanks Andreu, but I can't get it to work. I do appreciate your assistance though I might just do a for...next and use a batch file rename programs separately to name the files in an orderly way, being that the "for" statement will create the same names again,
  5. Hi Everyone! Been away from scripting for a bit and am a bit rusty. I was trying to get downloaded image filenames to increment by one. I was hoping to be able to check the last filename and continue from there if the program was closed and reopened again. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $biolister = GUICreate("Form1", 125, 97, 192, 124) GUISetBkColor(0x99B4D1) $start = GUICtrlCreateButton("Start", 8, 40, 41, 33) GUICtrlSetBkColor(-1, 0x00FFFF) $stop = GUICtrlCreateButton("Stop", 72, 40, 41, 33) GUICtrlSetBkColor(-1, 0xFF0000) $Bio = GUICtrlCreateLabel("Bio Lister", 24, 8, 80, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $filename = 0 $sImgDir = "C:\filepathname\"&$filename&".jpg" $sImgUrl = "http://lorempixel.com/400/200" $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $stop Exit case $start InetGet($sImgUrl, $simgdir, 1, 0) if fileexists( $simgdir & $filename) then $filename + 1 EndSwitch WEnd
  6. Holy crap, that's awesome! This does exactly what I want. Thank you so much! This is great!
  7. Well, I figured out a way around it... sorta. I will be using this to keep track of numbers. So the last number entered needs to be added to the new number entered. I ended up with a msgbox that pops up with the current total. I would prefer this to show in an inputbox if this possible though. For anyone interested: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 211, 85, 192, 124) $FIRST = GUICtrlCreateLabel("First", 8, 16, 23, 17) $1ST=GUICtrlCreateInput("", 36, 12, 57, 21) $Button1 = GUICtrlCreateButton("Add", 20, 40, 75, 25) $Button2 = GUICtrlCreateButton("Clear", 104, 40, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $FIRST1=GUICtrlRead($1st) ;reads number entered $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE FileDelete("total.txt") ;deletes any created files so there is no interference next time Exit Case $Button1 $LASTTOTAL=FileReadLine("total.txt",-1) ;reads last number in tally file. If not there, it is created $NEXTTOTAL=$FIRST1+$LASTTOTAL ;adds the last number in the tally file with the number entered in inputbox $TOTALFILE=FileWriteLine("total.txt",$NEXTTOTAL) ;writes new total in tally file MsgBox(1,"",$NEXTTOTAL) ;displays the current total Case $Button2 FileDelete("total.txt") ;deletes the tally file if you want to start again EndSwitch WEnd
  8. This probably has a simple solution, but I cannot figure it out. First here is the code: #include #include #include #include #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("", 234, 58, 192, 124) $FIRST = GUICtrlCreateLabel("First", 8, 16, 23, 17) $SECOND = GUICtrlCreateLabel("Second", 104, 15, 41, 17) $1st=GUICtrlCreateInput("", 36, 12, 57, 21) $2nd=GUICtrlCreateInput("", 150, 12, 57, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $FIRST1=GUICtrlRead($1st) $SECOND2=GUICtrlRead($2nd) if $FIRST1<>"" Then $SECOND2=$FIRST1+$SECOND2 EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd What I want to do is, when I put a number in the First inputbox, the Second inputbox automatically adds it to its total. Example: First: I put in the number 6 Second: It already has the number 8 in it I want the Second to automatically update to 14. Any help is greatly appreciated.
  9. First example script. Yay for me! So apologies if there is a certain way i need to do this. It is probably more accurate to state that this is code from different people put into a instantly usable script. First, credits go to: For the encrypt\decrypt code: For the Verification against AD code: I have added commentary in the scripts that will hopefully help the newbie factor out a bit. I've been there and its nice to have helpful comments. In case you need to compare your situation with mine: I work on a helpdesk. I log on with a standard signon and use a different signon for administrative tasks. I am using this to run other scripts as an administrator.In "CredCheck.au3", it will check the username and password given against Active Directory. If it fails, it will let you know. If it succeeds, it will run the given program or script as administrator. It also writes the password to an ini file and encrypts it, and also writes the username - unencrypted. In "Unencrypt Test.au3" it will unencrypt the password which will allow it to be injected into password fields of remote pc's if needed. In my case, I did need this. CredCheck.au3 unencrypt test.au3 Good luck and any criticism welcome!
  10. I FIGURED IT OUT!! OMG I THOUGHT MY HEAD WOULD ASPLODE AND EVERYONE AROUND ME WOULD BE COVERED IN CONFUSED BRAIN GOO! Right, now that excitement is out of the way: BrewManNH, you are very right, but not in the way I (or perhaps you) are thinking. I was wondering if the files were getting the same rights as the initial script calling on them. Our standard logon and our Admin logon (the reason I am creating this) are different - "username" for standard and "username_a" for admin. So if the script is being opened with the "username_a", then calling on files that have not inherited the same rights, it will fail. Because these files are a part of the array, said annoying-as-hell error appears. So what to do? Look at the Logon script (CredCheckPrint) that calls the script I want to run! In this script, I had this: case $ok If _ValidUserPass($usera, $computer, $passa) = True Then Ini_Write("Password","c:cred3.ini","Section","Key",$passa) ; RunAs($usera, $computer, $passa,0,@ScriptDir&"test3.exe") ExitLoop Else for when the OK button was pressed. I changed the RunAs line to this: RunAs($usera, $computer, $passa,0,@ScriptDir&"test3.exe",@ScriptDir,"",0x1) Help file states: 0x1 ($STDIN_CHILD) = Provide a handle to the child's STDIN stream My interpretation of this is that the credentials used will also also be used for any files the script calls on. Which is what i need. Works beautifully! When I have this completed and working, I am going to post for use by others as it really is going to be a useful script in an environment that only uses admin logons when troubleshooting users PC's. It will allow automation of any script yiou create that needs to be run as admin. And the printing script may come in handy too! Thanks SO MUCH for the help you have both provided! Once again this community shows its awesomeness.
  11. Hi BrewManNH, I added what you suggested, as such: $print = IniReadSection(".printerlist.ini","PRINTERS") _ArrayDisplay ($print) and: $PrintCombo = GUICtrlCreateCombo("", 160, 77, 225, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) For $iX = 1 To $print[0][0] ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iX = ' & $iX & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console GUICtrlSetData(-1, $print[$iX][0],"") Next When run uncompiled, the array displays perfectly, with no debug errors at all. Unfortunately, the same error came up when trying to runas the Printer Install script when it is compiled. So it does not even open it to debug it. As stated before, when run from the au3 file or if I run the exe just by double clicking on it, there are no errors. So nothing to debug. Thanks for the hints though. I ended up trying this in place of the arrays: $PrintCombo = GUICtrlCreateCombo("", 160, 77, 225, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) $file = FileOpen("printerlist.txt", 0) $lineComplete = "" while 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $lineComplete = $lineComplete & $line GUICtrlSetData(-1,$lineComplete) WEnd FileClose($file) Now it does not show the error when using runas. Instead, I see the autoit icon in the system tray, but it does not open the GUI! Gah!!
  12. Thanks, but I have picked up on this and tried with the ini file in the same folder as the script and withwithout the "." in front. Still fails with the same error. I am now resorting to finding a way without using arrays. Maybe using filereadline, but it only reads one line. Ah well. Another journey to undertake!
  13. Still happening Here is the error that happens EVERY time. It is always the same (with yours and mine). I can see what you were doing with the ini files, too. I didn't have anything in the "value" field for a couple of them. Made no difference though unfortunately. As mentioned above, ONLY happens when I try and run as from a different autoit script (compiled or uncompiled) or runas with a command prompt. If I right click and Run As a different user, it works perfectly fine. Thanks a million for you input though Aipion. My head will now explode...
  14. Thanks Aipion. I wish i could try this, but my work proxy has blocked your site. Nothing personal, our filters are just really paranoid! I think it picked up the .co.cc domain and slammed down the iron door of fear! Is it possible to post the au3 file? Thanks again
  15. FINAL EDIT: The answer you seek is at the EDIT: It definitley has to do with any part of the code with this in it: For $iX = 1 To $print[0][0] GUICtrlSetData(-1, $print[$iX][0],"") Next which calls on this: $print = IniReadSection(".ifileprinterlist.ini","PRINTERS") I commented all of the arrays and it worked fine. So I guess i need to figure out what I'm doing wrong here. END EDIT MORE EDITS I used a totally different array and it still fails when trying to runas. I tried to runas using a command prompt and it failed with the same error again. I have no idea whats going on. It may be something to do with the Include file Array.au3. I am going to go that way next. END MORE EDITS ********************************************************************************************************************** I am just wondering if the below code is, in fact, correct (the way that the combolists are getting information from the ini files): #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> $print = IniReadSection(".ifileprinterlist.ini","PRINTERS") $port = IniReadSection(".ifileportlist.ini","PORTS") $queue = IniReadSection(".ifilequeuelist.ini","QUEUE") $queuemini = IniReadSection(".ifilequeuelist2.ini","QUEUE") globaL $PrintGUI = GUICreate("Printer Installation Assistant", 530, 349, 192, 114) GUISetBkColor(0xA6CAF0) $EnterPC = GUICtrlCreateInput("", 160, 45, 225, 21) $PCNum = GUICtrlCreateLabel("Enter PC number:", 18, 49, 107, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $PrintCombo = GUICtrlCreateCombo("", 160, 77, 225, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) For $iX = 1 To $print[0][0] GUICtrlSetData(-1, $print[$iX][0],"") Next $PortCombo = GUICtrlCreateCombo("", 160, 110, 225, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) For $iY = 1 To $port[0][0] GUICtrlSetData(-1, $port[$iY][0],"") Next $QueueCombo = GUICtrlCreateCombo("", 160, 141, 225, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) For $iZ = 1 To $queue[0][0] GUICtrlSetData(-1, $queue[$iZ][0],"") Next I am trying to use this code: CredCheckPrint.au3 to call this code: Printer Install.au3 as an adminstrator. What I have posted above is the the first part of Printer Install.au3. When Printer Install.au3 is run on its own (compiled or uncompiled), it works absolutely perfectly. If I try to runas from the CredCheckPrint.au3 file, it fails with "Subscript used with non-Array variable error". It cites line 1591 of the Printer Install script as the culprit, but this line does not exist. I can use the CredCheck script to run other scripts with no issue. If I right click Printer Install and Run as an admin manually, it works fine. I am at a loss and I know there is something in the way I have used the array that is not working. There are more combo boxes further down the script (different GUI's) that use the same method as is shown above. I know very little about arrays and have borrowed this from someone on this forum. Once I get this working I am going to post and credit it to who I borrowed it from. Thanks in advance for any help. Edit: Needed to make more sense at the beginning.
  16. And I'm glad that there are people such as yourself kind enough to donate time to helping where you can. It's not like you guys get paid or anything! I totally respect that. Also, I just noticed that you are a neighbor! Well, close anyways. I'm in Bendigo, Vic. I'll chuck a paper plane and see if it reaches you!
  17. Sorry to take so long to answer enaiman. I have been furiously learning and correcting everything and it is now working. You were right, obviously, about the correct handle! The script is to assist us in renaming a profile and copying files across that are not kept on servers - nk2 file (what outlook uses to store those email addresses you have previously typed in the "To" field), signatures folder and desktop items. Sometimes things are forgotten, so this will assist with minimizing that. I thought I would post all the code that I have done in case it can help anyone else. I don't often get to contribute, so here's my chance! What it does in a nutshell: Opens GUI, asks for username and PC numberOpens a "Killswitch" GUI that can be used to kill the script at any point.Checks that PC is online and the Users folder exists.Checks that the folders requested to be copied are there and adjusts itself accordinglyNotes the number of files in each folderRenames the folderCopies a file to the remote machine to do the copying locally (faster)Checks each folder being copied and compares to earlier checks to make sure they have all been copiedCleans up any files created and exits.EDIT: Code is too large to post. Tried to upload, but our proxy is not playing. Will try later. Thanks for being such a great community! EDIT: Yay! Used the simple uploader instead. Here ya go: MAIN CODE: Rename copy.au3 KILLSWITCH CODE: killswitch.au3 FILE TO COPY TO REMOTE MACHINE: profilecopy.au3 Any criticism is welcome, and I hope this helps a newbie one day! EDIT: Main code updated to create a random 4 letter mix instead of "old." in case old.username already exists. File to copy to machine updated to know what to put before the renamed profile Killswitch updated as I found it would not kill the rename progress bar. It does now.
  18. *sigh* Thanks enaiman. I will have a go. I tried guidelete in end1 with no luck. The bar just keeps scrolling. Guess I have more to learn than I thought.
  19. Firstly, please let me apologise for the huge block of code, but it's so you can see what I am trying to do. Code here: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <progressconstants.au3> #include <GuiStatusBar.au3> #Include <File.au3> #Include <Array.au3> #include <Constants.au3> ;INITIAL FORM $Form1_1 = GUICreate("Form1", 396, 181, 192, 114) GUISetBkColor(0xA6CAF0) $Label3 = GUICtrlCreateLabel("Enter Users ADM Number", 38, 17, 126, 17) $useradm = GUICtrlCreateInput("EG: ADM1234", 185, 14, 177, 21) $useradm2 = GUICtrlRead($useradm) $Label4 = GUICtrlCreateLabel("Enter Users PC Number", 45, 61, 116, 17) $userpc = GUICtrlCreateInput("EG: PCH1234", 186, 55, 177, 21) $userpc2 = GUICtrlRead($userpc) $MyButton1 = GUICtrlCreateButton("COPY!", 224, 96, 100, 30, BitOR($BS_NOTIFY,$BS_FLAT)) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlSetOnEvent($MyButton1, "rename") ;CALLS FIRST FUNCTION $MyButton2 = GUICtrlCreateButton("EXIT", 40, 96, 100, 30, BitOR($BS_NOTIFY,$BS_FLAT)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlSetOnEvent($MyButton2, "cancel") ;CLOSES GUI GUISetState(@SW_SHOW) OPT("GUIOnEventMode",1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ;RENAMES USERS PROFILE FOLDER func rename () $owner = @Username $userpc2 = GUICtrlRead($userpc) $useradm2 = GUICtrlRead($useradm) call("progress1") ;CALLS PROGRESS BAR run("\\server\filepath\Admin Support.bat") sleep(500) WinSetState("cmd /k net use x: \\server\filepath && x: (running as domain\"&$owner&"_a)","",@SW_RESTORE) sleep(1000) ControlSend("cmd /k net use x: \\server\filepath&& x: (running as domain\"&$owner&"_a)","","","title Administrator") ControlSend("cmd /k net use x: \\server\filepath && x: (running as domain\"&$owner&"_a)","","","{enter}") sleep(1000) ControlSend("Administrator","","","psexec \\"&$userpc2&": cmd","","","cd\") ControlSend("\\"&$userpc2&": cmd","","","cd ""documents and settings""") ControlSend("\\"&$userpc2&": cmd","","","rename "&$useradm2&" old."&$useradm2&"") ControlSend("\\"&$userpc2&": cmd") while 1 if FileExists ("\\"&$userpc2&"\c$\Documents and Settings\old."&$useradm2&"") Then Call("end1") ;CALLS END OF PROGRESS BAR EndIf sleep(100) WEnd EndFunc Func progress1 () $g = GUICreate("test",200,50,-1,-1,$WS_POPUP) global $l = GUICtrlCreateLabel("Running", 20, 35, 120, 21) GUISetBkColor(0x00BFFF) GUISetState() global $progress = GUICtrlCreateProgress(0, 0, 200, 30, $PBS_MARQUEE) _SendMessage(GUICtrlGetHandle($progress), $PBM_SETMARQUEE, 1, 200) GUICtrlSetData($l, "Renaming profile...") EndFunc Func end1 () global $l = GUICtrlCreateLabel("Running", 20, 35, 120, 21) global $progress = GUICtrlCreateProgress(0, 0, 200, 30, $PBS_MARQUEE) GUICtrlSetData($l, "All done!") guictrlDelete($progress) Sleep(300) call("gogogo") ;CALLS ANOTHER GUI SCREEN Exit ;;;; I KNOW THIS SHOULD NOT BE HERE, BUT WHAT INSTEAD?? EndFunc Func gogogo () ;THIS FORM APPEARS, BUT CANNOT START. ALSO, HOW TO MAKE IT DISAPPEAR WHEN OK IS PRESSED? #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> $Form1 = GUICreate("Form1", 309, 138, 192, 114) $Label1 = GUICtrlCreateLabel("When the user has signed back", 8, 8, 294, 26) GUICtrlSetFont(-1, 14, 800, 0, "Arial") GUICtrlSetColor(-1, 0xFF0000) $Label2 = GUICtrlCreateLabel("on, click OK!", 96, 40, 120, 26) GUICtrlSetFont(-1, 14, 800, 0, "Arial") GUICtrlSetColor(-1, 0xFF0000) $GoGoGo = GUICtrlCreateButton("OK", 104, 88, 100, 30, BitOR($BS_NOTIFY,$BS_FLAT)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetBkColor(-1, 0x008000) GUICtrlSetOnEvent($GoGoGo, "start") ;CALLS START FUNCTION. ANYTHING ELSE TO CLOSE THE WINDOW? GUISetState(@SW_SHOW) OPT("GUIOnEventMode",1) EndFunc Func start () ; COPIES A SMALL FILE TO USERS PC. COPIES FILES DIRECTLY ON THE PC REDUCING COPY TIME.CHECKS THAT ALL FILES MATCH. $owner = @Username $userpc2 = GUICtrlRead($userpc) $useradm2 = GUICtrlRead($useradm) call("progress2") ;;;;; CALLS NEW PROGRESS BAR. IS THIS EVEN NEEDED?? $sig = _FileListToArray("\\"&$userpc2&"\c$\Documents and Settings\"&$useradm2&"\Application Data\Microsoft\Signatures","*") _FileWriteFromArray("c:\sig.log",$sig) _FileCountLines("c\sig.log") sleep(1000) $nk2 = _FileListToArray("\\"&$userpc2&"\c$\Documents and Settings\"&$useradm2&"\Application Data\Microsoft\Outlook","*") _FileWriteFromArray("c:\nk2.log",$nk2) _FileCountLines("c\nk2.log") sleep(1000) $desk = _FileListToArray("\\"&$userpc2&"\c$\Documents and Settings\"&$useradm2&"\Desktop","*") _FileWriteFromArray("c:\desk.log",$desk) _FileCountLines("c\desk.log") sleep(1000) IniWrite("c:\copy.ini","ID","useradm",$useradm2) run("\\server\filepath\Admin Support.bat") sleep(100) WinSetState("cmd /k net use x: \\server\filepath && x: (running as domain\"&$owner&"_a)","",@SW_HIDE) sleep(1000) ControlSend("cmd /k net use x: \\server\filepath && x: (running as domain\"&$owner&"_a)","","","title Administrator") ControlSend("cmd /k net use x: \\server\filepath && x: (running as domain\"&$owner&"_a)","","","{enter}") sleep(4000) controlSend("Administrator","","","xcopy ""\\server\filepath\Nothing to see here\profilecopy.exe"" \\"&$userpc2&"\c$") controlSend("Administrator","","","{enter}") sleep(500) controlSend("Administrator","","","y") controlSend("Administrator","","","{enter}") sleep(500) controlSend("Administrator","","","xcopy ""c:\copy.ini"" \\"&$userpc2&"\c$") controlSend("Administrator","","","{enter}") sleep(500) controlSend("Administrator","","","y") controlSend("Administrator","","","{enter}") sleep(500) controlSend("Administrator","","","start \\"&$userpc2&"\c$\profilecopy.exe") controlSend("Administrator","","","{enter}") while 1 $readsig = fileopen("c:\sig.log",0) $linesig = FileReadLine($readsig,1) $readnk2 = fileopen("c:\nk2.log",0) $linenk2 = FileReadLine($readnk2,1) $readdesk = fileopen("c:\desk.log",0) $linedesk = FileReadLine($readdesk,1) $sig2 = _FileListToArray("\\"&$userpc2&"\c$\Documents and Settings\"&$useradm2&"\Application Data\Microsoft\Signatures","*") _FileWriteFromArray("c:\sig2.log",$sig2) _FileCountLines("c\sig2.log") sleep(100) $readsig2 = fileopen("c:\sig2.log",0) $linesig2 = FileReadLine($readsig2,1) $nk22 = _FileListToArray("\\"&$userpc2&"\c$\Documents and Settings\"&$useradm2&"\Application Data\Microsoft\Outlook","*") _FileWriteFromArray("c:\nk22.log",$nk22) _FileCountLines("c\nk22.log") sleep(100) $readnk22 = fileopen("c:\nk22.log",0) $linenk22 = FileReadLine($readnk22,1) $desk2 = _FileListToArray("\\"&$userpc2&"\c$\Documents and Settings\"&$useradm2&"\Desktop","*") _FileWriteFromArray("c:\desk2.log",$desk2) _FileCountLines("c\desk2.log") sleep(100) $readdesk2 = fileopen("c:\desk2.log",0) $linedesk2 = FileReadLine($readdesk2,1) if $linesig = $linesig2 And $linenk2 = $linenk22 And $linedesk = $linedesk2 Then call("end2") ;CALLS END TO SECOND PROGRESS BAR EndIf WEnd endfunc Func progress2 () $g = GUICreate("test",200,50,-1,-1,$WS_POPUP) global $l = GUICtrlCreateLabel("Running", 20, 35, 120, 21) GUISetBkColor(0x00BFFF) GUISetState() global $progress = GUICtrlCreateProgress(0, 0, 200, 30, $PBS_MARQUEE) _SendMessage(GUICtrlGetHandle($progress), $PBM_SETMARQUEE, 1, 200) GUICtrlSetData($l, "Copying Files...") EndFunc Func end2 () global $l = GUICtrlCreateLabel("Running", 20, 35, 120, 21) global $progress = GUICtrlCreateProgress(0, 0, 200, 30, $PBS_MARQUEE) GUICtrlSetData($l, "All done!") guictrlDelete($progress) Sleep(300) call("cancel") ;;CALLS ENDING FUNCTION exit EndFunc Func cancel () ;CLEARS OUT FILES NOT NEEDED ANYMORE AND ENDS $userpc2 = GUICtrlRead($userpc) $useradm2 = GUICtrlRead($useradm) FileDelete("c:\sig.log") FileDelete("c:\nk2.log") FileDelete("c:\desk.log") FileDelete("c:\sig2.log") FileDelete("c:\nk22.log") FileDelete("c:\desk2.log") FileDelete("c:\copy.ini") FileDelete("\\"&$userpc2&"\c$\profilecopy.exe") FileDelete("\\"&$userpc2&"\c$\copy.ini") global $l = GUICtrlCreateLabel("Running", 20, 35, 120, 21) global $progress = GUICtrlCreateProgress(0, 0, 200, 30, $PBS_MARQUEE) GUICtrlSetData($l, "All done!") guictrlDelete($progress) Sleep(300) MsgBox(0,"Fo' Shizzle!","All copied. And remember: You're Awesome!") Exit EndFunc I have put notes inside the code to try and make it easier. It runs through the first "rename" function fine (rename the users profile folder), then opens the "gogogo" form, but I can't click on the start button. It just does nothing. I am also trying to figure out how to close this window. I have noted that the "Exit" in the "end1" function should not be there, but what should be there instead? The progress bar just stays open. I get the feeling this is why it is not going anywhere - because a function is still open. But I don't know how to end it without ending the whole script? On their own, these functions work perfectly. I have done a piece at a time, then put it all together, It is also my first large continuous piece. Thank you so much for any help!!
  20. Thanks Beege, I have figured it out now. I had issues including @UserProfileDir into the runwait command, but figured it all out. Runs like I need it to and I have a couple of happy users and a slightly impressed boss. My work here is done...
  21. Well, there you go! Thanks so much! Did not know that existed. This is going to help me out alot.
  22. I am using this in a bigger script, but once I get it working on this smaller scale, I should be good with the bigger one. Code I am using: Run(@ComSpec & " /c c: && cd %userprofile% && echo %userprofile% > c:\NAME.txt","",@SW_HIDE) $name1 = fileopen("c:\NAME.txt",0) FileReadLine($name1,1) $data = FileReadLine($name1,1) DirCreate($data&"\TEST") Basically: Use CMD to get username path Write that path to a TXT file Read the path Use this info as a variable ($data) If I add a msgbox, it reads it out just fine, but the folder is not created. No errors occur and exit code is zero. As always, any help is welcomed!
  23. Thanks for your help kylomas. I headed home for the weekend before I got a chance to see your post (I can't test what I need to do at home). I ended up figuring it out, as per below: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("Form1", 188, 131, 192, 114) $Label1 = GUICtrlCreateLabel("Enter your ADM number", 8, 8, 170, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") $input = GUICtrlCreateInput("", 16, 32, 145, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $data = GUICtrlRead($input) $MyButton1 = GUICtrlCreateButton("OK", 56, 64, 68, 30, BitOR($BS_NOTIFY,$BS_FLAT)) GUICtrlSetOnEvent($MyButton1, "adm") $Please = GUICtrlCreateLabel("Please wait for ""Complete"" message", 8, 104, 175, 17) GUISetState(@SW_SHOW) Opt("GUIOnEventMode", 1) While 1 sleep(10) WEnd func adm () $data = GUICtrlRead($input) RunAsWait("Username","Domain","Password",2,@ComSpec & " /c pskill iexplore","",@SW_HIDE) RunAsWait("Username","Domain","Password",2,@ComSpec & " /c rmdir /s /q ""C:Documents and Settings"&$data&"cookies") RunAsWait("Username","Domain","Password",2,@ComSpec & " /c rmdir /s /q ""C:Documents and Settings"&$data&"Local settingsTemporary internet files") if FileExists("C:Documents and Settings"&$data&"cookies*.txt") Then MsgBox (0,"","Failed :(") Exit Else MsgBox (0,"","Complete! :)") Exit endif EndFunc Exit Once it is in an executable, the username and password will be inaccessible. I could not see where I would put the Admin credentials in your script? I am assuming "Local $rc" is what you were using. Our machine unfotunately do not have local administrator accounts, but do have an admin group built into it. This is where the difficulty started. Now I am trying add a progress bar that shows percentage done. Not proving easy! Thanks again guys.
  24. Thanks for the input Chimaera, but as mentioned, this is on XP, so #RequireAdmin does not help, unfortunately. I tried, as clutching at straws is what I do best, but was unsuccessful.
  25. I need a portion of my code to run as an administrator. Basically I need to insert the username and password of an administration account for the code to do what I want without interaction from our helpdesk. It will save us and some of our users a bit of time. Code: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("Form1", 187, 109, 192, 114) $Label1 = GUICtrlCreateLabel("Enter your Username", 8, 8, 170, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") $input = GUICtrlCreateInput("", 16, 32, 145, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $data = GUICtrlRead($input) $MyButton1 = GUICtrlCreateButton("OK", 56, 64, 68, 30, BitOR($BS_NOTIFY,$BS_FLAT)) GUICtrlSetOnEvent($MyButton1, "Username") GUISetState(@SW_SHOW) Opt("GUIOnEventMode", 1) While 1 sleep(10) WEnd func Username () ;need below to run as administrator ProcessClose("iexplore") DirRemove("c:documents and settings" & $input & "cookies") DirRemove("c:documents and settings" & $input & "local settingstemporary internet files") Exit EndFunc Exit Once it is in an executable, no one will be able to find the admin pass of course (unless they want to go through reverse engineering it of course. Not in our organization). Running on Win XP SP3 Any help is appreciated.
×
×
  • Create New...