Jump to content

Rename .EXE


laurin1
 Share

Recommended Posts

I have a problem where I run several of the same script at once, and I need to tell the difference between them programmatically. Is there a way to rename the .exe that is running, or maybe have one main script generating and compile "child" scripts? Any other ideas I'd be open to as well.

Keith Davis

MCSA, ZCE, A+, N+

http://www.laurinkeithdavis.com

Link to comment
Share on other sites

I have a problem where I run several of the same script at once, and I need to tell the difference between them programmatically. Is there a way to rename the .exe that is running, or maybe have one main script generating and compile "child" scripts? Any other ideas I'd be open to as well.

Just put a func in your script that looks whether there is a process with the scriptname and then count them and add 1 to it and show the counter in the title of your GUI.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Just put a func in your script that looks whether there is a process with the scriptname and then count them and add 1 to it and show the counter in the title of your GUI.

Mega

This doens't use a GUI, it's a bunch of scripted automated backups. I would really rather find a way to name the .exe, so even visually, I can see which is which (in case i have to terminate them manually, I can tell which one I'm looking at.) However, your idea might help.

Keith Davis

MCSA, ZCE, A+, N+

http://www.laurinkeithdavis.com

Link to comment
Share on other sites

This doens't use a GUI, it's a bunch of scripted automated backups. I would really rather find a way to name the .exe, so even visually, I can see which is which (in case i have to terminate them manually, I can tell which one I'm looking at.) However, your idea might help.

Hmmh do not get it. One main script starts one other script over and over again --> multiple times? Right?

Then start bla_1.exe

next one rename to bla_2.exe (FileMove)

and so on.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hmmh do not get it. One main script starts one other script over and over again --> multiple times? Right?

Then start bla_1.exe

next one rename to bla_2.exe (FileMove)

and so on.

Mega

Sorry, no, I use VisualCron to start the same script over and over again, using different Command Line arguments. Each instance is in affect a different backup job.

Keith Davis

MCSA, ZCE, A+, N+

http://www.laurinkeithdavis.com

Link to comment
Share on other sites

Sorry, no, I use VisualCron to start the same script over and over again, using different Command Line arguments. Each instance is in affect a different backup job.

Sorry, I cannot get want you need. Maybe you can determine the scripts by PID

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

I have a problem where I run several of the same script at once, and I need to tell the difference between them programmatically. Is there a way to rename the .exe that is running, or maybe have one main script generating and compile "child" scripts? Any other ideas I'd be open to as well.

Cannot really answer this question directly but why not explain the goal of what you are trying to accomplish with the script. If you are using the same script over and over with different command line args then that sounds like a perfect case for a function to me. It would be helplful to include an example of your script so we can all get on the same page with your line of reasoning for your question.
Link to comment
Share on other sites

Not sure if this will work... but:

In the script include part at the top that renames the exe your run with VisualCron to name*index*.exe (like program1.exe)... But determine that name by checking if other processes exist. Like have it check if program1.exe exists and if doesn't rename the program to that, and if it does exist check program2.exe... etc.

Once you a file renamed that is going to be different then any other one, run the script and the exit yours. However, use $cmdLine to tell the new script that it doesn't need to check the proccesses like it did in the first paragraph I described.

If you don't know about $cmdLine or whatever it's called ask and I'll explain more, or somebody else. Also, ask if what I said didn't make sense, it sounds complicated.

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Edit: I've 'fleshed out' this suggestion a bit better

If you know this next bit already, read on.

Then it's strictly for others who come along and don't know this.

Every AutoIt script has a hidden GUI window even if it has no GUI elements.

Even CUI compiled scripts with the new wrapper option for commandline scripts

still have the hidden GUI window titled 'AutoIt v3'

These commands allow reading and re-titling the hidden window

AutoItWinGetTitle()

AutoItWinSetTitle("script001")

you could set the title of the hidden window 'AutoIt v3'

to a number for each iteration of the script or

title it with the commandline parameters the script was passed

and use a script like the one below to view each script window and enter the pid to close the script

testscript.au3 - compile to exe and pass command line parameters

#NoTrayIcon
Opt("TrayIconHide", 1)

Func OnAutoItStart()
    ; use first 2 parameters for script title name and description or number
    If IsArray($CmdLine) And $CmdLine[0] Then
        AutoItWinSetTitle($CmdLine[1]&$CmdLine[2])
    EndIf
EndFunc

While 1
    Sleep(5000)
WEnd

Func OnAutoItExit(); allows polite script shutdown
    ; chance to do cleanup on script closure
    ; add cleanup code here
    Beep(1000,5) ; audible indication of proper script shutdown
EndFuncoÝ÷ Ùè¢iÙbêZ­©µêìµë-±Êâ¦×±x쵩eÓMmzËlr¸©µì^"{-jYtÓk^²Û®*m{ËZ]4Ýëµë-±Êâ¦×±x쵩eÚz׬¶Ç+^Åâ'²Ö¥X«yú1µë-±Êâ¦×±x쵩e
ë-¢g­r»§)à±Êâ¦Û'£Z½èbuקëh"Ü"Ú0Â+aiº/zØ­ëHËZP¡··ö÷ô쵩eÓMwöÇ+^é­«^±©e®éçx'¢x.uéìr¸©¶Ì"¶ý"{-jYqÇqßاëh"Ü"Ú0¶+ezv¦xGb¶ö«¬~,^±©Ý~(!¶)àÂ+a~îçb¶ðØOƬ²ý±Æ¥¶@Ųè­i¹^~ïßo5¢·®X®êåoÝ÷ Û­»¢Ø§²ÂjY[iÉ,º+ZnW¢»÷Û]4jwn¥«­¢+Ù=ÁÐ ÅÕ½Ðí5ÕÍѱÉYÉÌÅÕ½Ðì°Ä¤(¥¹±Õ±ÐíAɽÍ̹ÔÌÐì)1½°ÀÌØí±¥ÍаÀÌØí¹µ°ÀÌØí¤ÄôÀ°ÀÌØí¤ÈôÄ°ÀÌØíÍQ¥Ñ±°ÀÌØí¡¹±)1½°ÀÌØíMÉ¥Á]¥¹9µ°ÀÌØíA%°ÀÌØíÍ¥é°ÀÌØí
½Õ¹Ñ1¥¹Ì°ÀÌØíµÍ)±½°ÀÌØíÉÉålÅulÅt((ì¹ÑÈÁÉ¥àѥѱÕͽÈÍÉ¥ÁÑ̽µµ¹±¥¹(ÀÌØíMÉ¥Á]¥¹9µô%¹ÁÕÑ   ½à ÅÕ½ÐíIÕ¹¹¥¹MÉ¥ÁйյÉÑ¥½¸ÅÕ½Ðì°|($$ÅÕ½Ðí¹ÑÈѥѱ¹µÁÉ¥à½ÈÉÕ¹¹¥¹ÍÉ¥ÁÑÌÅÕ½Ðì°ÅÕ½Ðí%¹Íѱ°ÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÌÀÀ°ÄÀÀ¤((ì
Éѱ±¬Õ¹Ñ¥½¸(ÀÌØí¡¹±ô±±
±±­I¥ÍÑÈ ÅÕ½Ðí}¹Õµ]¥¹½ÝÍAɽÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½Ðí¡Ý¹íÁÑÈÅÕ½Ðì¤()]¡¥±Ä($ÀÌØíµÍôU%Ñ5Í ¤(%%ÀÌØíµÍô´ÌQ¡¸á¥Ð(%%9½Ð]¥¹á¥ÍÑÌ ÅÕ½Ðí¹ÑÈA%Ѽ±½ÍÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì¤Q¡¸($$ÀÌØí¤ÄôÀ($$ÀÌØí¤ÈôÄ($%¥´ÀÌØíÉÉålÅulÅt($$($$ì
±°¹Õµ]¥¹½ÝÌ($%±±
±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½Ðí¹Õµ]¥¹½ÝÌÅÕ½Ðì°|($$$$ÅÕ½ÐíÁÑÈÅÕ½Ðì°±±
±±­ÑAÑÈ ÀÌØí¡¹±¤°ÅÕ½Ðí±ÁÉ´ÅÕ½Ðì°ÄÀ¤($$($%%9½ÐMÑÉ¥¹1¸ ÀÌØí±¥ÍФQ¡¸($$%5Í ½à À°ÅÕ½ÐíIÕ¹¹¥¹MÉ¥ÁйյÉÑ¥½¸ÅÕ½Ðì°|($$$$$ÅÕ½Ðí9¼ÉÕ¹¹¥¹ÍÉ¥ÁÑÌÝ¥Ñ ÌäìÅÕ½ÐìµÀìÀÌØíMÉ¥Á]¥¹9µµÀìÅÕ½ÐìÌäìѥѱ½Õ¹ÅÕ½Ðì¤($$%á¥Ð($%¹%($$($%%ÀÌØíÉÉålÁulÁtÐìÌQ¡¸($$$ÀÌØíÍ¥éôÄÔÀ¬  ÀÌØíÉÉålÁulÁt´Ì¤¨ÄÔ¤($%±Í($$$ÀÌØíÍ¥éôÄÔÀ($%¹%(($$ÀÌØíA%ô%¹ÁÕÑ   ½à ÅÕ½Ðí¹ÑÈA%Ѽ±½ÍÍÉ¥ÁÐÅÕ½Ðì°ÀÌØí±¥ÍаÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÜÀÀ°ÀÌØíÍ¥é¤($%%9½ÐMÑÉ¥¹1¸ ÀÌØíA%¤Q¡¸á¥Ðì±¥¬½¬ÕÑѽ¸Ý¥Ñ ¹¼¥¹ÁÕÐÑÍÐ($%½ÈÀÌØí¤ÌôÄQ¼ÀÌØíÉÉålÁulÁt($$%%ÀÌØíÉÉålÀÌØí¤ÍulÅtôÀÌØíA%Q¡¸($$$%]¥¹
±½Í ÀÌØíÉÉålÀÌØí¤ÍulÁt°ÅÕ½ÐìÅÕ½Ðì¤($$$$ÀÌØíÍQ¥Ñ±ôÀÌØíÉÉålÀÌØí¤ÍulÁt($$%¹%($%9áÐ($%]¥¹]¥Ñ
±½Í ÀÌØíÍQ¥Ñ±°ÅÕ½ÐìÅÕ½Ðì°È¤($$ÀÌØíÍQ¥Ñ±ôÅÕ½ÐìÅÕ½Ðì($$ÀÌØí±¥ÍÐôÅÕ½ÐìÅÕ½Ðì(%¹%)]¹((ì
±±¬AɽÕÉ)Õ¹}¹Õµ]¥¹½ÝÍAɽ ÀÌØí¡]¹°ÀÌØí±AÉ´¤($ÀÌØí¡]¹ô!]¹ ÀÌØí¡]¹¤(%1½°ÀÌØíÍÑA%ô±±MÑÉÕÑ
ÉÑ ÅÕ½Ðí¥¹ÐÅÕ½Ðì¤(%1½°ÀÌØíѥѱô]¥¹ÑQ¥Ñ± ÀÌØí¡]¹¤(%1½°ÀÌØíA%(%%MÑÉ¥¹%¹MÑÈ ÀÌØíѥѱ°ÀÌØíMÉ¥Á]¥¹9µ°Ä¤Q¡¸($$íÐÑ¡Á¥É½´Ñ¡Ý¥¹½ÜÁɽ٥($%±±
±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíÑ]¥¹½ÝQ¡ÉAɽÍÍ%ÅÕ½Ðì°|($$$$ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÀÌØí¡]¹°ÅÕ½ÐíÁÑÈÅÕ½Ðì°±±MÑÉÕÑÑAÑÈ ÀÌØíÍÑA%¤¤($%%ÉɽÈQ¡¸IÑÕɸMÑÉÉ½È È°À°À¤($$ÀÌØíA%ô±±MÑÉÕÑÑÑ ÀÌØíÍÑA%°Ä¤($%%ÉɽÈQ¡¸IÑÕɸMÑÉÉ½È È°À°À¤($$($$ÀÌØí¤Ä¬ôÄ($$ÀÌØí¤Èô9½ÐÀÌØí¤È($%I¥´ÀÌØíÉÉålÀÌØí¤Ä¬ÅulÀÌØí¤Ä¬Åt($$ÀÌØíÉÉålÀÌØí¤ÅulÀÌØí¤ÉtôÀÌØíѥѱ($$ÀÌØí¤Èô9½ÐÀÌØí¤È($$ÀÌØíÉÉålÀÌØí¤ÅulÀÌØí¤ÉtôÀÌØíA%($$ÀÌØíÉÉålÁulÁtôÀÌØí¤Ä($$($$ìÀÌØí¹µô}AɽÍÍÑ9µ ÀÌØíÁ¥¤($$ÀÌØí¹µô}ÑAɽÍÍAÑ  ÀÌØíA%¤($$ÀÌØí±¥ÍеÀìôÅÕ½ÐíQ¥Ñ±èÅÕ½ÐìµÀìÀÌØíѥѱµÀìQµÀìÅÕ½ÐíA%èÅÕ½ÐìµÀì|($$$$ÀÌØíA%µÀìQµÀìÅÕ½Ðí¡]¹èÅÕ½ÐìµÀìÀÌØí¡]¹µÀìQµÀìÅÕ½ÐíAɽÍÌèÅÕ½ÐìµÀìÀÌØí¹µµÀì
I1($%
½¹Í½±]É¥Ñ ÅÕ½Ðì´ÐíQ¥Ñ±è´ÐìÅÕ½ÐìµÀìÀÌØíѥѱµÀìÅÕ½Ðì¡]¹è´ÐìÅÕ½ÐìµÀì|($$$$ÀÌØí¡]¹µÀìÅÕ½ÐìA%è´ÐìÅÕ½ÐìµÀìÀÌØíA%µÀìQµÀìÅÕ½ÐíAɽÍÌè´ÐìÅÕ½ÐìµÀìÀÌØí¹µµÀì
I1¤(%¹%(%IÑÕɸÄ)¹Õ¹ìôôÐí}¹Õµ]¥¹½ÝÍAɽ()Õ¹=¹Õѽ%Ñá¥Ð ¤($ì±Ñ±±¬Õ¹Ñ¥½¸(%±±
±±­É ÀÌØí¡¹±¤)¹Õ¹ìôôÐí=¹Õѽ%Ñá¥Ð()Õ¹}ÑAɽÍÍAÑ  ÀÌØíA%Ȥ($ì}ÑAɽÍÍAÑ Ù¥Á½ÍÐäµ±½É½´µÉµ¸±é½ÁɽÍ͵¹È(%1½°ÀÌØíAɽÍÌ°ÀÌØí5½Õ±Ì°ÀÌØíIÐ(%
½¹ÍÐÀÌØíAI=
MM}EUIe}%9=I5Q%=8ôÁàÀÐÀÀ(%
½¹ÍÐÀÌØíAI=
MM}Y5}IôÁàÀÀÄÀ($ÀÌØíAɽÍÌô±±
±° ÅÕ½Ðí­É¹°Ìȹ±°ÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÅÕ½Ðí=Á¹AɽÍÌÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°|($$%  ¥Ñ=H ÀÌØíAI=
MM}EUIe}%9=I5Q%=8°ÀÌØíAI=
MM}Y5}I¤°|($$$ÅÕ½Ðí¥¹ÐÅÕ½Ðì°À°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØíA%Ȥ(%%ÀÌØíAɽÍÍlÁtôÀQ¡¸IÑÕɸMÑÉÉ½È Ä¤($ÀÌØí5½Õ±Ìô±±MÑÉÕÑ
ÉÑ ÅÕ½Ðí¥¹ÑlÄÀÈÑtÅÕ½Ðì¤(%±±
±° ÅÕ½ÐíÁÍÁ¤¹±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½Ðí¹ÕµAɽÍÍ5½Õ±ÌÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°|($$$ÀÌØíAɽÍÍlÁt°ÅÕ½ÐíÁÑÈÅÕ½Ðì°±±MÑÉÕÑÑAÑÈ ÀÌØí5½Õ±Ì¤°|($$$ÅÕ½Ðí¥¹ÐÅÕ½Ðì°±±MÑÉÕÑÑM¥é ÀÌØí5½Õ±Ì¤°ÅÕ½Ðí¥¹Ñ}ÁÑÈÅÕ½Ðì°À¤($ÀÌØíIÐô±±
±° ÅÕ½ÐíÁÍÁ¤¹±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíÑ5½Õ±¥±9µàÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°|($$$ÀÌØíAɽÍÍlÁt°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°±±MÑÉÕÑÑÑ ÀÌØí5½Õ±Ì°Ä¤°|($$$ÅÕ½ÐíÍÑÈÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÈÀÐà¤($ÀÌØí5½Õ±ÌôÀ(%%MÑÉ¥¹1¸ ÀÌØíIÑlÍt¤ôÀQ¡¸IÑÕɸMÑÉÉ½È Ä¤(%IÑÕɸÀÌØíIÑlÍt)¹Õ¹ìôôÐí}ÑAɽÍÍAÑ
Edited by rover

I see fascists...

Link to comment
Share on other sites

Sorry, no, I use VisualCron to start the same script over and over again, using different Command Line arguments. Each instance is in affect a different backup job.

It seems like what you want to do is to be able look at a tray menu item for each backup job, since you don't want to use a GUI. This function is described in the Help file:

TrayCreateItem ( text [, menuID [, menuentry [, menuradioitem]]] )

Use this function to display the name or path of the folder being backed up, this way:

TrayCreateItem($FolderBeingBackedUp)

Das Häschen benutzt Radar

Link to comment
Share on other sites

I apologize for not giving more info, as we've veared off a bit, but this is all good information that will come in handy, so not wasted. I was unaware of that hidden window, so this much easier than I thought. Here's what I do:

From VisualCron, I call Backup.exe with a command line argument, for example "Backup.exe 'Full Daily Differential to File'". Backup.exe runs ntbackup.exe with various command line arguments, based on an .ini file.

What I need to be able to do is if these jobs overlap, which from time to time they will do, I need to be able to check verify 1 that the current "version" with that particular command line argument is not the one running (two of the same "jobs" running at the same time is a real problem), I need to be able to monitor that that particular one is running, and I need to monitor the ntbackup.exe instance so that I know that it is still running. I figured out the last part yesterday, in that I can copy and rename ntbackup.exe before I run it as what 'Full Daily Differential to File.exe', or whatver I want and then monitor that instance as a process.

I can read through your suggestions (rover) to check the other piece, or if you don't mind clarify how that might work in this situation, that would be great.

Keith Davis

MCSA, ZCE, A+, N+

http://www.laurinkeithdavis.com

Link to comment
Share on other sites

what do you mean by: 'current "version" with that particular command line argument is not the one running'

by "version", do you mean an instance of backup.exe run with 'Full Daily Differential to File' as the commandline argument?

thats what the monitoring script I posted and Hubertus' WMI code will show.

they both display the commandline parameters the instance of backup.exe was run with

and the PID's for each instance so you can see if there are any duplicates

close in Taskmanager or ProcessExplorer or use the monitoring script I uploaded to close duplicates

(best to WinClose instead of ProcessClose a script)

(I think what you need is _Singleton())

you know if that particular commandline is what the backup.exe script is running because

thats what it's title is named as displayed in that monitoring script or in the script by Hubertus that shows the command line the script was run with

I refrained from posting an WMI script as there are compatability and permission issues

and some people prefer an API all AutoIt solution, though the WMI scripting is better for some functions.

the Win32_Process class has a lot of info, particularly that commandline object

_Singleton():

to prevent two instances of the same script running with the same command line parameters

you could use the _Singleton() function to create a 'Mutex' of those commandline parameters

and close any second instance of the script instantly when it is run.

If you only need to prevent script duplicates of backup.exe, then just use _Singleton("backup") in your scripts

excuse this if it seems pedantic but others read these posts and the clearer they are,

the more people learn (for those still learning like me)

Use the built in function 'OnAutoItStart()'

this function, if present in the script is the very first thing run by AutoIt,

regardless of it's placement location in the script

even before declared variables at the top of the script.

its the best place for _Singleton() and other functions required prior to script startup

its counterpart is OnAutoItExit(),

the last function run automatically by AutoIt on exit

these functions are not called by you in the script,

AutoIt uses these on start and exit automatically if they are present

I can read through your suggestions (rover) to check the other piece, or if you don't mind clarify how that might work in this situation, that would be great.

The monitoring script is started and you enter in the inputbox the fixed name of the script running you want to monitor

e.g. 'Backup' - NOTE: Case Sensitive!, same name as the script executable minus the '.exe'

or hard code the monitoring script to monitor 'Backup' and dump the inputbox, its just a demo script...

(the demo version of your backup.exe names it's hidden window with its filename minus '.exe')

that will be the first part of the hidden title,

the commandline parameter is the rest of the title

the next inputbox displays all instances of 'Backup.exe' and the commandline parameters they where run with

see image link: post-22637-1202687198_thumb.jpg

notice two instances of backup.exe are running

one daily differential and one incremental (ok so its contradictory, I'm just using your example and a supposition of incremental backup as an example)

any new instance of backup.exe run with either of those two commandline parameters would close immediately because of _Singleton()

in backup.exe

or if only one instance of backup.exe can run at a time then make singleton

close any second instance of the script with this line:

Func OnAutoItStart()

_Singleton("backup",0) ; only one instance of backup.exe can run

EndFunc

pseudocode demo version of your 'Backup.exe'

Run: backup.exe Full Daily Differential to File

#NoTrayIcon
Opt("TrayIconHide", 1)
#include <Misc.au3>

Func OnAutoItStart() ; if second instance of backup.exe with the same command
    ;line is run, it will close immediately because an instance of the script
    ;with same commandline is already running and a Mutex named: 'Full Daily Differential to File' already exists
    $title = StringTrimRight(@ScriptName, 4)
    If Stringlen($CmdLineRaw) Then
        $title &= ": "&$CmdLineRaw
        $mutex = $CmdLineRaw
    Else
        $mutex = $title
    EndIf
    AutoItWinSetTitle($title) ; instance of Backup.exe now titled with commandline parameters
    ; Title of script now: 'Backup: Full Daily Differential to File'
    If Not _Singleton("Global\"&$mutex,1) Then Exit(2) ; Mutex is now: 'Full Daily Differential to File'
EndFunc

; run ntbackup.exe with your commandline arguments
Switch $CmdLineRaw
    Case 'Full Daily Differential to File'
        ; read ini file
        ; Run ntbackup.exe with arguments from ini
    Case 'Daily Incremental to File'
EndSwitch

While 1
    ; message loop code, wait for events etc.
    Sleep(5000)
WEnd

Func OnAutoItExit(); allows polite script shutdown cleanup of needed
    If @exitCode <> 2 Then ; _Singleton() exit, bypass any script shutdown cleanup
    ; chance to do cleanup on script closure
    ; add cleanup code here if required
    Beep(1000,5) ; audible indication of normal script shutdown (Optional)
    Else
        Beep(1500,5) ; audible indication of _Singleton() script shutdown (Optional)
    EndIf
EndFunc
Edited by rover

I see fascists...

Link to comment
Share on other sites

I see that VisualCron has a setting per job to not run a job if it is already running (Version 4.82)

wouldn't that prevent jobs being run concurrently, regardless of trigger or condition settings?

Are these backup jobs run remotely on multiple machines or you are just backing up a single machine (server) ?

I assume because you use a master ini file with each backup operation parameter set defined, that you don't want

to use hard coded versions of your backup.exe named for the backup operation section in that ini file,

and have all parameters hardcoded in those files so you have in VisualCron listed backup jobs that run those customized versions of the backup.exe

probably because the ini file includes admin email address, backup locations and other info that may need updating for all scripts.

but you could have custom named copies of backup.exe that when run get the corresponding section of the master ini file for the NTBackup parameters

so you could run them without using commandline parameters

filename examples from your old backup.zip you posted to the forums

Full Daily Differential to File.exe

Archive Monthly Normal to Tape.exe

Archive Weekly Normal to File.exe

Current Daily Differential to File.exe

Current Weekly Copy to Tape.exe

Current Weekly Normal to File.exe

When these files are run they read the corresponding section (by filename) in the master ini file for the NTBackup parameters.

You should place _Singleton() in each file so only a single instance can be run.

In taskmanager each backup scripts name is its function

(should have just suggested this in the first place...)

relevance of the responses on the forums to what you are trying to do are only as good as the clarity of input from you, the OP ('Original Poster)

we make assumptions otherwise on what you want or don't want, get sidetracked, have our own interpretations.

It helps if you post code examples and participate in your own solution...

you have a number of solutions to choose from

1 - using customized name versions of the backup script for each backup function

2 - using _Singleton() to prevent script instance duplication

3 - using a GUI script to monitor all backup script process for commandline the process was run with - Hubertus WMI code

4 - monitoring all backup script process with hidden window titles with same substring name 'Backup' and commandline parms used for title - my code

(note that the code I posted could be modified to monitor by processname instead of window title,

I just used an 'off the shelf' example of DllCallback from the forums. the results are the same)

Good Luck

I see fascists...

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...