Jump to content

mrrlg

Active Members
  • Posts

    98
  • Joined

  • Last visited

mrrlg's Achievements

Wayfarer

Wayfarer (2/7)

0

Reputation

  1. Great script! When I apply the executable to remote machines as part of a log on script, it only works on those machines where the logging on user has admin rights. Is there a way to incorporate a run as admin function within the executable?
  2. I would be very interested in looking at your scripts, when I ran the setACL.exe example to list folder contents it generated a large amount of text that I don't understand.
  3. I am trying to do something that is far beyond my meager scripting abilities. My problem is this, I have a member server that has 200 plus local user accounts that have varying degrees of ntfs permissions to folders, sub-folders and files on this server. I am trying to come up with some sort of a script that I can run at the folder level that will tell me the user names and permissions sorted at the sub folder and or file level. Any ideas, hints suggestions will be greatly appreciated.
  4. I have a script that has been running for a couple of years now. I made a few changes to it and it appears to be failing at this line: AutoItSetOption ( "RunErrorsFatal", 0), how would I convert this to keep the script running?
  5. I am looking for a script that will allow me to find and export to a text file all users who belong to a security group in Active Directory. Is such a script available?
  6. In the example I printed above the H:\ drive share is the home directory of the logged on user and I am able to write to folders within it. As to the time left running in the background I gave up after 15 minutesd.
  7. I am trying to use adfunctions to extract the members of local groups on member servers that are not domain controllers. I have been able to get the script to work after a fashion. It will create and populate the text file, but the script pauses and fails to create the csv file on the public share. I then have to end the script before I can rerun the script to extract members of another local group (there are several groups on the server that need to be checked on a monthly basis). Any ideas? ; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.0 ; Author: Ben Sherrill ; ; Script Function: ; Use CMD Prompt to run a Net Localgroups Administrators. ;~ The Using STDOUT move that data to a text file. ; Once the text file is created use ReadLine to get the specific users that are admins on the computer ;~ Create as CSV file for easier sorting of the computer name ; ---------------------------------------------------------------------------- #include <Constants.au3> #include <Process.au3> #include <File.au3> ;~ Check to see if this has already been run on the computer ;If FileExists("C:\No Streaming Media.txt") Then ; Exit ;EndIf FileDelete("C:\No Streaming Media.txt");used for testing purposes ; Start up the CMD Prompt $cmd = Run(@ComSpec & "", @SystemDir, @SW_SHOW, 7) ; Write the desired commands + RETURNs to the child's STDIN StdinWrite ($cmd, 'net localgroup "No Streaming Media"' & @CRLF & "exit" & @CRLF) ; Loop and retrieve all data from the CMD Window While 1 $line = StdoutRead ($cmd) If @error = -1 Then ExitLoop $file = FileOpen("C:\No Streaming Media.txt", 1) FileWrite($file, $line) FileClose($file) WEnd ;Exit ; Loop and collect any error messsages from the child program While 1 $line = StderrRead ($cmd) If @error = -1 Then ExitLoop MsgBox(0, "STDERR read:", $line) WEnd ;Reopen the Txt file located on the users C Drive for reading purposes $file = FileOpen("C:\No Streaming Media.txt", 0) $line11 = FileReadLine($file, 11) $line12 = FileReadLine($file, 12) $line13 = FileReadLine($file, 13) $line14 = FileReadLine($file, 14) $line15 = FileReadLine($file, 15) $line16 = FileReadLine($file, 16) $line17 = FileReadLine($file, 17) ;~ MsgBox(0,"test",$line11);testing purposes ; Now that the lines have been read and values have been given, create a CSV file on a Public Server for all IT to look at $pc_admins = "H:\Users\localusers.csv" ; Open the file on the public server for writing purposes FileOpen($pc_admins, 1) ; Write the following Data - The Computer name LINE11(first Admin line)- Line17 more lines could be added. Possible array here? not sure? FileWrite($pc_admins, @CRLF & @ComputerName & "," & $line11 & "," & $line12 & "," & $line13 & "," & $line14 & "," & $line15 & "," & $line16 & "," & $line17) ; Data has been written, now close file and exit script FileClose($pc_admins) Exit
  8. When I define the source and destination and attempt to run your script, nothing happens. What am I doing wrong? $dir="C:\salesreports\"$dest="C:\archive\sales\" Func _ExtractDir($dir,$dest) $search = FileFindFirstFile($dir & "*.*") If $search <> -1 Then While 1 $file = FileFindNextFile($search) If @error Then ExitLoop EndIf If StringInStr(StringRight($file,4),".") = 1 Then $destfile = $dest & StringReplace($dir & $file,"\","-") FileCopy($dir & "\" & $file,$destfile) Else _ExtractDir($dir & $file & "\",$dest) EndIf WEnd FileClose($search) EndIf EndFunc
  9. Thank you for your prompt reply, what you are suggesting is far beyond my meager talents but I will give it a go!
  10. I have been using this script to move files older then 14 days to an archive folder. It works perfectly when the file name is unique in each of the folders and subfolders. Now I have a situation where the same file will be written to multiple folders. Currently, when I run this script it moves the file and overwrites it until I have only one copy left from the last folder alphabetically that the script touched. Is there a way to write this script to recreate the existing folder structure under the archive folder and write the old files to that location? That way file sales00007 which is generated daily in each of the sales reps folders will be archived. [/code]; Script Function: ; Move files older than 14 days #include <date.au3> AutoItSetOption ( "RunErrorsFatal", 0) ;AutoItSetOption ( "TrayIconHide", 1) Break(0) $Hotkey = "{Pause}" HotKeySet ($Hotkey ,"StopExec") $L_Msg = "" ; init variables $Version = "0.2" $dir="C:\salesreports" $Dircount = 0 $n_FileCount = 0 $n_FileSize = 0 ;$begin = TimerStart() $rc = _Remove_Files($Dir, 1,14) Exit ;=============================================================================== ; ;=============================================================================== Func _Remove_Files($T_Dir,$T_Incl_SubDir,$T_Days) Dim $n_Dirnames[200000][3]; max number of directories that can be counted Local $n_DirCount = 0 Local $n_File Local $n_Search Local $n_tFile Local $n_Fdate Writelog("### Start run ###") $T_DirCount = 1 $T_FileCount = 0 $T_FileSize = 0 ; remove the end \ If StringRight($T_Dir,1) = "\" then $T_Dir = StringTrimRight($T_Dir,1) $n_Dirnames[$T_DirCount][0] = $T_Dir $n_Dirnames[$T_DirCount][1] = 0 $T_Incl_SubDir = Int($T_Incl_SubDir) ; Exit if base dir doesn't exists If Not FileExists($T_Dir) then Return 0 ; keep on looping until all directories are counted While $T_DirCount > $n_DirCount $n_DirCount = $n_DirCount + 1 $n_Search = FileFindFirstFile($n_Dirnames[$n_DirCount][0] & "\*.*" ) If $n_Search = -1 Then ContinueLoop EndIf ShowMenu("Processing directory:" & @LF & $n_Dirnames[$n_DirCount][0],0) While 1 $n_File = FileFindNextFile($n_Search) If @error Then ExitLoop $n_tFile = $n_Dirnames[$n_DirCount][0] & "\" & $n_File ShowMenu(" File :" & $n_File,2) ; skip these references if $n_File = "." or $n_File = ".." then ContinueLoop EndIf ; if Directory than add to the list to be processed later If StringInstr(FileGetAttrib ( $n_tFile ),"D") > 0 then If $T_Incl_SubDir = 1 then $T_DirCount = $T_DirCount + 1 $n_Dirnames[$T_DirCount][0] = $n_tFile $n_Dirnames[$T_DirCount][1] = 0 EndIf Else ; Check age of the file $n_Fdate = FileGetTime($n_tFile,0) $sdate=$n_Fdate[0] & "/" & $n_Fdate[1] & "/" & $n_Fdate[2] & " " & $n_Fdate[3] & ":" & $n_Fdate[4] & ":" & $n_Fdate[5] $edate=@YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC If _DateDiff ('d',$sdate,$eDate) > $T_Days then $rc = FileMove ($n_tFile, "c:\archive\salesreports") ; $rc = FileRecycle($n_tFile) Writelog($sdate & " " & _DateDiff ('d',$sdate,$eDate) & " *** rc:" & $rc & " move-> " & $n_tFile) Else ; add 1 to filecount for this directory ;Writelog(" Keep -> " & $n_tFile) Writelog(" Keep -> " & $n_tFile & " ModifiedDate:" & $sdate & " Days old:" & _DateDiff ('d',$sdate,$eDate)) $n_Dirnames[$n_DirCount][1] = $n_Dirnames[$n_DirCount][1] + 1 EndIf EndIf Wend FileClose($n_Search) Wend Writelog("### Removing empty directories ###") For $x = $T_DirCount to 2 step -1 Writelog("Dir: " & $n_Dirnames[$x][0] & " Files:" & $n_Dirnames[$x][1]) If $n_Dirnames[$x][1] = 0 then If "user\hidden" <> StringRight($n_Dirnames[$x][0],11) then DirRemove ($n_Dirnames[$x][0]) Writelog("Remove Dir: " & $n_Dirnames[$x][0]) EndIF EndIf Next Writelog("### End Run ###") Return ( 1 ) EndFunc ; ;====================================== ; Stop executing when Hotkey is pressed ;====================================== Func StopExec() $mrc=Msgbox(4,"Cancel Execution?","You pressed " & $Hotkey & ". Do you want to cancel the Program?") if $mrc = 6 then writelog("*** Utility Cancelled by operator.") Exit EndIf Return EndFunc ;===================================================== ; Show Splash screen or update its content ;===================================================== Func ShowMenu($g_msg,$concat) $W_Title=" file remove Utility (ver:" & $Version & ") Press " & $Hotkey & " to stop execution" $D_msg = "" If $concat > 0 Then If $concat = 1 Then $L_msg = $L_msg & @LF & $g_msg $d_msg = $L_msg Else $d_msg = $L_msg & @LF & $g_msg EndIf Else $L_msg = $g_msg $d_msg = $g_msg EndIf if WinExists($W_Title) then ControlSetText($W_Title,"","Static1",$d_msg) else SplashTextOn($W_Title,$d_msg,800,100,1,1,6,"Courier",10,600) endif Return 0 EndFunc ;============================== ; Write to logfile ;============================== Func WriteLog($msg) $msg = @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " " & "==>" & $msg FileWriteLine(@ScriptDir & "\RemFiles3.log", $msg ) Return 0 EndFunc[code]
  11. In one of the much earlier verions of AutoIt I seem to recall there was a folder of custom icons. Are these icons still available and if so where might I find them?
  12. I upgraded from beta version 3.1.1.104 to 3.1.1.122 and generated the exact same error at line 279. $treeIDArray[$treeID] = $fullOU ^ =Array variable has incorrect number of sub scripts or subscript dimension range exceeded. Perhaps you might have another idea.
  13. Wonderful work, my compliments. I have a little problem with line 279 and I am certain it has to do with how my domain is laid out. I receive this error at: $treeIDArray[$treeID] = $fullOU ^ =Array variable has incorrect number of sub scripts or subscript dimension range exceeded.
  14. When I run the executable on the machine I created the script, it runs correctly. When I move it to the server I immediately get three gui errors "Mail failed with error code 50". This server has no mail client (Lotus Notes). I then tried this on a server with a mail client and got the same errors. I even moved it to another machine that has my mail client on it and I also received the same three errors. Could it be that there is a file or files from AutoIt itself that are being called when the script is running?
  15. When I run this as a .au3 script it works properly. When I convert it to an executable using 3.1 beta, it fails with three error messages (error code 50). What could be the problem? I am trying to run the executable as a scheduled task. #include <INet.au3> ;''Settings'' $folder = 'c:\lgeai\trio\';-- With trailing backslash $filenames = '*.*';-- Wildcards accepted. $WhatTime = 0;---0,1 or 2 as FileGetTime option $y= @YEAR $m= @MON $d= @MDAY ;''Code'' $Handle = FileFindFirstFile($folder & $filenames) If $Handle = -1 Then MsgBox(0, "Error", "No files matched the search pattern") Exit EndIf $c = 0 While 1 $file = $folder & FileFindNextFile($Handle) If @error Then ExitLoop $time = FileGetTime ( $file , $WhatTime ) If $time[0] = $y AND $time[1] = $m AND $time[2] = $d Then $c = $c + 1 ;MsgBox (0, "date", @YEAR & "_" & @MON & "_" & @MDAY) $s_SmtpServer = "10.X.X.X" $s_FromName = "SNA Messenger" $s_FromAddress = "snamessenger@sna.com" $s_ToAddress = "snasapr@sna.com" $s_Subject = "SAP FTP Upload" Dim $as_Body[2] $as_Body[0] = "SAP successfully uploaded files to SLC FTP." $as_Body[1] = "This is an automated message" $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body) $err = @error If $Response = 1 Then If $c=2 Then MsgBox(0, "Success!", "Mail sent" , 5) Else If $c<3 Then MsgBox(0, "Error!", "Mail failed with error code " & $err, 5) EndIf EndIf WEnd FileClose($Handle) If $c = 0 Then MsgBox (0, "Error", "No files matched the requested time", 5)
×
×
  • Create New...