Execute script on windows event no result timed script yes - events

I have a script that normally executes every 5 minutes.
It starts a Photoshop session and treats pictures in a folder.
This works but I need to stay logged in to the PC.
I tried with the setting Run logged on or not.
I then created a windows task based on a event 4663 and/or 5145.
When a file now arrives in the folder the event fires the script I even see Photoshop launching, but no pictures is treated.
It's the same script so I don't know why this is the case..
Regards
Guy

Related

Windows Server 2008 R2 scheduler ignores "hidden" setting

I have the following problem: I've created scheduled jobs that are only containing calls to a cmd and have parameters that contain things like project name etc.
I know about the fact that you have to set it to "Run only when user is logged on" if you want to see the window (cmd in this case) and also have to uncheck "hidden".
Until a week or two ago that worked fine, the box was showing up. Now the exact same job does no longer show the dos box. I suspect a windows update but I couldn't find anything useful in the update history of the server.
Do you guys have any idea what it might be? I tried switching the settings between the two "run as" options, tried setting it to hidden, tried switching "configure for" around...
The jobs run ok most of the time, the output is generated in most cases but if things go wrong I want to see the shell and not have to pipe everything to a .txt :/
I tried looking on google etc for a solution but only found other problems or the "my tasks run hidden if I choose run whether user is logged on or not" solutions.
Any ideas or hints? Anything would be really appreciated!
As you use scheduler to automate running of some rutine task, what's the point of manually checking/controlling it's execution? It is sort of negates benefit of automation and should be done through some basic logging (you can built in in your task scripts or whatever it is) and even viewer where you can check whether your tasks was run successfully.
Why it is required to you to see this window? Are you really need it?
If you state that it used to work OK then check logs does your tasks run successfully all the tine but hidden from you or it's something else?
Try to re-create / create new task & check whether it is not run hidden with settings you use.
From your description your scheduled task indeed configured so that it should be visible, namely:
- It is scheduled under your current logon account.
- It is configured to Run only when user is logged on.
These 2 conditions required for task to be visible.
The Hidden checkbox in the Windows Task Scheduler has nothing to do with how the scheduled program is displayed (in fact, there are no display options for scheduled tasks like there are with shortcuts). The Hidden checkbox controls whether or not the task is displayed in the Task Scheduler. If you set check it, then Task Scheduler will not display it unless the View Hidden Tasks option in the View menu is selected. You should still see the program window when it runs even if it is checked.
You did not indicate what changes you had made to the task between the time it worked and when it stopped, but one change that would prevent the window from being shown is if you had changed the account that runs it to the SYSTEM account. That is a trick that people use to hide the window (which is not a good solution, especially since there are much safer options), so if you had changed that, then you would not see it.
(The OP may have already fixed this by now), but if anyone else has the same problem, check the user account. If the task is not too complicated, you could do as Mikhail suggested and re-create the task from scratch.

How to display the main window of a process in another Windows session?

When running a Scheduled Task under Windows to launched batch processes under a dedicated account, you could want to see output of theses processes.
These sub-processes could be either or both graphical or character based applications
As there are running in a different Windows Logon session, I cannot find way to display their output. There are like ghost processes
I would expect being able to use the show Window command from Process Explorer, but even via running Process Explorer under the dedicated account used to run the task (via runas), it is not working
Is there a way to do it ?
References : http://www.brianbondy.com/blog/id/100/
I believe that once created, a window cannot be transferred to another window station. Also, I doubt it is possible to open windows in another session. For character-based applications you are better off writing the output to some file and examining that file. For graphical applications you are out of luck with task scheduler. You may want to write a simple VBS script that wakes up at a certain time and runs your graphical task(s) and run it upon user logon, e.g. along the lines of a script from this page:
http://social.technet.microsoft.com/Forums/scriptcenter/en-US/d9465815-87e2-43df-a0fe-4a23c16dca99/need-a-time-schedule-in-vbs-script-to-execute-something

Windows 7 scheduled task "runs" but doesn't DO anything

