Jump to content

Can I change the name of Autoit3.exe Process as the script starts(without compiling it)?


ratacat
 Share

Recommended Posts

Hi Folks! Thanks for your time today. Here is what I'm working with:

I have a little Web Scraper script I resell as a service, it's hosted by me on a VPS. As I get more and more clients, I am running more and more copies of the script. At this point in time, I have maybe 20. Occasionally I need to reboot a client's script. At the moment, my only way to tell which one is which, is to mouseover the tray icons, and then close out the appropriate one. I rename each script to match the client's name.

Why compiling them is not a desirable option.

I have many different versions of this script, and due to the nature of it, I must nearly continuously create new versions. Not keeping track of this versioning has bit me in the past, so I am very careful about it now. But I already spend a considerable amount of time maintaining these, and I do not wish to add more overhead time to switching/progressing clients to new versions of the script.

Currently, when a client's script becomes outdated, I copy up a new version of the script & it's files in a separate folder from my dev. And I drop an ini file with that client's specific information into the folder, rename the main script(so I can tell the difference between them all in the tray), and then launch it.

If it's at all possible for me to rename the PROCESS that runs that particular script by pulling out a bit of information in the ini AS the script starts, this would have two big advantages for me.

1. I could remove the step of having to rename the main script for each client so that I can easily reboot it later.

2. I could disable tray icon's in all scripts, and simply use the task manager to identify & restart individual client scripts.

Hope that is a clear enough explanation of what Im trying. Thankyou for your time, I'm looking forward to hearing your input!!

R

Link to comment
Share on other sites

Self-renaming might prove hard. A much simpler alternative is to create a single script which you use to launch every instances by passing relevant parameters. This one can then rename the actual script to be run according to .ini parameters for instance and run it.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

ahhhh...that does seem promising! Am I able to change the name of the process itself? Or just the name of the autoit script. At the very least this would allow me to rename the script, which would definitely save me a bit of time. Thanks jchd!

Link to comment
Share on other sites

Since the actual (effective) script is in source form, you could even run it from another script with the correct name.

Here's how you can do that. Don't be scared if it looks complicated at first, it isn't!

Have a generic launcher accepting relevant client parameters (indicating which script to be run a final, which name it should have and any other parameter you need. Make that lancher.exe

Have a generic runner.exe script which will run the real .au3 script passed as parameter (again).

launcher will copy-rename runner.exe to the correct client script name in the directory where it needs to reside and run

client_script_name /AutoIt3ExecuteScript client_script_whatever_it_is_called.au3

without wait and terminate.

All you'll see in Process Manager is the client_script_name.exe which will in fact run the source code from the REAL client script.

Looks like a mess but it's only a few lines of code in practice.

EDIT: runner.au3 can be any script, even an empty one will do. Once compiled, it's only use is to be renamed to the name you want for this instance and it will only run the client script source code you tell it to run.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

All AutoIt scripts create a hidden window that you can easily rename.

You can rename/show it like this.

AutoItWinSetTitle('John Doe')

WinSetState(AutoItWinGetTitle(), '', @SW_SHOW)

While Sleep(100)
WEnd

Then you could create a simple script like...

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

Local Const $HiddnA3Win = 'AutoIt v3'
Local Const $A3ProcessName = 'AutoIt3.exe'
Local Const $wTitle = 'Open "Named" AutoIt Windows'
Local $lView, $sBtn, $cBtn, $Msg

GUICreate($wTitle, 300, 200, -1, -1)
$sBtn = GUICtrlCreateButton('Refresh List', 18, 10, 80, 25)
$cBtn = GUICtrlCreateButton('Close Selected', 18, 50, 80, 25)
$lView = GUICtrlCreateListView('Named Autoit Wins|PID', 115, 5, 180, 190)
RefreshList()
GUISetState()

While 1
$Msg = GUIGetMsg()
     Switch $Msg
     Case $sBtn
         RefreshList()
     Case $cBtn
         Local $SelRow = _GUICtrlListView_GetSelectionMark($lView)
         Local $SelPID = _GUICtrlListView_GetItemText($lView, $SelRow , 1)
         If ProcessExists($SelPID) Then ProcessClose($SelPID)
         RefreshList()
     Case $GUI_EVENT_CLOSE
         ExitLoop
EndSwitch
WEnd

Func RefreshList()
_GUICtrlListView_DeleteAllItems($lView)
Local $wList = WinList(), $NoDupPID
Local $pList = ProcessList(), $wPid
     For $w = 1 To $wList[0][0]
         If $wList[$w][0] <> '' Then
         If $wList[$w][0] == $wTitle Or $wList[$w][0] == $HiddnA3Win Then Continueloop
             $wPid = WinGetProcess($wList[$w][0])
             If StringInStr($NoDupPID, $wPid) Then Continueloop
             For $p = 1 To $pList[0][0]
                     If $pList[$p][1] = $wPid And $pList[$p][0] == $A3ProcessName Then
                     GUICtrlCreateListViewItem($wList[$w][0] & '|' & $wPid, $lView)
                     $NoDupPID &= $wPid & ','
                 EndIf
                 Next
         EndIf
     Next
EndFunc

(The above script hides itself and default named hidden AutoIt windows from the list. Run the first example and then this script to see how it would work.)

And manage them that way.

You could use a $CmdLine parameter to set the hidden window title so you could use one source file.

Not exacly what you want but its an idea. :)

Link to comment
Share on other sites

Maybe will give you some pointers too.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...