PeterAtkin
Active Members-
Posts
105 -
Joined
-
Last visited
About PeterAtkin
- Birthday 06/20/1966
Profile Information
-
Location
Uganda
-
WWW
http://www.cfts.co
-
Interests
scripting for a better life.
PeterAtkin's Achievements
Adventurer (3/7)
0
Reputation
-
Simple text placment on desktop without boarders
PeterAtkin replied to PeterAtkin's topic in AutoIt GUI Help and Support
Wow thanks, and as expected much more complex than i had anticipated, this looks like it will do the trick.. -
I'm looking for a way to have just some text 'Version Number' to be discreetly displayed without boarder and preferably overlayed so as not to disturb the background/desktop showing while the compiled script is running. I've had a look to see if these anything I could use but either I'm just not looking right or this is harder than it looks. Any pointers would be appreciated
-
@wraithdu I having issues understanding how this script is to be used whats I come up with so far is this [please bare in mind this is a snippet if you feel the full script would be required I would be more than happy to post] See code under 'Case 3' Func _mapdrive($DriveLtr, $DrivePath) Local $var, $var1, $var2, $var_DrivePath $var_DrivePath = _StringBetween($DrivePath, "\\", "\") _add_log_line($DrivePath & " " & $var_DrivePath) $var = $var_DrivePath[0] $var1 = _ping($var, 25) If $var1 Then ; so now the function will not try to connect to a device that is not present, ; make sure your firewall allows ICBM echo requests. $var2 = DriveMapAdd($DriveLtr, $DrivePath, 8) Switch @error Case 1 _add_log_line("Error! O.M.G Error, An unknown error occured on " & $DrivePath & " trying to be mapped as local drive " & $DriveLtr & " maybe end device is not avilable for mapping") $error_code = 1 Case 2 _add_log_line("Error! Access Error, Access to the remote share " & $DrivePath & " was denied") $error_code = 1 Case 3 _add_log_line("Error! Map Drive Error, The device/drive " & $DriveLtr & " is already assigned and will be deleted if possible") If DriveGetType($DriveLtr) = "Network" Then DriveMapDel($DriveLtr) ElseIf DriveGetType($DriveLtr) = "Removable" Then $drive = StringUpper(StringLeft($DriveLtr, 1)) _QueryDrive($drive,True) Else _add_log_line("Error! Map Drive Error, The device/drive " & $DriveLtr & " could not be deleted as it a " & DriveGetType($DriveLtr) & " Drive.") Beep(500, 1000) EndIf $var2 = DriveMapAdd($DriveLtr, $DrivePath, 8) If $var2 <> 1 Then _add_log_line("Error! Map Drive Error, The device/drive " & $DriveLtr & " could not be deleted") Else $var2 = DriveMapAdd($DriveLtr, $DrivePath, 8) EndIf $error_code = 1 Case 4 _add_log_line("Error! Device Error, Invalid device " & $DriveLtr & " name") $error_code = 1 Case 5 _add_log_line("Error! Connect to Remote Share Error, Invalid remote share :" & $DrivePath) $error_code = 1 Case 6 _add_log_line("Error! Password Error for user :" & @UserName & " Invalid password for " & $DriveLtr & $DrivePath) $error_code = 1 EndSwitch If $var2 = 1 Then _add_log_line("Completed! Mapped " & $DriveLtr & " to share " & $DrivePath) EndIf EndFunc ;==>_mapdrive So my question is does this make sense! I wish to use your script to remove removable USB devices that are using conflicting drive assignments which conflict with the logon script when it run. Thanks in advance for any input..
-
works a treat in Windows 7 did this if its of any help, its only a snippet but should give you the idea.. Func Network_Shortcuts() #cs Description Does a basic todyup of the array $griups and maps the 'My Network Places' shares this works for both user and groups. Dependencies _FileCreateNetworkPlace($networkResource, $name vars.ini with a section named [Network Shortcuts], format for this section is: user or group, network share to be mapped and description. [Network Shortcuts] peter = \\dc-pri-cfu\netlogon,Network Logon Domain Users = \\dc-pri-cfu\Remote Installs,Remote Install Global Veriables $network_shortcuts, $groups, $pbar $var_groups, $var_$network_shortcuts $var_network_shortcuts = generic_read_array($vars_file, "Network Shortcuts", $network_shortcuts) #ce ProgressSet($pbar, "Adding Network Shortcuts...") Local $avar, $avar_description, $avar_share, $l, $ll, $lll ConsoleWrite(@CRLF & @CRLF & ">>>> Network Shortcuts <<<< [" & $var_network_shortcuts & "]" & @CRLF) ; Read Users For $l = 1 To $var_network_shortcuts $avar_description = _StringBetween($network_shortcuts[$l][1], ",", "", +1) $var = StringLen($avar_description[0]) $avar_share = StringLeft($network_shortcuts[$l][1], StringLen($network_shortcuts[$l][1]) - $var - 1) ;Rewrite sections of the array $network_shortcuts[0][2] = "Link Description" $network_shortcuts[$l][2] = $avar_description[0] $network_shortcuts[0][1] = "Share Location" $network_shortcuts[$l][1] = $avar_share ConsoleWrite($avar_share & " = " & $avar_description[0] & " remove " & $var & " char from the right" & @CRLF) Next For $ll = 1 To $var_network_shortcuts If $network_shortcuts[$ll][0] = @UserName Then ProgressSet($pbar + 1, "Network Shortcut " & $network_shortcuts[$ll][1]) _FileCreateNetworkPlace($network_shortcuts[$ll][1], $network_shortcuts[$ll][2]) ConsoleWrite("added User [" & @UserName & "] using Share [" & $network_shortcuts[$ll][1] & "] with Description [" & $network_shortcuts[$ll][2] & "]" & @CRLF) EndIf For $lll = 1 To $var_groups If $network_shortcuts[$ll][0] = $groups[$lll][1] Then ProgressSet($pbar + 1, "Network Shortcut " & $network_shortcuts[$ll][1]) _FileCreateNetworkPlace($network_shortcuts[$ll][1], $network_shortcuts[$ll][2]) ConsoleWrite("added Group [" & $groups[$lll][1] & "] using Share [" & $network_shortcuts[$ll][1] & "] with Description [" & $network_shortcuts[$ll][2] & "]" & @CRLF) EndIf Next Next If $diags = 1 Then _ArrayDisplay($network_shortcuts, "Network Shortcuts" & " " & $l, $var_network_shortcuts, 0, "<") EndFunc ;==>Network_Shortcuts Func _FileCreateNetworkPlace($networkResource, $name) #cs The following function adds a network place to "My Network Places" $networkResource is of the form \\server\share OR http://webserver/share OR ftp://ftp.example.com/ $name can be any valid file name, i.e., it Cannot contain the characters \ / : * ? " < > | #ce Local $NHItem = @UserProfileDir & "\NetHood\" & $name DirCreate($NHItem) FileSetAttrib($NHItem, "+S") FileCreateShortcut($networkResource, $NHItem & '\target.lnk', "", "", $networkResource) IniWriteSection($NHItem & '\desktop.ini', ".ShellClassInfo", "CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}" & @LF & "Flags=2") Local $success = FileSetAttrib($NHItem & '\desktop.ini', "+SH") ;ShellExecute(@UserProfileDir & "\NetHood\" & $name) ;Open Network Place when Finished... Return $success EndFunc ;==>_FileCreateNetworkPlace
-
this looks really good, this may be a bit off topic but is it possible to get the e-mail and user settings from outlook?
-
Determining Internet Explorer Version
PeterAtkin replied to DoctorWho's topic in AutoIt General Help and Support
I like the belt and braces approach, you never know what MS will do next.... Func _IEGet() Local $sVersion = StringRegExpReplace(RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer", "Version"), "^(\d+)\..+$", "$1") If @error <> 0 Then $sVersion = FileGetVersion(@ProgramFilesDir & "\Internet Explorer\iexplore.exe") ConsoleWrite(@CRLF & ">>>> IE Version is: " & $sVersion & " " & " <<<< error:" & @error & @CRLF & @CRLF) ConsoleWrite("Possible Regisitry / IE issue?" & @CRLF) Else ConsoleWrite(@CRLF & ">>>> IE Version is: " & $sVersion & " " & " <<<<" & @CRLF & @CRLF) EndIf Return $sVersion EndFunc ;==>_IEGet -
@ 'water' Just did this using your AD UDF and works a treat, I do have one question is there any way to verify the status of the FSMO Server e.g. not just are they up, but also what is their health, e.g. any critical errors that may affect the function of the FSMO roles if that makes any sense. #AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Au3Check_Stop_OnWarning=Y ; ***************************************************************************** ; Example 1 ; Get a list of all FSMO Role Owners ; ***************************************************************************** #include <AD.au3> Global $aFSMO[6][3] = [[""],["Domains PDC Emulator"],["Domains RID (Relative-Identifierer) master"],["Domains Infrastructure master"],["Forest-wide Schema master"],["Forest-wide Domain naming master"]] Global $fmso_error = 0, $Diags = 0, $fsmo_check = "Yes", $fsmo_error = 0, $post_msg = "support@computer-facilities.com or call on 0414-533784" fsmo_all() Func fsmo_all() #cs Description simple check of FSMO roles and the Servers holding them. Dependencies log.udf ad.udf _ping_fsmo() _add_log_line() Global Veriables $fsmo_error, $fsmo_check, $hLog, $post_msg $aFSMO[6][3] = [[""],["Domains PDC Emulator"],["Domains RID (Relative-Identifierer) master"],["Domains Infrastructure master"],["Forest-wide Schema master"],["Forest-wide Domain naming master"]] #ce Local $iCount, $var _AD_Open() Local $aTemp = _AD_ListRoleOwners() _AD_Close() ConsoleWrite(@CRLF & ">>>> FSMO Roles <<<<" & @CRLF & @CRLF) For $iCount = 1 To $aTemp[0] $aFSMO[$iCount][1] = $aTemp[$iCount] $var = _ping_fsmo($aFSMO[$iCount][1], 25) $aFSMO[$iCount][2] = $var if $aFSMO[$iCount][2] = "Down" Then $fsmo_error = 1 ;_add_log_line("The " & $aFSMO[$iCount][0] & " " & $aFSMO[$iCount][1] & " is " & $aFSMO[$iCount][2]) ConsoleWrite("The " & $aFSMO[$iCount][0] & " " & $aFSMO[$iCount][1] & " is " & $aFSMO[$iCount][2] & @CRLF) Next $aFSMO[0][0] = $aTemp[0] If $Diags = 1 Then _ArrayDisplay($aFSMO, "Active Directory Functions - Example 1", -1, 0, "<") If $fsmo_check = "Yes" Then If $fsmo_error = 1 Then MsgBox(32, "FSMO Error :" & $fsmo_error, "See event log at: " & @CRLF & "[" & @UserProfileDir & " \" & " logon - " & @UserName & " .log" & "] for more details!" & @CRLF & _ @CRLF & "This could lead to unexpected Domain and Logon issues and needs to be sorted out as a matter of urgency please contact :" & _ @CRLF & @CRLF & $post_msg & " for support on this matter") Exit EndIf EndIf EndFunc ;==>fsmo_all Func _ping_fsmo($host, $ttl) Local $var $var = Ping($host, $ttl) If $var Then Return "Present" Else $fmso_error = 1 Return "Down" EndIf EndFunc ;==>_ping_fsmo
-
Thanks 'water' will give this a go..
-
Works a treat, here is what I did and it really helped.. thanks #include <log.au3> #include <fsmo.au3> Global $hLog = _Log_Open(@UserProfileDir & "\" & "logon-" & @UserName & ".log", "###User " & @UserName & " Logon Event Log###") Global $fsmo_error = 0, $fsmo_check = "Yes", $post_msg = "support@computer-facilities.com or call on 0414-533784" fsmo_all() Func fsmo_all() #cs Dependencies log.udf fsmo.udf _ping_fsmo() _add_log_line() Global Veriables $fsmo_error, $fsmo_check, $hLog #ce Local $sm_var = _GetSchemaMaster() Local $dm_var = _GetDomainNamingMaster() Local $pdc_var = _GetPDCEmulator() Local $ism_var = _GetInfrastructureMaster() Local $rid_var = _GetRIDMaster() $fmso_error = 0 ConsoleWrite(@CRLF & ">>>> FSMO Roles <<<<" & @CRLF & @CRLF) _add_log_line("FMSO Roles") $var = _ping_fsmo($sm_var, 25) _add_log_line("Schema Master :" & @TAB & @TAB & $sm_var & " is " & $var) ConsoleWrite("Schema Master :" & @TAB & @TAB & $sm_var & " is " & $var & @CRLF) $var = _ping_fsmo($dm_var, 25) _add_log_line("Domain Naming Master :" & $dm_var & " is " & $var) ConsoleWrite("Domain Naming Master :" & @TAB & $dm_var & " is " & $var & @CRLF) $var = _ping_fsmo($pdc_var, 25) _add_log_line("PDC Emulator :" & @TAB & @TAB & $pdc_var & " is " & $var & @CRLF) ConsoleWrite("PDC Emulator :" & @TAB & @TAB & $pdc_var & " is " & $var & @CRLF) $var = _ping_fsmo($rid_var, 25) _add_log_line("RID Master :" & @TAB & @TAB & @TAB & $rid_var & " is " & $var & @CRLF) ConsoleWrite("RID Master :" & @TAB & @TAB & $rid_var & " is " & $var & @CRLF) $var = _ping_fsmo($ism_var, 25) _add_log_line("Infrastructure Master :" & $ism_var & " is " & $var & @CRLF) ConsoleWrite("Infrastructure Master :" & @TAB & $ism_var & " is " & $var & @CRLF) If $fsmo_check = "Yes" Then If $fsmo_error = 1 Then MsgBox(32, "FSMO Error :" & $fsmo_error, "See event log at: " & @CRLF & "[" & @UserProfileDir & " \" & " logon - " & @UserName & " .log" & "] for more details!" & @CRLF & _ @CRLF & "This could lead to unexpected Domain and Logon issues and needs to be sorted out as a matter of urgency please contact :" & _ @CRLF & @CRLF & $post_msg & " for support on this matter") Exit EndIf EndIf EndFunc ;==>fsmo_all Func _ping_fsmo($host, $ttl) Local $var $var = Ping($host, 50) If $var Then Return "Up" Else $fmso_error = 1 Return "Down" EndIf EndFunc ;==>_ping_fsmo Func _add_log_line($logmsg) _Log_Report($hLog, $logmsg) _Log_Report($hLog, "---------") EndFunc ;==>_add_log_line I did modify your scripts a little just making sure the return data in all your functions was changed to this Return StringTrimLeft($sComputer,3) from Return $sComputer just so the output was a little neater. The add log function I got from http://www.autoitscript.com/forum/index....4&hl=log%20udf&fromsearch=1&#entry829674,
-
Valuater have you been getting my e-mails? they have pics so have not been able to put them on the forum ...
-
I guess the first question were they part of a domain originally? and do you have the admin admin password to each of the machine? weather they be domain or work group. I would normally just format and re setup I did a auto install to help with that if you want it, as that a main prt our our business here, would save you time in basic setup up brought down our time from 4-5 hours per machine to 45mins + for a windows 7 install. In my experience better of resetting as you really do not know what nasties are hiding, but if you wanted a script to do a basic reset I'm sure that can be done and would be happy to give it a go with you help as I know your autoit skill are far better than min, but I am quite good admin/pc guy..
-
Dynamic Read/Write Array from .ini [solved]
PeterAtkin replied to PeterAtkin's topic in AutoIt General Help and Support
OMG just solved by using ByRef as you suggested a much neater solution thanks.. just in case anyone else is interested here the working final script (snippet) you will need to include Array.au3 in your script to use this..Func generic_read_array(ByRef $file_location, $ini_section, ByRef $array_ptr) #cs for: To read from any standard .ini files extract the settings from a paticulare section and then read values into 2D array, also will return total number of records stored within the section being read. usage: $var = generic_read_array($vars_file, "[Section]", $array) [$var] will contain a value equile to the total number of recoreds read, vey useful to know the number of valid recoreds within the the array variables: $file_location = ini file, to be used $ini_section = the section, to be used within the ini. file $array_ptr = 2D array that section variables to be put into, this will need to be declared before hand something like $users[99][2] #ce Local $var, $i If FileExists($vars_file) Then $var = IniReadSection($file_location, $ini_section) ConsoleWrite(@CRLF & ">>>> " & $ini_section & " <<<<" & @CRLF & @CRLF) If @error Then $error_code = 1 ;MsgBox(1, "Section does not exist", $ini_section) _put_event(1, "The INI file " & $vars_file & " may not exist or the section [" & $ini_section & "] within may not exist", @error) Else For $i = 1 To $var[0][0] Step 1 $array_ptr[$i][0] = $var[$i][0] $array_ptr[$i][1] = $var[$i][1] ConsoleWrite($array_ptr[$i][0] & " = " & $array_ptr[$i][1] & @CRLF) Next EndIf EndIf $how_many_records = $var[0][0] Return $how_many_records EndFunc ;==>generic_read_array -
Dynamic Read/Write Array from .ini [solved]
PeterAtkin replied to PeterAtkin's topic in AutoIt General Help and Support
Thanks Tvern, I tried to incorperate your suggestion but seems I cannot find where I am going wrong, the below script should be self contained except for the above malware.ini file, I get an error malware.au3 (45) : ==> Subscript used with non-Array variable.:, while I understand the error I do not understand how to solve it.. #include<array.au3> Global $malware[499][2], $str_var1[499][2], $str_var2[499][2] $var_malware = generic_read_array(@ScriptDir & "\malware.ini", "Malware", $malware[0][0], $malware[0][0]) scan_malware($var_malware) Func scan_malware($var_malware) For $mw = 1 To $var_malware Step 1 Local $mwf = 0 If ProcessExists($malware[$mw][0]) Then ProcessClose($malware[$mw][0]) Switch @error ;_put_event(1, "Kill Process Faile [" & $malware[$mw][0] & "] failed to terminate hostile process, you may need Administrator rights", @error) Case 1 MsgBox(11, "OpenProcess Failed", "Process [" & $malware[$mw][0] & "] failed to terminate hostile process, call support") ConsoleWrite("OpenProcess Failed [" & $malware[$mw][0] & "] you may need Administrator rights") Case 2 MsgBox(11, "AdjustTokenPrivileges Failed", "Process [" & $malware[$mw][0] & "] failed to terminate hostile process, call support") ConsoleWrite("AdjustTokenPrivileges Failed [" & $malware[$mw][0] & "] you may need Administrator rights") Case 3 MsgBox(11, "TerminateProcess Failed", "Process [" & $malware[$mw][0] & "] failed to terminate hostile process, you may need Administrator rights") ConsoleWrite("Terminate Process Failed [" & $malware[$mw][0] & "]" & @CRLF) Case 4 MsgBox(11, "Cannot verify if process exists", "Process [" & $malware[$mw][0] & "] failed to terminate hostile process, call support") ConsoleWrite("Cannot verify if process exists [" & $malware[$mw][0] & "] you may need Administrator rights") EndSwitch $mwf = $mwf + 1 EndIf Next EndFunc ;==>scan_malware Func generic_read_array($vars_file, $ini_section, ByRef $str_var1, ByRef $str_var2) Local $var, $i ;MsgBox(1,"Varibles", "Var1 :" & $var1 & @CRLF & "Var2 :" & $var2 & @CRLF & "Type :" & VarGetType($var2)& @CRLF & "str_var1 :" & $str_var1 & @CRLF & "str_var2 :" & $str_var2 & @CRLF & "Type :" & VarGetType($str_var2)) If FileExists($vars_file) Then $var = IniReadSection($vars_file, $ini_section) ConsoleWrite(@CRLF & ">>>> " & $ini_section & " <<<<" & @CRLF & @CRLF) If @error Then $error_code = 1 ;MsgBox(1, "Section does not exist", $ini_section) ;_put_event(1, "The INI file " & $vars_file & " may not exist or the section [" & $ini_section & "] within may not exist", @error) Else For $i = 1 To $var[0][0] Step 1 $str_var1[$i][0] = $var[$i][0] $str_var2[$i][1] = $var[$i][1] ConsoleWrite($str_var1[$i][0] & " = " & $str_var2[$i][1] & @CRLF) ConsoleWrite("> " & $malware[$i][0] & " = " & $malware[$i][1] & @CRLF) Next $nobj = $var[0][0] Return $nobj EndIf Else EndIf EndFunc ;==>generic_read_array I'm really trying but seems I am missing something rather basic.. any nudge would be appreciated. -
Dynamic Read/Write Array from .ini [solved]
PeterAtkin replied to PeterAtkin's topic in AutoIt General Help and Support
Yes just looked at the code, this will not work and has not Execute($str_var1 & " = $var[$i][0]") should work logically (maybe) but unfortunately does not update the array that ($str_var1) point to in this case ($malware[$i][0]).. As said before a I have several routine/functions withing the same script that do very similar jobs it's only the array names that changes, I would like to avoid repetition if possible. -
Dynamic Read/Write Array from .ini [solved]
PeterAtkin replied to PeterAtkin's topic in AutoIt General Help and Support
Wow would never have guessed that, i have a go and get back. The reason for this is to simply my code, I have several function like this and the only difference is that the variable for the array changes, seems just a bit clumsy to have a new function every time I need to read data into a different array.