I have a vbscript file that must run under 32bit on a 64 bit Windows 7 machine so that it can connect to a 32 bit Access database. From a run box I can enter:
C:\Windows\SysWow64\WSCRIPT.EXE P:\Applicants\Applicants.wsf
and it runs great. When I try to run this as a scheduled task, it runs in under a second (it shouldn't be that fast) and claims it finished successfully. This is the 'action' I am running it under currently:
Start a Program
C:\Windows\SysWow64\WSCRIPT.EXE
Arguments: //Nologo //B P:\Applicants\Applicants.wsf >> P:\Applicants\logfile.txt
I have also tried running it under CScript instead of WScript and the result is exactly the same.
Before I added "//Nologo //B" (a tip I found here) it would start running and never stop.
The optional "Start In" box is empty. If I put any value in it at all (tried P:\Applicants) the task fails to start with "Error Value: 2147942667." No solutions offered by searching this error code have worked so I leave this box empty.
The logfile never even gets created and none of the work the script performs is getting done.
The task runs under my network account and should have access to all needed drives and resources.
Suggestions? Without a logfile I don't even know where to begin troubleshooting this thing.
EDIT: New Info: If I set it to run only when I am logged in it works fine. It is only when set to run even if user is logged off that it doesn't work, even if I am logged in when it runs.
EDIT 2: Security context of 'run even if user is logged off' states that ""...select the radio button labeled Run whether user is logged on or not. If this radio button is selected, tasks will not run interactively. To make a task run interactively, select the Run only when user is logged on radio button."
So I guess it thinks my script is somehow interactive, but it isn't. There aren't any kind of prompts or dialog boxes or msgBox calls so I'm not sure why this would be an issue.
Got it! The problem was that I was referencing a mapped drive with P:\ both in the 'action' call and in the script itself. When I replaced all calls to the P drive with the full network path \server\share everything works fine. Of course mapped drives aren't available if I'm not logged in, makes perfect sense :p
You have two options.
1.Create a batch file with the command to run, then schedule the batch file to run instead of the VBScript file.
2.Run the script file directly, instead of using WScript or CScript.
Sources: http://social.technet.microsoft.com/Forums/en-US/windowsserver2008r2general/thread/464a3bb3-3bcd-47a0-ab03-f0b8910f2ed1/

Same BAT file behaving differently when called from Desktop or from within a Program

I'm using Windows 7. I want to trigger a BAT file to run once some sound happens.
The BAT file should trigger a Skype call.
For that, I'm using the following BAT command:
c:\"Program Files"\Skype\Phone\skype /callto:someUsername
Skype should be already running before the trigger. If I double-click this BAT file on my desktop, it will run smoothly, pop up Skype, and start the call.
Now I'm using ISpy software to trigger the BAT file over a specified sound threshold.
ISpy is working fine. It detects the sound and triggers the BAT file.
But when the BAT file starts running, instead of popping up Skype it tries to load a new Skype instance.
Is there a context difference between calling BAT file with double click or within ISpy?
How can I overcome this?
#PaulojFonseca hasn't checked in since one day after this post, meaning Oct 29, 2012, so he won't likely come back to post his answer. Even though he won't be here to accept his own answer, I'll post it so at least it will show up. I've edited it to make the answer easier to read without much context.
"... when running ISpy, ... not all permissions [that were needed were] enabled. If i change this in the security preferences than the batch file runs smoothly."

How to run something after Windows logon is fully done?

I have a system service running on my Windows machine that can impersonate the currently logged on user and launch applications on their behalf (including UI apps).
It works fine when the user is already logged on into their interactive session, their Desktop is created, and so on.
The startup of the service is Automatic, so it is started automatically after each reboot. If it attempts to run some program (that needs UI access) immediately after the service is started, that program may fail - possibly because the autologon process is still in progress, the Desktop is not created yet, etc.
The question is: if the service starts "early", how can it wait for the interactive session to be fully initialized (apart from waiting some arbitrary time, which is not optimal)?
Or, can the service be started "late"? Is there a registry key, or a folder, or something else, that I can use to delay the service startup to the moment when the Shell is ready and it is safe to launch UI applications?
The easiest two ways to "execute some code when a user logs on" is to write a .bat file, and either:
1) Put the .bat file in the startup folder
<= Note: Windows 7/Vista has a new location for "Startup folder"
... or ...
2) Create a new Task that calls the .bat file at login
I option "2)" gives you finer control. It also allows the .bat file to "Run as Administrator" if needed.
If you'd like to make the .bat file pause briefly (e.g. to make sure things are completely initialized", you can add "ping -w" to your .bat file.
EXAMPLE:
#rem Waits 5 seconds before continuing
ping 1.1.1.1 -n 1 -w 5000 > nul

Resources