Running an automated script at scheduled intervals

Greetings all,
Is there a way to setup a process or job to run an SQL Script automatically on the first of the month? I am running on a server much like apex.oracle.com so I don't have permissions to the back end of the database and can't run a cron job.
What I am trying to do is run a script that updates a table on the 1st and 15th of the month.
I Googled it and searched OTN and was not able to find what I was looking for so asking the experts.
Thanks in advance for any assistance.
Wally

wfsteadman wrote:
I definitely did not good for dbms_scheduler or dbms_job.. so that may be my first issue. will this run from application express? I don't have access to the backend of the database or to a command line so I would have to set it up in the application and not sure how to do that.APEX provides SQL Workshop with the SQL Commands and SQL Scripts processors.
I've just successfully tested basic <tt>dbms_scheduler</tt> functions on apex.oracle.com, so try it on your environment.
<li>Go to SQL Workshop > SQL Commands
<li>Create a basic, run-once job (that actually does nothing):
begin
  dbms_scheduler.create_job(
    job_name => 'myjob',
    job_type => 'plsql_block',
    job_action => 'null;',
    enabled => true);
end;If this returns
Statement processed.rather than an error message then you're probably good to go.
<li>Check the execution log:
select * from user_scheduler_job_run_details;Should return something like:
5825946     19-JUL-11 02.53.12.839925 PM -05:00     NANDBTAG     MYJOB         -               SUCCEEDED     0           19-JUL-11 02.53.12.808693 PM AMERICA/CHICAGO     19-JUL-11 02.53.12.817457 PM AMERICA/CHICAGO     +000 00:00:00     1               1171,2895       25087         +000 00:00:00.02     -                     -                   -                     -               -<li>Try creating a job that runs every minute:
begin
  dbms_scheduler.create_job(
    job_name => 'myjob',
    job_type => 'plsql_block',
    job_action => 'null;',
    start_date => '19-JUL-11 03.10.00 PM', /* Remember to use the DB time, not your local time if not specifying a timezone */
    repeat_interval => 'freq=minutely',
    enabled => true);
