MSF Posted June 15, 2009 Share Posted June 15, 2009 I have a very simple script. My script calls a DOS batch file. The batch file just renames and copies (xcopy) an existing file then moves it to a share. Is it possible to keep this script running when logged out? If this is not possible due to the use of my DOS batch file, would it be possible if I didn't use a batch file and just did the file manipulation in AutoIT? While 1 Sleep(3000) $search = FileFindFirstFile("fdrprlse.dat") If $search = 1 Then RunWait(@COMSpec & " /c" & "backup.bat", "", @SW_HIDE) $search = FileFindFirstFile("fdrprlse.dat") EndIf WEnd Link to comment Share on other sites More sharing options...
martin Posted June 15, 2009 Share Posted June 15, 2009 I have a very simple script. My script calls a DOS batch file. The batch file just renames and copies (xcopy) an existing file then moves it to a share. Is it possible to keep this script running when logged out? If this is not possible due to the use of my DOS batch file, would it be possible if I didn't use a batch file and just did the file manipulation in AutoIT? While 1 Sleep(3000) $search = FileFindFirstFile("fdrprlse.dat") If $search = 1 Then RunWait(@COMSpec & " /c" & "backup.bat", "", @SW_HIDE) $search = FileFindFirstFile("fdrprlse.dat") EndIf WEnd You can have a script running when you switch user, but if you want it to run when you are logged out then AFAIK you will need to run your script as a service, and there are threads in Example Scripts to let you do that. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
herewasplato Posted June 15, 2009 Share Posted June 15, 2009 @ComSpec is not needed: RunWait("backup.bat", "", @SW_HIDE) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
MSF Posted June 17, 2009 Author Share Posted June 17, 2009 (edited) Wheew!! Only a million hours later and I finally figure out how services work and how to run my exe as one!This is the post that helped me: Run your script as Service v1.0If you are new to services, you better read every page of that post.Here is my example. I decided to drop the whole DOS idea and just go with straight AutoIT.Partial:func main() $transfer_to_directory = InputBox("", "Backup Directory", "\\yourBackupDirectory", "", -1, 1, 0, 0) $file_loc = @ScriptDir $file_name = InputBox("", "Enter File Name", "file.dat", "", -1, 1, 0, 0) while 1 $search = FileFindFirstFile($file_name) FileMove($file_loc & "\" & $file_name, $file_loc & "\" & @YEAR & @MON & @YDAY & @MIN & @SEC & "-log-" & $file_name) FileMove($file_loc & "\*-log-" & $file_name, $transfer_to_directory, 9) Sleep(1000) WEnd EndFuncoÝ÷ Ø[¥«¢+ØI¥½¸ì¨¨¨¨¥ÉÑ¥ÙÌÉÑäÕѽ%ÐÍ]ÉÁÁÉ}U$¨¨¨¨(Õѽ%ÐÍ]ÉÁÁÉ}YÉÍ¥½¸õ Ñ(Õѽ%ÐÍ]ÉÁÁÉ} ¡¹É U$õä(¹I¥½¸ì¨¨¨¨¥ÉÑ¥ÙÌÉÑäÕѽ%ÐÍ]ÉÁÁÉ}U$¨¨¨¨(ìáµÁ±½ÕÍ¥¹ÍÉÙ¥UѼµ¸áÁ½ÍÍ¥±äÉÕ¹ÌÍÉÙ¥(ì äÉÈ(ìÄÀ¼Àä¼ÈÀÀà(ì5½¥¥ä5M(ìÀؼÄؼÈÀÀä((¥¹±Õ±ÐíMÉÙ¥¹ÔÌÐì((ÀÌØíÍMÉÙ¥9µôÅÕ½ÐíÕѽ%Q}¹ÐÅÕ½Ðì)%ÀÌØíµ±¥¹lÁtÐìÀQ¡¸(%MÝ¥Ñ ÀÌØíµ±¥¹lÅt($% ÍÅÕ½Ðí¥¹Íѱ°ÅÕ½Ðì°ÅÕ½Ð쵤ÅÕ½Ðì°ÅÕ½Ð콤ÅÕ½Ðì($$%%¹Íѱ±MÉÙ¥ ¤($% ÍÅÕ½Ðíɵ½ÙÅÕ½Ðì°ÅÕ½ÐìµÔÅÕ½Ðì°ÅÕ½Ðì½ÔÅÕ½Ðì°ÅÕ½ÐíÕ¹¥¹Íѱ°ÅÕ½Ðì($$%Iµ½ÙMÉÙ¥ ¤($% ͱÍ($$% ½¹Í½±]É¥Ñ ÅÕ½Ðì´´´!±À´´´ÅÕ½ÐìµÀìɱ¤($$% ½¹Í½±]É¥Ñ ÅÕ½ÐíÁɵÌèÅÕ½ÐìµÀìɱ¤($$% ½¹Í½±]É¥Ñ ÅÕ½Ð쵤襹Íѱ°ÍÉÙ¥ÅÕ½ÐìµÀìɱ¤($$% ½¹Í½±]É¥Ñ ÅÕ½ÐìµÔèɵ½ÙÍÉÙ¥ÅÕ½ÐìµÀìɱ¤($$% ½¹Í½±]É¥Ñ ÅÕ½Ðì´´´´´´´´ÅÕ½ÐìµÀìɱ¤($$%á¥Ð($$$íÍÑÉÐÍÉÙ¥¸(%¹MÝ¥Ñ )¹%)}MÉÙ¥}¥¹¥Ð ÀÌØíÍMÉÙ¥9µ¤()Õ¹µ¥¸ ¤($($ÀÌØíÑɹÍÉ}ѽ}¥ÉѽÉäô%¹ÁÕÑ ½à ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí ÕÀ¥ÉѽÉäÅÕ½Ðì°ÅÕ½ÐìÀäÈìÀäÈíå½ÕÉ ÕÁ¥ÉѽÉäÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°´Ä°Ä°À°À¤($ÀÌØí¥±}±½ôMÉ¥ÁÑ¥È($ÀÌØí¥±}¹µô%¹ÁÕÑ ½à ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí¹ÑÈ¥±9µÅÕ½Ðì°ÅÕ½Ðí¥±¹ÐÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°´Ä°Ä°À°À¤($(%Ý¡¥±Ä($$ÀÌØíÍÉ ô¥±¥¹¥ÉÍÑ¥± ÀÌØí¥±}¹µ¤($$($%¥±5½Ù ÀÌØí¥±}±½µÀìÅÕ½ÐìÀäÈìÅÕ½ÐìµÀìÀÌØí¥±}¹µ°ÀÌØí¥±}±½µÀìÅÕ½ÐìÀäÈìÅÕ½ÐìµÀìeHµÀì5=8µÀìedµÀì5%8µÀìMµÀìÅÕ½Ðìµ±½´ÅÕ½ÐìµÀìÀÌØí¥±}¹µ¤($%¥±5½Ù ÀÌØí¥±}±½µÀìÅÕ½ÐìÀäÈ쨵±½´ÅÕ½ÐìµÀìÀÌØí¥±}¹µ°ÀÌØíÑɹÍÉ}ѽ}¥ÉѽÉä°ä¤($$($%M±À ÄÀÀÀ¤($$(%]¹)¹Õ¹()Õ¹%¹Íѱ±MÉÙ¥ ¤(% ½¹Í½±]É¥Ñ ÅÕ½Ðí%¹Íѱ±¥¹ÍÉÙ¥°Á±ÍÝ¥ÐÅÕ½ÐìµÀì I1¤(%}MÉÙ¥} ÉÑ ÅÕ½ÐìÅÕ½Ðì°ÀÌØíÍMÉÙ¥9µ°ÅÕ½ÐíÕѽ%P¹ÐÅÕ½Ðì°ÌäìÅÕ½ÐìÌäìµÀìMÉ¥ÁÑÕ±±AÑ µÀìÌäìÅÕ½ÐìÌäì¤(%%ÉɽÈQ¡¸($% ½¹Í½±]É¥Ñ ÅÕ½ÐíAɽ±´¥¹Íѱ±¥¹ÍÉÙ¥°ÉɽȹյȥÌÅÕ½ÐìµÀìÉɽȵÀì I1µÀìÅÕ½ÐìµÍÍèÅÕ½ÐìµÀì}]¥¹A%}Ñ1ÍÑÉɽÉ5ÍÍ ¤¤(%±Í($% ½¹Í½±]É¥Ñ ÅÕ½Ðí%¹Íѱ±Ñ¥½¸½ÍÉÙ¥ÍÕÍÍÕ°ÅÕ½Ðì¤(%¹%(%á¥Ð)¹Õ¹ìôôÐí%¹Íѱ±MÉÙ¥)Õ¹Iµ½ÙMÉÙ¥ ¤(%}MѽÁMÉÙ¥ ÅÕ½ÐìÅÕ½Ðì°ÀÌØíÍMÉÙ¥9µ¤(%}±ÑMÉÙ¥ ÅÕ½ÐìÅÕ½Ðì°ÀÌØíÍMÉÙ¥9µ¤(%¥¹½ÐÉɽÈÑ¡¸ ½¹Í½±]É¥Ñ ÅÕ½ÐíÍÉ٥ɵ½ÙÍÕÍÍÕ±±äÅÕ½ÐìµÀìɱ¤(%á¥Ð)¹Õ¹ìôôÐíIµ½ÙMÉÙ¥ Edited June 17, 2009 by MSF Link to comment Share on other sites More sharing options...
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