DavidLago Posted September 28, 2012 Posted September 28, 2012 (edited) Well, I've reached the loop point. I really don't know what to think or to do anymore Let me try to explain. This script I'll post below export the output of the the command "openfiles" on cmd, and it has an option to filter the logs to something that the analyst want to check in particular. For example. I wanna know how many guys are accessing the folder "X:folder1" or how many folders is the computer "Computer342312" accessing through the DFS. expandcollapse popup;---------------------------------------------------------------INCLUDES-------------------------------------------------------------------------------- #include <Process.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> #include <INet.au3> #include <Date.au3> ;------------------------------------------------------------EXPORT-FOLDER-------------------------------------------------------------------------------- If Not FileExists(@ScriptDir & "Export") Then DirCreate(@ScriptDir & "Export") EndIf ;------------------------------------------------------------ WHILE LOOP -------------------------------------------------------------------------------- Global $iNow = _NowCalc() Global $TimeOut = False While $TimeOut = False ;---------------------------------------------------------VARIABLES----------------------------------------------------------------------------------- Global $Date = @YEAR & "-" & @MON & "-" & @MDAY Global $Hour = @HOUR & "-" & @MIN & "--" Global $FullDate = $Date & "_" & $Hour Global $ReportDir = @ScriptDir & "Export" ;----------------------------------------------------------INI_READ----------------------------------------------------------------------------------- Global $TimeFreq = IniRead("Config.ini", "Time", "Frequency", "60") Global $TimeDur = IniRead("Config.ini", "Time", "Duration", "24") Global $ReportOut = $FullDate & "_" & IniRead("Config.ini", "ReportOut", "ReportOut", "Report") Global $FilterExt = IniRead("Config.ini", "FilterExt", "FilterExt", "N") Global $FileExt = '"' & IniRead("Config.ini", "FileExt", "FileExt", "exe") & '"' Global $FormatOut = IniRead("Config.ini", "FormatOut", "FormatOut", "Table") ;-------------------------------------------------------ADVANCED VARIABLES----------------------------------------------------------------------------- Global $CommandCombo, $CommandFinal, $iDiff, $FreqDurMath $iTimeFreq = $TimeFreq * 60000 ; Turn to miliseconds $iTimeDur = $TimeDur ; Turn to minutes $FreqDurMath = ($TimeDur * 60) / $TimeFreq ;-------------------------------------------------------ERROR-TREATMENT--------------------------------------------------------------------------------- If $iTimeFreq < 900000 Then MsgBox(4112, "Error", 'The parameter "FREQUENCY" at the config.ini file is set to a number below 15. 15 minutes is the minumum threshold', 5) Exit EndIf If $FreqDurMath < 1 Then If MsgBox(4116, "Error", 'The parameters "FREQUENCY" and "DURATION" at the config.ini file is set to a number which prevents it to loop more than once. Do you want to continue?', 10) = 7 Then Exit EndIf ;----------------------------------------------------------COMMAND BREED I------------------------------------------------------------------------------- Global $QueryCommand = "/query " & "/FO " & $FormatOut & " /V " & "/nh " Global $FindCommand = "| find /I " & $FileExt Global $ExportCommand = " > " & '"' & $ReportDir & $ReportOut & ".log" & '"' ;----------------------------------------------------------COMMAND BREED II------------------------------------------------------------------------------ If $FilterExt = "Y" Then $CommandCombo = $QueryCommand & $FindCommand & $ExportCommand Else $CommandCombo = $QueryCommand & $ExportCommand EndIf $CommandFinal = "openfiles " & $CommandCombo ;-------------------------------------------------------------OPTIONS----------------------------------------------------------------------------------- If $FilterExt = "Y" Then If $FileExt <> "" Then TrayTip("Message from the " & @ScriptName & " Script: ", 'The command "' & $CommandFinal & '" is running in this server. Options enabled are the following:' & @CRLF & @CRLF & "Filter: " & '"' & $FilterExt & '"' & @CRLF & "Ext/String: " & $FileExt & @CRLF, 1, 1) FileWriteLine(@ScriptDir & "" & "CommandOut.txt", $CommandFinal) Else TrayTip("Message from the " & @ScriptName & " Script: ", 'The command "' & $CommandFinal & '" is running in this server.', 1, 1) FileWriteLine(@ScriptDir & "" & "CommandOut.txt", $CommandFinal) EndIf EndIf ;-----------------------------------------------------------MAIN COMMAND--------------------------------------------------------------------------------- ;--------MAIN COMMAND----------------------------------- _RunDOS($CommandFinal) ;--------MAIN COMMAND----------------------------------- $iDiff = _DateDiff('h', $iNow, _NowCalc()) Sleep($iTimeFreq) ;Frequency, If $iDiff > $iTimeDur Then $TimeOut = True EndIf If $TimeOut = True Then Exit WEnd ;==> While from line 20 The ini File is the following: [Time] # What frequency? (Minutes [minimum: 15 min) / How long? (Hours [Minimum: 1H) Frequency = 15 Duration = 1 [FilterExt] # GREP Extension/String? ( Y, N) FilterExt = Y [FileExt] # What's the extension or string combo to be matched? (.exe; .doc; .csv; Solidworks; Report, etc. (default: line commented by #) FileExt = C:Sharing [ReportOut] # LogFile Sufix ReportOut = Report [FormatOut] # LogFile Format: CSV or Table. (default: table) FormatOut = CSV So, It wasn't working. I tried to debug every line and it still didn't find anything wrong, so I created a filewriteline that writes down the SAME command that _RunDOS is running before it runs it. And if you copy and paste this command on the cmd line, it works, but the same command within _RunDOS generates a logfile with 0kb. To test it you must create a sharing in your computer, and access a file like a .doc or .xls from another computer, then use the filter on the .ini file. Check the the file in the EXPORT folder, it has 0kb. Delete it, and run on cmd the same exported command at scriptdir file "CommandOut.txt" and now, explain why it doesn't work. It makes 0 sense. Edited September 28, 2012 by HellFrost
FireFox Posted September 28, 2012 Posted September 28, 2012 Please, run a test and try to help me figure this out...Wow, be patient. Wait at least 1 DAY before bumping your topic.Br, FireFox.
DavidLago Posted September 28, 2012 Author Posted September 28, 2012 But I just found a new symptom! It runs on a Windows Server 2003 perfectly but it doesn't on a Windows Server 2008. That sucks Does anyone have any idea about any difference about permissions that disables _RunDOS to run?
Moderators Melba23 Posted September 28, 2012 Moderators Posted September 28, 2012 HellFrost, Please do not bump this thread again today. Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You will just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. And there is no need to reply to this post either. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
DavidLago Posted October 8, 2012 Author Posted October 8, 2012 Hello. That seems to be no way to make this work from within a AutoIt Script. To solve this problem I created a Scheduled Task, with a batch file as this: cls REM @echo off SET DATETIME="" SET DATETIME=%date:~-4,4%-%date:~-7,2%-%date:~-10,2%--%time:~0,2%h%time:~3,2%m%time:~6,2%s openfiles /query /FO CSV /V /nh | find /I "I:PUBLICBSCJGWMDOC_CLIENTS" >> "C:SCRIPTSOpenFilesReport%DATETIME%-report.log" If you're gonna use this way, remember to set the "start in" field as the place you want the logs to be saved at. It doesn't work otherwise this is set. Thanks.
UEZ Posted October 8, 2012 Posted October 8, 2012 Is your Server 2008 x64 or x86 version? Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
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