end;<li>Check it's status in the <tt>user_scheduler_jobs</tt> view:
select * from user_scheduler_jobs;
MYJOB      -     REGULAR     APEX_PUBLIC_USER     MACMILP:1275550617277611      -      -      -     PLSQL_BLOCK     null;     0      -      -     CALENDAR     19-JUL-11 03.10.00.000000 PM -05:00     freq=minutely      -      -      -      -      -      -      -      -     DEFAULT_JOB_CLASS     TRUE     TRUE     FALSE     SCHEDULED     3     0      -     0      -     0      -      -     19-JUL-11 03.10.00.000000 PM -05:00      -      -     OFF     FALSE     TRUE      -     FALSE     1     NLS_LANGUAGE='AMERICAN' NLS_TERRITORY='AMERICA' NLS_CURRENCY='$' NLS_ISO_CURRENCY='AMERICA' NLS_NUMERIC_CHARACTERS='.,' NLS_CALENDAR='GREGORIAN' NLS_DATE_FORMAT='mm/dd/yyyy' NLS_DATE_LANGUAGE='AMERICAN' NLS_SORT='BINARY' NLS_TIME_FORMAT='HH.MI.SSXFF AM' NLS_TIMESTAMP_FORMAT='DD-MON-RR HH.MI.SSXFF AM' NLS_TIME_TZ_FORMAT='HH.MI.SSXFF AM TZR' NLS_TIMESTAMP_TZ_FORMAT='DD-MON-RR HH.MI.SSXFF AM TZR' NLS_DUAL_CURRENCY='$' NLS_COMP='BINARY' NLS_LENGTH_SEMANTICS='BYTE' NLS_NCHAR_CONV_EXCP='FALSE'      -     1      -      -      -      -      -     FALSE     FALSE      -     133168<li>And that it's executing every minute:
select * from user_scheduler_job_log;
5826446     19-JUL-11 03.13.00.264038 PM -05:00     NANDBTAG     MYJOB      -     DEFAULT_JOB_CLASS     RUN     SUCCEEDED      -      -      -      -      -      -      -      -
5826426     19-JUL-11 03.12.00.191519 PM -05:00     NANDBTAG     MYJOB      -     DEFAULT_JOB_CLASS     RUN     SUCCEEDED      -      -      -      -      -      -      -      -
5826386     19-JUL-11 03.11.00.075835 PM -05:00     NANDBTAG     MYJOB      -     DEFAULT_JOB_CLASS     RUN     SUCCEEDED      -      -      -      -      -      -      -      -
5826366     19-JUL-11 03.10.00.048849 PM -05:00     NANDBTAG     MYJOB      -     DEFAULT_JOB_CLASS     RUN     SUCCEEDED      -      -      -      -      -      -      -      -After that you want to experiment with the calendar syntax to figure out how to run a job on the first of the month, and plug in your own PL/SQL block or stored procedure <tt>job_action</tt> that actually does something.
And if that first call errors out and you don't get anywhere near this far, you'll have to contact the host DBAs an enquire about getting CREATE JOB privilege granted to the required parsing schema in your workspace.
(If it does work, remember to drop any experimental jobs when you're done to free up resources for everyone else!)

Similar Messages

  • To run my functional script in schedule times

    Hi
    This is ravi.
    I prepared one functional script using OATS. Then i want to run that script after some time.I want to put some schedule time to run that script .I have searched in the tool but i am unable to find the solution...can any please help me regarding this issue??
    Thanks in advance
    Edited by: 838740 on Feb 22, 2011 4:15 AM

    Hi we have created OATS ADF loadtesting script.. would like to know how we can run Loadtest in command line mode or schedule multiple LOAD test
    c:\oracleats\openscript\runscript.bat
    -- this will run only Open Script - single user
    OTM
    -- is letting me only to schedule functional tests not load tests
    please let us know if there is any way to schedule load test which will hel in automating our entire test env.
    Thanks
    Joseph

  • Running an Automator Script unpon wakeup

    I use automator to mount my network drives upon startup and runs a treat. I am trying to find away to run this script automatically after the computer wakes up.
    What also would be great would be if I could get an automator script to unmount the drives when the computer sleeps that way I can unmount the drives automatically.
    Any help would be great.

    You could save the workflow as an application, then enable it as a Login Item.
    J

  • Is there an AppleScript or Automator Script that will wake a Mac from Sleep?

    Is there an AppleScript or Automator Script that will wake a Mac from Sleep?

    Frank and All,
    The following answer to your question above is complicated, but I hope it explains why my question was formed with so much frustration in it.
    I have an OpenOffice(OO) Macro that was launched with Calendar at 6pm each business night. It ran properly in all Apples operating systems until I Hit Maverick(OSX10.9). From then on, the AppleScript would run from one to 3 days, then would disappear from the Calendar entry. The Calendar alert would still run, but the "OpenFile" section of the alert would disappear. I also was running elgato EyeTV HD during the day, so I would use energy saver to put my MacBook Pro to sleep at 12 Midnight and wake it again at 9am. I picked up a used Mac Mini to do the EyeTV stuff, provide AppleTV the files in H264 format through iTunes' media share, and found it had plenty of power to do the 6pm automated stuff simultaneously as well. Because I still wanted to run the OpenOffice Macro on my MacBook Pro at 6pm, and wanted to use it for a host of other things when I was on the road, I wanted it to sleep most of the time and only wake up automatically to run the 6pm OO Macro. When I called Apple about the issue I was having with Maverick and Calendar loosing the OpenFile command as part of the Alert Message, they told me the no longer supported answering AppleScript Questions but they now would support Automator questions. I pointed out that the OpenFile would also fail after one to three days if I used a Calendar Alert to launch an Automator App. At first, I did not like Automator, but now I see why Apple is pushing us to use it. Automator adds a TIME STAMP ID to the Apps developed in Automator so the first time you launch the App after a change to it, you must reply to a dialog message saying that this is the first time you are running this version of the App. If a Scammer has replaced your app with one that can reek havoc on your computer, the replacement app will not run unless you are there to agree that you know where the modified app came from and click the OK button to continue (BRILLIANT, Enhanced Security idea on Apples part). I also noticed that after Mountain Lion, the Applescript delay timing was all screwed up as well. Well I tried to use LaunchD Task Scheduler to circumvent the Calendar Problem and that worked until I upgraded to Yosemite Last week. Then LaunchD no longer worked and I am only into a few days of using The Calendar Launched Automator App to see if it will continue to run.
    But I think I solved the dilemma I was having with opening an Automator App in a Sleeping Mac. I Googled up the following question, "AppleScript to wake up computer".  I went thru several complex responses until I found this on that is INCREDIBLE EASEY! What came back was a brettterpstra.com  response from Feb 20th,2014. What it said, in a Quick Tip: caffeinated your Terminal Article,  if you wanted to wake a Mac from sleep, use the Terminal command named "Caffeine -u -t 1". I placed it in an Automator Most Used Action called "Run Shell Script -- Caffeine -u -t 1" and it worked!  Now, I can put my Mac to Sleep but at 6pm, the Automator App will launch, run the "Caffeine -u- -t 1" command and proceed to work as if I had awakened the Mac From Sleep mode by pressing a keyboard key and had run the Automator Script with a double click.
    Sorry for the long, drawn-out reply, but maybe this will help others.

  • How do I schedule an automator script to run at a certain time every day?

    How do I schedule an automator script to run at a certain time every day?
    This used to be done through iCalendar and this option is no longer available.
    How do I do this?
    --Kenoli

    Kenoli Oleari1 wrote:
    How do I schedule an automator script to run at a certain time every day?
    This used to be done through iCalendar and this option is no longer available.
    How do I do this?
    --Kenoli
    You can use lauchd to run the script.
    Here's an example of an Automator App that I have scheduled to run at 7am daily:
    You would save this as com.yourname.plist and put it the the Folder: ~/Library/LaunchAgents/ (then log out and back in, or reboot)
    (To run a workflow, change open to automator)
    (A nice GUI launchd editor is Lingon)
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
              <key>Label</key>
              <string>com.tonyt.EventReport</string>
              <key>ProgramArguments</key>
              <array>
                        <string>open</string>
                        <string>/Users/Tony/Library/Scripts/Events Report.app</string>
              </array>
              <key>StartCalendarInterval</key>
              <dict>
                        <key>Hour</key>
                        <integer>7</integer>
                        <key>Minute</key>
                        <integer>0</integer>
              </dict>
    </dict>
    </plist>

  • How to run an "Automator" application at regular time intervals

    I would like to find out how to run an "Automator" application at regular time intervals, say at every 5 minutes.
    Is there any program, AppleScript or any method to do this?
    I would very much appreciate a help.
    Suwan

    save your workflow as an ical plugin, this will automatically insert the workflow into ical,and create a workflow category for it, then just set to repeat every 5 minutes, or save as an APP and use a program called CRONIX (freeware) to run the schedule.

  • How to run an Automator app at a specific scheduled time?

    Hi all,
    I know this question has been answered before, but the only info I can find on it is extremely dated.
    How can I run an Automator app (rsync backup) at a specific scheduled daily time?

    One way is to use launchd.  The easiest way is with Lingon (search in the App store)
    Then in the run input box use "open" i.e: open "/users/tony/scripts/rsyncbu.app"

  • How I run a shell script from the scheduler on 10.2.0.2.0 ?

    Hello Oracle People,
    I'd like to run a shell script from the Scheduler in my 10g database.
    Right now it is a simple shell script.
    Eventually it will wrap RMAN commands to back up my DB.
    I wrote a simple pl/sql script to create a job:
    -- cr_job10.sql
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'my_backup_job',
    job_type => 'EXECUTABLE',
    job_action => '/h/oracle/scripts/tst.sh',
    start_date => '06-SEP-07 5.33.00PM US/Pacific',
    repeat_interval => 'FREQ=DAILY',
    end_date => '08-SEP-07 4.00.00PM US/Pacific',
    enabled => TRUE,
    comments => 'My Backup Job');
    END;
    I see no errors when I run the above procedure.
    I checked DBA_SCHEDULER_JOBS and the job is in there.
    The scheduler, though, errors out with an error which I see in a trace file:
    /h/oracle/admin/orcl/bdump/orcl_j000_22396.trc
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    ORACLE_HOME = /h/oracle/product/10r2
    System name: SunOS
    Node name: sol
    Release: 5.10
    Version: Generic_118855-14
    Machine: i86pc
    Instance name: orcl
    Redo thread mounted by this instance: 1
    Oracle process number: 15
    Unix process pid: 22396, image: oracle@sol (J000)
    *** ACTION NAME:(MY_BACKUP_JOB) 2007-09-06 17:33:00.175
    *** MODULE NAME:(DBMS_SCHEDULER) 2007-09-06 17:33:00.175
    *** SERVICE NAME:(SYS$USERS) 2007-09-06 17:33:00.175
    *** CLIENT ID:() 2007-09-06 17:33:00.175
    *** SESSION ID:(140.13520) 2007-09-06 17:33:00.175
    *** 2007-09-06 17:33:00.175
    ORA-12012: error on auto execute of job 53267
    ORA-27369: job of type EXECUTABLE failed with exit code: 274662
    I googled on this:
    ORA-27369: job of type EXECUTABLE failed with exit code: 274662
    Google returned only 1 hit.
    There, I see some evidence that I need to configure something inside
    of Oracle to run shell scripts from the scheduler, but possibly just
    for machines running windows. I'm running Solaris.
    Do any of you know what I need to configure inside of Oracle to
    run shell scripts from the scheduler?
    -Owen

    Hello people,
    I should have added this bit of information:
    "The script runs fine from oracle's crontab."
    "The script runs fine from a shell owned by oracle."
    I'm getting responses telling me to check my env variables and permissions
    which would be helpful to a UNIX novice.
    I have a feeling that no one is using the scheduler to run RMAN scripts.
    Tim Hall suggested I take a close look at these files:
    $ORACLE_HOME/rdbms/admin/externaljob.ora
    $ORACLE_HOME/bin/extJob
    Currently I'm setup like this:
    bash sol root /h/oracle/product/10r2/bin 31 #
    bash sol root /h/oracle/product/10r2/bin 31 # ll $ORACLE_HOME/rdbms/admin/externaljob.ora
    -rw-r--r-- 1 root dba 52 Sep 7 15:29 /h/oracle/product/10r2/rdbms/admin/externaljob.ora
    bash sol root /h/oracle/product/10r2/bin 32 #
    bash sol root /h/oracle/product/10r2/bin 32 # cat $ORACLE_HOME/rdbms/admin/externaljob.ora
    # externaljob.ora
    run_user = rman
    run_group = rman
    bash sol root /h/oracle/product/10r2/bin 33 #
    bash sol root /h/oracle/product/10r2/bin 33 #
    bash sol root /h/oracle/product/10r2/bin 33 #
    bash sol root /h/oracle/product/10r2/bin 33 # ll $ORACLE_HOME/bin/ext*
    -rwsr-x--- 1 rman dba 30388 Sep 21 2006 /h/oracle/product/10r2/bin/extjob*
    -rwsr-x--- 1 rman dba 30392 Sep 21 2006 /h/oracle/product/10r2/bin/extjobo*
    -rwsr-x--- 1 rman dba 34468 Sep 21 2006 /h/oracle/product/10r2/bin/extproc*
    -rwxr-xr-x 1 oracle dba 300 Sep 21 2006 /h/oracle/product/10r2/bin/extusrupgrade*
    bash sol root /h/oracle/product/10r2/bin 34 #
    bash sol root /h/oracle/product/10r2/bin 34 #
    bash sol root /h/oracle/product/10r2/bin 34 #
    On my system, the user 'nobody' has no shell so I cannot use nobody.
    I created a user named rman:
    bash sol root /h/oracle/product/10r2/bin 34 #
    bash sol root /h/oracle/product/10r2/bin 34 #
    bash sol root /h/oracle/product/10r2/bin 34 # su - rman
    Sun Microsystems Inc. SunOS 5.10 Generic January 2005
    $
    $ id
    uid=220(rman) gid=220(rman)
    $
    $
    $ date
    Fri Sep 7 16:30:03 PDT 2007
    $
    $
    Jared points out that rman needs access to extproc:
    $ ls -la /h/oracle/product/10r2/bin/extproc
    -rwsr-x--- 1 rman dba 34468 Sep 21 2006 /h/oracle/product/10r2/bin/extproc
    $
    $
    Here is a demo of rman running his script:
    bash sol root /h/oracle/product/10r2/bin 35 # su - rman
    Sun Microsystems Inc. SunOS 5.10 Generic January 2005
    $
    $
    $ ls
    scripts
    $
    $
    $ scripts/tst.sh
    $
    $
    $ cat scripts/tst.sh
    #! /bin/sh
    /usr/bin/date > /tmp/tst.sh.out.txt 2>&1 &
    exit 0
    $
    $
    $ cat /tmp/tst.sh.out.txt
    Fri Sep 7 16:31:23 PDT 2007
    $
    $ rm /tmp/tst.sh.out.txt
    $
    I am focused on this error:
    ORA-27369: job of type EXECUTABLE failed with exit code: 274662
    And I am focused on this exit code: 274662
    What does 274662 mean?
    If the Scheduler gives me an error like "274662" rather than some English,
    it's obvious to me the Scheduler is a POS and I should not use it.
    And of course,
    If I cannot run RMAN from Oracle Scheduler, I'll use cron.
    -Owen

  • What is the best way to run a powershell script with parameters in the Task Scheduler?

    Hello, 
    Want to run the following from a scheduled task in the Task Scheduler on a server.  What is the best approach?
    .\pscript.ps1 -csvfile "\\Srv1\Share\File.txt"
    Thanks for your help! SdeDot

    Hi,
    To run a powershell script with parameters in the Task Scheduler:
    Program: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Add argument (optional): -Command "& c:\scripts\test.ps1 -par1 2 -par2 3"
    Hope the below two articles be helpful for you:
    Schedule PowerShell Scripts that Require Input Values
    https://blogs.technet.com/b/heyscriptingguy/archive/2011/01/12/schedule-powershell-scripts-that-require-input-values.aspx
    How to Schedule a PowerShell Script
    http://dmitrysotnikov.wordpress.com/2011/02/03/how-to-schedule-a-powershell-script/
    Regards,
    Yan Li
    Regards, Yan Li

  • Run Powershell script from Scheduled Task as "NT Authority \ SYSTEM"

    Hello, dear Colleagues.
    Cannot make Powershell script from Scheduled Task as "NT Authority \ System"
    Action: Start a program - 
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "C:\script.ps1"
    The matter is that script is working, moreover if to run Task with Domain Account it works too.
    Checked Run with highest privileges, changed "Configure for" field, tried different arguments (-noprofile, -noexit, -executionpolicy bypass, -command, -file,") - no luck.
    Didn't you try to make it work with SYSTEM account?
    Thanks.

    Hi fapq,
    Try this link task schedulers
    Note
    To identify tasks that run with system permissions, use a verbose query (/query/v). In a verbose query display of a system-run task, the Run As User field has a value of NT AUTHORITY\SYSTEM and
    the Logon Mode field has a value of Background only.
    Naveen Basati

  • Calendar alarm fails to run Automator script if Mac is sleeping

    I have an Automator script to run a backup task which is saved as a Calendar alarm to run once every week.
    This was working perfectly in Snow Leopard - if the computer was asleep at the alarm time, then it would simply run the next time the computer is woken up.
    Then I upgraded to Mountain Lion, and had various issues. First, the alarm got imported to iCloud and caused unwanted pop-up alerts on all my iOS devices, but I resolved that by moving the alarm's calendar from "iCloud" to "On My Mac" (described here).
    Now I'm finding that if the computer is asleep at the alarm time, the script doesn't run at all.
    I don't want the computer to wake up in order to run the script, but to run the next time the computer is woken up, just like it did on Snow Leopard.
    Is this a known difference in behaviour between Snow Leopard and Mountain Lion, and is there any way to get the old behaviour?

    As no-one has confirmed whether this is expected behaviour or a bug, I've assumed it is a bug and raised a bug report at http://www.apple.com/feedback/macosx.html.
    In the meantime, I've created a repeating task in my To Do list app to remind me to run the backup script once a week (I'm using Cultured Code "Things" for task management).
    When the task pops up, I run the Automator workflow MANUALLY by double-clicking on the workflow ".app" file.
    It seems insane, but this is the only way I can be sure the Automator script runs once a week.

  • Running a SFTP script as a scheduled task

    Would like to run a SFTP script I wrote which is shown below as a scheduled task.  It runs fine when I don't use the task scheduler.  Technically it runs when I do use the task scheduler I just don't wind up with any .csv files.  It is
    currently written in vbscript and i'm not sure if it's worth it to convert it to powershell.  Do you have advice on what I can do differently to make it work as a scheduled task?  To attempt to resolve the problem I tried to run it
    from a BATCH file which did not help.
    set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.run("C:\xyz\PSFTP.EXE")
    WshShell.AppActivate "C:\xyz\PSFTP.EXE"
    WScript.Sleep 1000
    WshShell.SendKeys"open secureftp.server.com"
    WshShell.SendKeys("{Enter}")
    WScript.Sleep 1000
    WshShell.SendKeys"Username"
    WshShell.SendKeys("{Enter}")
    WScript.Sleep 1000
    WshShell.SendKeys"Password"
    WshShell.SendKeys("{Enter}")
    WScript.Sleep 1000
    WshShell.SendKeys"cd Folder1"
    WshShell.SendKeys("{Enter}")
    WScript.Sleep 1000
    WshShell.SendKeys"mget *.*"
    WshShell.SendKeys("{Enter}")
    WScript.Sleep 4000
    WshShell.SendKeys("bye")
    WshShell.SendKeys("{Enter}")
    The file shown below is how I wrote the batch file.  The first line clears out all previous .csv files and I delay a second and kick off the vbscript.
    Del /Q "C:\xyz\*.csv"
    ping 192.0.2.2 -n 1 -w 1000 > nul
    wscript "C:\xyz\ftp.vbs"

    Thanks Bill I appreciate that.
    The first thing I needed to do was add the start in path to the scheduled task
    Then the script needed converted to powershell since sendkeys is no longer supported.  I found a good example on the net and used it.
    $username = "Username"
    $password = "Password"
    $server = "secureftp.server.com"
    $exepath="C:\xyz\PSFTP.EXE"
    $cmd = @(
    "cd ..",
    "cd folder1",
    "mget *.*",
    "bye")
    $cmd | & $exepath -pw $password "$username@$server"

  • Jquery slider is not consistently loads while running coded ui automation script

    Hello Guys,<o:p></o:p>
    I am doing coded ui automation testing for mvc application. Now there are some features where we are loading Jquery slider from left towards right. Actually those slider loads properly
    when users does it manually but when i ran it using coded ui script, so sometimes slider comes and go back within seconds .This means it is not loading properly but sometime its load fine.so due to that coded ui does not find respective control to click over.<o:p></o:p>
                I have tried to wait with different option of playback , wait , delay but the behavior is still same.
    That means my test fails to load proper slider window  most of the time.<o:p></o:p>
    Can anyone suggests me some inclinations to solve this problem. <o:p></o:p>
    Thanks in advance.<o:p></o:p>

    Actually i have tried to wait in all possible ways provided by coded ui . But issue happens only sometime during following scenario:
    1. I click on "x" button 
    2. Then that slider gets loaded from right towards left. There is again other internal ajax call which brings up data to show on slider. For that i have used webwaitforcontrolready=3 to disable ajax or js engine. 
    3. But sometimes problem occurs when automation scripts clicks on "x" button ,then slider comes and go back within fraction of seconds. I do not know whether it is due to network speed or any other issue. so due to that subsequent action on that slider are
    not getting executed or gets failed.
    could you please suggests me which wait should i use till that slider loads completely and then only move to next action?
    i have tried using wait(), thread sleep(),waitforcontrolready(),waitforcontrolexits(),waitforcontrolenabled(),playback.settings.waitforreadylevel=allthreads.

  • Alternatives to PowerShell automation of Excel (Scheduled Task) in a Windows Server 2012 R2 world

    I have a handful of PowerShell scripts that ran as Scheduled Tasks on an old Windows 2008 SP2 server, which output reports as Excel workbooks with multiple worksheets, via a COM object. After migrating these scripts to a new Windows 2012 R2 server,
    these scripts no longer function. The Server 2008 system was running Office 2007, and the new Server 2012 R2 server has Office 2013 installed.
    What is everyone using on their Server 2012 R2 systems to automate generation of multi-sheet reports in Excel via PowerShell and Scheduled Tasks?
    I know that Microsoft has said that automating Office applications server-side in non-interactive mode, but it has worked in the past, until now. (https://support.microsoft.com/kb/257757)
    I've tried the OpenXML PowerTools for PowerShell (https://powertools.codeplex.com/), but Export-OpenXMLSpreadsheet will only export a single worksheet, and they don't support adding worksheets to existing files
    (am I missing something?). I understand the OpenXML PowerTools can be extended in C#, but I don't C#. The PowerShell cmdlets were released in Jan 2012, but don't look to have been updated since then (updates have been the core C# code).
    I've seen recommendations to add C:\Windows\(System32 or SysWOW64)\config\systemprofile\Desktop, but this hasn't worked on Server 2012.
    Has anyone been able to get Excel 2013 to cooperate on Server 2012 R2, or come up with a suitable alternative? I'd rather not start running these scripts from my workstation.
    EDIT:
    I'm not necessarily looking for an Excel answer, since there are OpenXML ways of doing things now without the Excel application.
    Here are some of the errors I'm getting when approaching this from different directions. When I use:
    $excel = New-Object -comobject Excel.Application$workbook = $excel.Workbooks.Add()
    Results in error:
    Exception calling "Add" with "0" argument(s): "Microsoft Excel cannot open or
    save any more documents because there is not enough available memory or disk
    space.
    • To make more memory available, close workbooks or programs you no longer
    need.
    • To free disk space, delete files you no longer need from the disk you are
    saving to."
    At C:\path\to\script.ps1:21 char:2
    + $workbook = $excel.Workbooks.Add()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ComMethodTargetInvocation
    The server is definitely not lacking for resources.
    I can copy a blank XLSX file and use .Open($xlFile) instead of .Add(), but then when I go to open a CSV file to copy/paste the content to a worksheet, I get this one:
    Exception calling "Open" with "1" argument(s): "The server threw an exception.
    (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"
    At C:\path\to\script.ps1:65 char:2
    + $tempcsv = $excel.Workbooks.Open($CSVFile)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ComMethodTargetInvocation
    Things that I've tried so far, with no success:
    I created C:\Windows\System32\config\systemprofile\Desktop and C:\Windows\SysWOW64\config\systemprofile\Desktop as suggested here:
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/0751119d-84d5-4a77-8240-1c4802f97375/powershell-scheduled-tasks-wont-start-excel?forum=winserverpowershell
    Add Local Launch and Local Activation permissions to the Microsoft Excel Application DCOM Config, Grant "Read & Execute, List folder contents, Read" permissions on the \config\systemprofile\Desktop folder. Grant "Modify, Read & Execute,
    List Folder Content, Read, Write" permissions for the account on the following folders:
    \config\systemprofile\AppData\Roaming\Microsoft
    \config\systemprofile\AppData\Local\Microsoft
    as suggested here:
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/aede572b-4c1f-4729-bc9d-899fed5fad02/run-powershell-script-as-scheduled-task-that-uses-excel-com-object?forum=winserverpowershell
    @ jrv - I will try posting a similar question in the Excel 2013 forum, but since I'm looking for a scripting solution to produce an OpenXML spreadsheet, and not something that necessarily uses the Excel application (though such a solution would not be turned
    away), I thought this the more appropriate venue.
    (to reiterate from OP) I have seen and acknowledge Microsoft's statements regarding the unsupported nature of automating Office applications in non-interactive environments, but the truth of the matter is, supported or not, it worked in the past (Server
    2008), it's what I inherited from my predecessor, and I know I'm not the only one who has been using Excel in this way. I'm only asking fellow scripters, some of whom must also be using Excel in this "unsupported" fashion, how they are automating
    creation of their spreadsheet reports after moving to Server 2012. A different system modification to make the Excel comObject continue working as before? Direct manipulation of the OpenXML document? Other solutions that may or may not require launching the
    Excel application?

    #1 - Ask in Excel 2013 forum.
    #2 - Microsoft has repeatedlynoted that this is NOT a supported configuration for Office products.
    #3 - What errors are you getting?
    #4 - What have you done to debug this:
    #5 - No one can be of much help unless you post a very simple example of how this fails.
    ¯\_(ツ)_/¯

  • Need automation script to detect deadlocks in a system.

    Hi ,
    I need a automation script to detect deadlocks in my system.  If any body have any scripts. please share with me.. that would be very helpful to me.
    Note : if i ran the script that would show the list of deadlock occurred in my system that must be automatic process..
    Thanks in advance
    Yangamuni Prasad M

    Hi pradas,
    you can even runthe following and as uri Said Traceflag 1222 must be on (DBCC TRACEON(1222, -1).
    IF
    OBJECT_ID(
    'dbo.usp_DeadlockNotification')
    IS NOT NULL
    DROP
    PROC dbo.usp_DeadlockNotification
    --GO
    CREATE
    PROC dbo.usp_DeadlockNotification
    @FilterBIT
    = 0,
    @Minutes
    INT = 30
    AS
    DECLARE @ErrorLog
    TABLE
    LogDate
    DATETIME NOT
    NULL,
    ProcessInfo
    VARCHAR(75),
    LogInfo
    VARCHAR(MAX)
    create a SQL job and run
    DECLARE @Count
    INT,
    @StartDate
    DATETIME,
    @EndDate
    DATETIME
    SET @Count
    = 0
    SET
    NOCOUNT ON
    -- Step I: Import Errorlog
    INSERT
    INTO @Errorlog
    EXEC
    xp_readerrorlog
    ---- Step II: How to search Errorlog
    IF
    (@Filter
    <> 0)
    BEGIN
    SELECT @EndDate
    = GETDATE()
    SELECT @StartDate
    = DATEADD(mi,
    -@Minutes, @EndDate)
    SELECT @Count
    = COUNT(*)
    FROM @Errorlog
    WHERE LogDate
    BETWEEN @StartDate AND @EndDate
    AND LogInfo
    LIKE '%Deadlock%'
    END
    ELSE
    BEGIN
    SELECT @Count
    = COUNT(*)
    FROM @Errorlog
    WHERE LogInfo
    LIKE '%Deadlock%'
    END
    ---- Step III: Send Email
    IF
    (@Count
    > 0)
    BEGIN
    EXEC msdb.dbo.sp_send_dbmail
    @profile_name
    = 'ABC',
    @recipients
    = '[email protected]',
    @subject
    = 'Deadlocks',
    @body
    = 'Deadlocks'
    END
    Create a agent job and schedule it accordingly as per you requirment and add following step in the job
    EXEC dbo.usp_DeadlockNotification 1, 30
    Thanks,Suhas V

Maybe you are looking for