Calling powershell script from a batch file

Hello All,
I have a batch script that calls a powershell script. Before calling the script I set the execution policy to unrestricted, but when it gets to the line that calls the batch script i still get the confirmation in the command window: "Do you want to
perform this operation" I then have to press Y for the PS script to run and then my batch script finishes.
Does anyone know the setting I need to change in order to suppress the confirmation?
Note: this is Windows 8, see code below
set THIS_DIR=%~dp0
powershell Set-ExecutionPolicy unrestricted
powershell %THIS_DIR%MyScript.ps1 "param1"

I may sound like a jerk but you really want to look at PowerShell.exe /?
PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>]
    [-NoLogo] [-NoExit] [-Sta] [-Mta] [-NoProfile] [-NonInteractive]
    [-InputFormat {Text | XML}] [-OutputFormat {Text | XML}]
    [-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>]
    [-File <filePath> <args>] [-ExecutionPolicy <ExecutionPolicy>]
    [-Command { - | <script-block> [-args <arg-array>]
                  | <string> [<CommandParameters>] } ]
PowerShell[.exe] -Help | -? | /?
-PSConsoleFile
    Loads the specified Windows PowerShell console file. To create a console
    file, use Export-Console in Windows PowerShell.
-Version
    Starts the specified version of Windows PowerShell.
    Enter a version number with the parameter, such as "-version 2.0".
-NoLogo
    Hides the copyright banner at startup.
-NoExit
    Does not exit after running startup commands.
-Sta
    Starts the shell using a single-threaded apartment.
    Single-threaded apartment (STA) is the default.
-Mta
    Start the shell using a multithreaded apartment.
-NoProfile
    Does not load the Windows PowerShell profile.
-NonInteractive
    Does not present an interactive prompt to the user.
-InputFormat
    Describes the format of data sent to Windows PowerShell. Valid values are
    "Text" (text strings) or "XML" (serialized CLIXML format).
-OutputFormat
    Determines how output from Windows PowerShell is formatted. Valid values
    are "Text" (text strings) or "XML" (serialized CLIXML format).
-WindowStyle
    Sets the window style to Normal, Minimized, Maximized or Hidden.
-EncodedCommand
    Accepts a base-64-encoded string version of a command. Use this parameter
    to submit commands to Windows PowerShell that require complex quotation
    marks or curly braces.
-File
    Runs the specified script in the local scope ("dot-sourced"), so that the
    functions and variables that the script creates are available in the
    current session. Enter the script file path and any parameters.
    File must be the last parameter in the command, because all characters
    typed after the File parameter name are interpreted
    as the script file path followed by the script parameters.
-ExecutionPolicy
    Sets the default execution policy for the current session and saves it
    in the $env:PSExecutionPolicyPreference environment variable.
    This parameter does not change the Windows PowerShell execution policy
    that is set in the registry.
-Command
    Executes the specified commands (and any parameters) as though they were
    typed at the Windows PowerShell command prompt, and then exits, unless
    NoExit is specified. The value of Command can be "-", a string. or a
    script block.
    If the value of Command is "-", the command text is read from standard
    input.
    If the value of Command is a script block, the script block must be enclosed
    in braces ({}). You can specify a script block only when running PowerShell.exe
    in Windows PowerShell. The results of the script block are returned to the
    parent shell as deserialized XML objects, not live objects.
    If the value of Command is a string, Command must be the last parameter
    in the command , because any characters typed after the command are
    interpreted as the command arguments.
    To write a string that runs a Windows PowerShell command, use the format:
        "& {<command>}"
    where the quotation marks indicate a string and the invoke operator (&)
    causes the command to be executed.
-Help, -?, /?
    Shows this message. If you are typing a PowerShell.exe command in Windows
    PowerShell, prepend the command parameters with a hyphen (-), not a forward
    slash (/). You can use either a hyphen or forward slash in Cmd.exe.
Hope that helps! Jason

Similar Messages

  • Calling Powershell Script from a vRA Blueprint

    Hi all,
    Need your help! I have a use case where I need to provide user a dropdown list in the Blueprint so that they can select a project number. The project numbers are dynamic and can be exported to a .csv file and I can then write a PS script to capture that.  I’m just not sure on how to present that data in the vRA Blueprint as the list is always changing?  Is there a way to create a custom Control Type in Property Dictionary say “DropDownListFromPowerShell” OR any other solution to address this use case? Any advice will be greatly appreciated.
    Thank you,
    Tony

    you cant do that in IaaS. you would need to use ASD to do those custom server side look ups in your forms.

  • How to execute a  .sql file from a batch file

    Hi all
    I've to take backup of a database weekly twice on every wednesday & Friday @ 5pm IST. I've written a hot backup script, which works every well.
    now i want to automate the script. ie i want this script to run on wednesday & friday @ 5pm without any human interfearance ie with out actually any1 executing this script.
    i created a batch file prod.bak with the following lines
    @echo off
    set oracle_sid=testdb
    set oracle_home=d:\oracle\ora92
    sqlplus /nolog
    connect sys as sysdba/oracletest@testdb
    this batch file when eexecuted connects me to sql prompt.
    Now i want to execute my backup script bkp.sql automatically when it is connected to sql prompt.
    (i tried with these lines in the above batch file...
    call bkp.sql---it just opens the bkp.sql file in notepad & displays the script
    start bkp.sql---same as call
    connect / as sysdba/pwd@[email protected] --- does not work simply remains a the sql prompt.
    At 17:00 /Every:w,f "d:\bkp.sql"---does not work simply remains at the sql promt.)
    Can any1 let me know what should i write in the batch file that will execute the bkp.sql file automatically after it gets connected to sql prompt. M using oracle 9i.
    I'll manage he time through windows utility of scheduling task.. Let me know how to execute the .sql file from a batch file.
    Thanks
    Tripti

    Try
    sqlplus "sys/oracletest as sysdba" @bpk.sql
    Working locally, and having set the ORACLE_SID, you don't need to specify the SqlNet alias (@testdb).
    Remember to put an exit at the end of the bpk.sql script.

  • Installing Oracle 11gR2 client from a batch file and it returns before done

    Hello,
    While installing Oracle 11gR2 client on XP and 7 from a batch file. When it launches the OUI from the batch file, it returns to the batch file before the installer finishes. So, there is no way for my script to know when the installer is done, or to glean a return code to test for success. This is particularly annoying...
    I've also used the "call" command to force my batch file to wait, to no avail. Anyone have any clues about this one?
    Thanks in advance!
    --Robert                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Srini,
    Awesome! Worked like a charm.
    Many thanks!
    --Robert                                                                                                                                                                                               

  • Run PowerShell script from C# writing to input pipe

    Hello,
    I am trying to run a PowerShell script from C# (I have no control over what's in the script). The script may have a prompt like "Press enter to continue". So my goal is:
    1. Get text output from the script (easy, many examples available)
    3. If output contains "Press enter to continue", write a blank line to the running script's pipe to make it finish its job and quit
    4. If output does contain that prompt, just let it exit by itself without sending any input
    Note that commands in this PS script also try to get at script's file path, so I can't read script from file and pass it as text. It has to be executed as a script so it knows where it's located.
    I have done this with .exes and batch files before. All you do in that case is process.StandardInput.WriteLine() which "types" enter into the input stream of script you are trying to control. But this does not work with Power Shell. How do I do this?
    I have tried using PS object model like so:
    using (Pipeline pipeline = runspace.CreatePipeline())
    Command command = new Command(scriptPS, true, true);
       pipeline.Commands.Add(command);
       pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
       pipeline.Input.Write("\n");
       Collection<PSObject> psresults = pipeline.Invoke();   //...
    But I get an error because the script prompts:
    "A command that prompts the user failed because the host program or the command type does not support user interaction. Try a host program that supports user interaction, such as the Windows PowerShell Console or Windows PowerShell ISE, and remove prompt-related
    commands from command types that do not support user interaction, such as Windows PowerShell workflows."
    I also tried using Process, and running PowerShell with -File switch to execute the script, then write to StandardInput with C#. I get no errors then, but the input is ignored and doesn't make it to PowerShell.
    Please help!

    No man, what kind of answer is that? You should have left it unanswered rather than waste people's time like this. I already seen those links before I posted my question. They address the issue of specifying script parameters, but not
    writing to the input pipe.
    Fortunately I did figure this out by writing a custom script host for PowerShell. Anyone interested can read about this in detail on MSDN (fortunately simple material with samples you can copy paste as I did, so this solution takes little time to implement).
    Implement PSHost interface. Nothing special here, just paste directly from MSDN sample and modify their SetShouldExit function definition to contain just a "return;". Here's the relevant link:
    http://msdn.microsoft.com/en-us/library/windows/desktop/ee706559(v=vs.85).aspx
    Implement PSHostUserInterface interface. This is the ticket to solving this problem
    (see below). Here's the MSDN link:
    http://msdn.microsoft.com/en-us/library/windows/desktop/ee706584(v=vs.85).aspx
    Implement PSHostRawUserInterface. This may not be required (not sure) but I did anyway. Nearly a direct paste from MSDN:
    http://msdn.microsoft.com/en-us/library/windows/desktop/ee706601(v=vs.85).aspx
    So, there are two PSHostUserInterface function implementations that are of particular interest. First is Prompt (read header comment to see why):
    /// <summary>
    /// When script attempts to get user input, we override it and give it input programmatically,
    /// by looking up within promptInput's dictionary<string,string> or lineInput array.
    /// PromptInput dictionary is mapped by input prompt (for example, return "" in response to "Press ENTER to continue")
    /// LineInput is a regular array, and each time the script wants to prompt for input we return the next line in that array;
    /// this works much like piping inputs from a regular text file in DOS command line.
    /// </summary>
    /// <param name="caption">The caption or title of the prompt.</param>
    /// <param name="message">The text of the prompt.</param>
    /// <param name="descriptions">A collection of FieldDescription objects that
    /// describe each field of the prompt.</param>
    /// <returns>Throws a NotImplementedException exception.</returns>
    public override Dictionary<string, PSObject> Prompt(string caption, string message, System.Collections.ObjectModel.Collection<FieldDescription> descriptions)
    Dictionary<string, PSObject> ret = new Dictionary<string, PSObject>();
    foreach (FieldDescription desc in descriptions)
    if (this.promptInput.Count != 0)
    ret[desc.Name] = new PSObject(this.promptInput[desc.Name] + "\r\n");
    else if (this.lineInput != null && this.currentLineInput >= 0 && this.currentLineInput < this.lineInput.Length)
    ret[desc.Name] = new PSObject(this.lineInput[this.currentLineInput++] + "\r\n");
    else
    if (desc.DefaultValue == null)
    ret[desc.Name] = new PSObject("\r\n");
    else
    ret[desc.Name] = new PSObject(desc.DefaultValue);
    return ret;
    Next is PromptForChoice. Here I opted to always return the default choice, but you could rewrite it to read from somewhere to "simulate" reading from input pipe just like the function above:
    public override int PromptForChoice(string caption, string message, System.Collections.ObjectModel.Collection<ChoiceDescription> choices, int defaultChoice)
            return defaultChoice;
    Last but not least, here's a ReadLine implementation (again read header comment):
    /// <summary>
    /// If the LineInput is set, "read" the next line from line input string array, incrementing line pointer/// </summary>
    /// <returns>The characters that are entered by the user.</returns>
    public override string ReadLine()
    if (this.lineInput != null && this.currentLineInput >= 0 && this.currentLineInput < this.lineInput.Length)
    return this.lineInput[this.currentLineInput++];
    else
    return Console.ReadLine();
    Both are exposed as properties:
    /// <summary>
    /// Gets or sets the input pipe override
    /// </summary>
    public string Input
    get
    return string.Join("\n", this.lineInput);
    set
    if (value != null)
    this.lineInput = value.Split('\n');
    this.currentLineInput = 0;
    else
    this.lineInput = null;
    /// <summary>
    /// Gets or sets input pipe override for named prompts
    /// </summary>
    public Dictionary<string, string> PromptInput
    get
    return this.promptInput;
    set
    this.promptInput = value;
    And finally, here's how the whole shebang is used:
    /// <summary>
    /// Runs a powershell script, with input pipe arguments
    /// </summary>
    /// <param name="script">Path of the script to execute, or script text</param>
    /// <param name="inline">Whether or not to execute script text directly, or execute script from path</param>
    /// <param name="unrestricted">Whether or not to set unrestricted execution policy</param>
    /// <param name="parameters">Parameters to pass to the script command line</param>
    /// <param name="inputOverride">Input to pass into the script's input pipe</param>
    /// <param name="inputOverrideName">Input to pass into the script's input pipe, to each prompt by label</param>
    /// <returns>Output lines</returns>
    public static string PowerShell(string script, bool inline, bool unrestricted = false, Dictionary<string, string> parameters = null, string inputOverride = null, Dictionary<string, string> inputOverrideByName = null)
    string output = null;
    ScriptHost host = new ScriptHost();
    (host.UI as ScriptHostUserInterface).Input = inputOverride;
    (host.UI as ScriptHostUserInterface).PromptInput = inputOverrideByName;
    using (Runspace runspace = RunspaceFactory.CreateRunspace(host))
    runspace.Open();
    if (unrestricted)
    RunspaceInvoke runSpaceInvoker = new RunspaceInvoke(runspace);
    runSpaceInvoker.Invoke("Set-ExecutionPolicy Unrestricted");
    using (Pipeline pipeline = runspace.CreatePipeline())
    if (inline)
    pipeline.Commands.AddScript(script);
    else
    Command command = new Command(script, true, true);
    foreach (KeyValuePair<string, string> param in parameters)
    command.Parameters.Add(param.Key, param.Value);
    pipeline.Commands.Add(command);
    pipeline.Commands.Add("Out-String");
    pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
    Collection<PSObject> psresults = pipeline.Invoke();
    var sb = new StringBuilder();
    foreach (PSObject obj in psresults)
    sb.AppendLine(obj.ToString());
    output = sb.ToString();
    pipeline.Dispose();
    runspace.Close();
    return (host.UI as ScriptHostUserInterface).Output + "\r\n" + output;
    As you can see, I also did some magic with the .Output property. That just accumulates lines of text output by the script in every WriteXXX function implemented in your custom PSHostUserInterface. The end result of all this, is that if you have a script
    that has prompts, choices or reads from standard input, you can execute the script within the context of your custom script host written as above, to control precisely what strings are passed to it in response to prompts.
     

  • Error while calling pscp.exe through a batch file which is called in SSIS Execute Process Task

    Hi,
    I am using Windows Server 2012 R2 Standard, SSIS 2012. I am trying to copy files from a remote location by calling pscp.exe through a batch file (FileCopy.bat at location M:\bin\) which is referenced in a SSIS Execute Process Task. My batch file content
    is,
    ECHO OFF
    echo. >> M:\Prod\bin\SourceFile_FileLog.txt
    echo %date% - %time% - Copy Start (XYZ_a201211155952avx0_69999.NOR.gz) >> M:\Prod\bin\SourceFile_FileLog.txt
    M:\ProdFiles\bin\pscp.exe -unsafe -scp -pw aaaaa myuser@sourceserver:/ABC_data/*.NOR.gz M:\Prod\FromMediation\
    echo %date% - %time% - Copy Complete >> M:\Prod\bin\SourceFile_FileLog.txt
    The error I am getting is 
    [Execute Process Task] Error: In Executing "M:\bin\FileCopy.bat" "" at "", The process exit code was "1" while the expected was "0".
    Exactly same setup but using Windows Server 2003 R2 Enterprise and SSIS 2005, this works fine and copies the files successfully.
    Please provide some guidance on this.
    Thank you!
    'In Persuit of Happiness' and ..... learning SQL.

    Hi,
    This is what I am getting while running the batch file from command prompt
    M:\bin\mttrb1>CDR_FileCopy
    M:\bin\mttrb1>ECHO OFF
    The system cannot find the path specified.
    The system cannot find the path specified.
    scp: M:\Prod\FromMediation\: Cannot create file
    scp: M:\Prod\FromMediation\: Cannot create file
    scp: M:\Prod\FromMediation\: Cannot create file
    The system cannot find the path specified.
    'In Persuit of Happiness' and ..... learning SQL.

  • Retrieving process id from a batch file

    Hi friends,
    I am having a problem to retrieve the process id from a batch file. I will give the code which I have written and if anyone can help me it will be grateful. I am having time pressure. Here when I call
    Process p = rt.exec("checkExec.bat");
    the process is getting created. What I need is "I have to get the process id inside the batch file and then I have to store that process id to a file. My problem is "HOW CAN I GET HOLD OF PROCESS ID". Please give some guidance.
    !!!!THANKS IN ADVANCE !!!
    PROCESSTEST:
    public class ProcessTest {
         * @param args
         public static void main(String[] args) throws IOException {
              Runtime rt = Runtime.getRuntime();
              try {
                   Process p = rt.exec("checkExec.bat");
              } catch (IOException e) {
                        e.printStackTrace();
    CHECKEXEC.BAT
    cd bin
    java duo.CalledProcess
    CALLEDPROCESS
    public class CalledProcess {
         * @param args
         public static void main(String[] args) {
              try {
                   Runtime rt = Runtime.getRuntime();
                   synchronized (rt) {
                        while(true){
                             rt.exec("notepad");
                             long sec = 100000;
                             rt.wait(sec);
              } catch (InterruptedException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }

    problem is "HOW CAN I GET HOLD OF PROCESS ID".You can take it from the Operating System using JNI.

  • Execute powershell script from ssis?

    Hi,
    I was trying to use the execute process task to kick off a powershell script.  However, nothing happens when I run in debug (the component turns yellow and stays yellow).  Any idea if what I am trying to do is possible and the proper way to configure
    it?
    btw, I am using powershell for the remoting capabilites.  I need to execute a bat file on a remote server which runs a process in a legacy program. 
    Update:  When I name the ps1 script file in the executable window, it opens it in notepad.  This would be like the default if you double clicked the file.
    Mark

    To run a PowerShell Script from SSIS package. Add a "Execute Process Task" in SSIS and use the following command text.
    This works just great, plus the "-ExecutionPolicy ByPass" switch will take care of any server script policies.
    C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe
    -ExecutionPolicy ByPass -command ". 'L:\Powershell_Script\Script1.ps1' 'param1' 'param2'"
    Regards
    Deepak

  • Calling Python Script from LabVIEW

    Hello Everyone,
    I want to call the Python script from LabVIEW.
    I tried with using at the command line but i am unable to run that script file..
    i have gone through LabPython but i am unable to call the scripts from there also..
    If someone has an example of a VI which invokes a python script, it will be very helpful...
    Thanks a lot in advance
    Regards
    Avni

    avni wrote:
    I have to invoke the Script file at command prompt.
    Can you descriobe your restriction(s) concerning "invoke the script at the command prompt"?  There may be ways around that.

  • Not able to call sql script from shell program

    Hi Gurus,
    I am facing issue while calling sqlplus script from my shell program. Please find below my shell script. This program I've written and registered as for one of concurrent program
    in oracle applications.
    p_userid_passwd=$1
    p_appl_login=$2
    p_user_name=$3
    p_request_id=$4
    v_conc_request_id=${5}
    p_to_role=${6}
    p_from_role=${7}
    p_subject=${8}
    p_body=${9}
    p_dist_list=${10}
    v_request=${11}
    v_file_path_name=/u01/oraspt/REQUEST
    cd $APPLCSF/$APPLOUT
    echo "v_conc_request_id" $v_conc_request_id
    echo "p_to_role" $p_to_role
    echo "p_from_role" $p_from_role
    echo "p_subject" $p_subject
    echo "p_body" $p_body
    echo "p_dist_list" $p_dist_list
    echo "v_request" $v_request
    ls -l $v_request
    if [ $? -ne 0 ]
    then
       echo "No output request generated"
    else
       echo "Output request generated" 
    fi
    echo "connecting to ftp for placing out file to DB server"
    echo FTP to 99.60.17.11
    echo username: "oraspt"
    echo pw:        
    ftp -i -n 99.60.17.11 << EOF2
    user "oraspt" orakdk
    cd $v_file_path_name
    put $v_request
    bye
    EOF2
    output=`sqlplus -s /nolog <<EOT
    whenever sqlerror exit failure;
    connect  apps/apps
    set verify off;
    set serveroutput on size 120000;
           DECLARE
             l_errbuf      varchar2(300);
             l_retcode     varchar2(300);
           BEGIN      
            XXFND_SEND_MAIL.SEND_NOTIFICATIONS(  errbuf        => l_errbuf
                                               , retcode       => l_retcode
                                               , p_request_id  => $v_conc_request_id
                                               , p_to_role     => $p_to_role
                                               , p_from_role   => $p_from_role
                                               , p_subject     => $p_subject
                                               , p_body        => $p_body
                                               , p_dist_list   => $p_dist_list);
         EXCEPTION
            when others then
               dbms_output.put_line('Error encountered :'||SQLERRM);
         END;    
    EOT
    `
    echo "connecting to ftp for deleting output file"     
    echo FTP to 99.60.17.11
    echo username: "oraspt"
    echo pw:        
    ftp -i -n 99.60.17.11 << EOF2
    user "oraspt" orakdk
    cd $v_file_path_name
    delete $v_request
    bye
    EOF2
    echo "Deleted successfully"Output for script is as below
    v_conc_request_id 451906
    p_to_role DC.DKHOO
    p_from_role DC.DKHOO
    p_subject Receivable audit report10
    p_body Please find Audit Report Attachment.
    p_dist_list
    v_request o451906.out
    -rw-r--r-- 1 applspt dba 2368 Dec 28 15:06 o451906.out
    Output request generated
    connecting to ftp for placing out file to DB server
    FTP to 10.60.17.11
    username: oraspt
    pw:
    connecting to ftp for deleting output file
    FTP to 10.60.17.11
    username: oraspt
    pw:
    Deleted successfullyPlease let me know how to trigger pl/sql script.
    Thanks in advance for your help.
    Regards
    Nagendra
    Edited by: 838961 on Dec 27, 2011 11:25 PM

    Please find output as suggested, I've placed set -x in script.
    + p_userid_passwd=APPS/APPS
    + p_appl_login=1110
    + p_user_name=DC.DKHOO
    + p_request_id=451949
    + v_conc_request_id=451945
    + p_to_role=DC.DKHOO
    + p_from_role=DC.DKHOO
    + p_subject=Receivabless
    + p_body=report
    + p_dist_list=
    + v_request=o451945.out
    + v_file_path_name=/u01/oraspt/REQUEST
    + cd /u01/applspt/inst/apps/SPT_nfs-stg-app1/logs/appl/conc/out
    + echo v_conc_request_id 451945
    v_conc_request_id 451945
    + echo p_to_role DC.DKHOO
    p_to_role DC.DKHOO
    + echo p_from_role DC.DKHOO
    p_from_role DC.DKHOO
    + echo p_subject Receivabless
    p_subject Receivabless
    + echo p_body report
    p_body report
    + echo p_dist_list
    p_dist_list
    + echo v_request o451945.out
    v_request o451945.out
    + ls -l o451945.out
    -rw-r--r-- 1 applspt dba 2368 Dec 28 15:54 o451945.out
    + '[' 0 -ne 0 ']'
    + echo 'Output request generated'
    Output request generated
    + echo 'connecting to ftp for placing out file to DB server'
    connecting to ftp for placing out file to DB server
    + echo FTP to 10.60.17.11
    FTP to 10.60.17.11
    + echo username: oraspt
    username: oraspt
    + echo pw:
    pw:
    + ftp -i -n 10.60.17.11
    ++ sqlplus -s /nolog
    + output=Connected.
    + echo 'connecting to ftp for deleting output file'
    connecting to ftp for deleting output file
    + echo FTP to 10.60.17.11
    FTP to 10.60.17.11
    + echo username: oraspt
    username: oraspt
    + echo pw:
    pw:
    + ftp -i -n 10.60.17.11
    + echo 'Deleted successfully'
    Deleted successfully

  • Scheduling a Powershell script as a batch job

    I need to run a PowerShell script as a batch job to be executed every 5 minutes on a Windows Server 2012 R2 server.
    I want to use a scheduled task.
    I read on the web different ways to solve the problem but I was unable to make them work.
    What is the simplest way to run a PowerShell file as a scheduled job?
    Regards
    Mario

    Hi Mario,
    The quickest method is to write your script and save it on the server. Then create a new scheduled task like so:
    Actions -
    Start a program
    Program/script : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Add arguments : -File C:\path\to\script.ps1
    That's all you need to do for simple scripts (make sure your execution policy is set right too).
    Don't retire TechNet! -
    (Don't give up yet - 12,700+ strong and growing)

  • 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

  • Calling PERL script from scheduler

    Hello All,
    I am trying to call PERL script from dbms_scheduler which makes the database connection using DBD module to read some values to perform the operation. My scheduler job kept failing with the following error:
    ORA-27369: job of type EXECUTABLE failed with exit code: No such file or directory
    STANDARD_ERROR="install_driver(Oracle) failed: Can't load '/usr/lib/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.10.1: cannot open shared object file
    It can't open libclntsh.so.10.1 file when I run the job, I guess because in job session, it creates a new shell and doesn't inherit the .profile and none of the environmental variables get set. When I run the PERL script manually it works because of all the env variables, so I put all those variables from my .profile into PERL script itself using ENV function but it still doesn't work, failed with very same error. And yes I do set LD_LIBRARY_PATH to point to $ORACLE_HOME/lib directory. Moreover, if I run the PERL script manually from a shell where I dont inherit .profile, it fails with very same error, so it is related to the environment issues but I have no idea how to fix it. I read somewhere the setting those env variable in PERL script itself doesn't help because by the time PERL get executed all the compilers are already initialized and and they don't use those environement variables anymore then. So the question is how to make it work?
    I would really appreciate if someone can help me fixing this, it's gonna change my life here :)
    DB Version: 10.2.0.2 (also tested on 11R2, same problem)
    OS: SUSE Linux 64 bit
    And here is my libclntsh file in $ORACLE_HOME/lib
    $ls -l libclnt*
    lrwxrwxrwx 1 epsora epsdba 52 2009-09-15 13:39 libclntsh.so -> /u01/app/epsora/product/10.2.0/lib/libclntsh.so.10.1
    -rwxr-xr-- 1 epsora epsdba 20274415 2009-09-15 13:39 libclntsh.so.10.1
    -rw-r----- 1 epsora epsdba 36840968 2009-09-15 13:38 libclntst10.a
    Please let me know if you need more information about this setup.
    Thanks
    Daljit Singh
    Edited by: Daljit on Jul 6, 2010 10:06 AM

    Nothing in your post indicates that you created a directory object and granted privileges.
    http://www.morganslibrary.org/reference/directories.html
    did you?

  • Calling javaFX script from Java program

    I am trying to call JavaFX script from a simple Java program. code as follows:
    import java.io.*;
    import javax.script.ScriptEngine;
    import javax.script.ScriptEngineManager;
    public class My{
    public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByExtension("fx");
    try {  
    InputStreamReader reader = new InputStreamReader(My.class.getResourceAsStream("first.fx"));
    engine.eval(reader);
    reader.close();
    } catch (Exception e) {
    e.printStackTrace();
    my first.fx file code is here:
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import javafx.scene.text.Text;
    import javafx.scene.text.Font;
    import javafx.scene.text.TextAlignment;
    Stage {
    title: "My First JavaFX Sphere"
    scene: Scene {
    width: 250
    height: 250
    content: [
    Text {
    font: Font { size: 24 }
    x: 20, y: 90
    textAlignment: TextAlignment.CENTER
    content:"Welcome to \nJavaFX World"
    } //Text
    ] // content
    } // Scene
    } // Stage
    I am not able to run My.java. runtime error as follows:
    java.lang.NullpointerException
    Kindly correct me, where I am wrong

    I am able to call .fx file from Java. Thank you all for helping me to resolve this problem
    Regards,
    Ritu

  • Calling a script from rman

    Hi Experts,
    Is it possible to call a script from rman.
    database 9i
    Recovery catalog 10g.
    Ex :
    connect target test/test@TEST;
    connect catalog rman/rman@RMAN
    @backup (where backup is a datafile backup script on unix)
    I dont know if there is any other way of calling a script within an rman script.
    Any ideas....
    Thanks in Advance
    MB

    OK,
    I understood. The file .SQL is for SQL statements only, not for RMAN commands.
    You can create a shell script on Unix named your_backup.sh on /home/oracle directory,
    for example.
    This shell script file (bellow) is with your rman code, like this:
    #!/bin/sh
    # Name: A name for the shell script
    # Author: You
    # Description: Executes backup for Sunday using the RMAN
    # Updates:
    export ORACLE_HOME=$1
    export ORACLE_SID=$2
    export LOG_DIR=$3
    # Variables:
    SCRIPT="your_backup"
    data_log=`date '+%y-%m-%d_%H:%M:%S'`
    logfile=${LOG_DIR}/${SCRIPT}-${data_log}.log
    # Execution of script backup of rman:
    $ORACLE_HOME/bin/rman <<EOF > $logfile
    connect target rman/rman
    connect catalog rman/rman
    run{
    set controlfile autobackup format for device type disk to '%F';
    allocate channel d1 type disk format '/tmp/SID/df_s%s_p%p_t%t';
    restore controlfile to '/PATH/ctl/cntrlTEMP.dbf' from autobackup;
    replicate controlfile from '/PATH/ctl/cntrlTEMP.dbf';
    sql "alter database mount";
    release channel d1;
    EOF
    exitto you execute this script, you can do this on the unix:
    [oracle@server oracle]$ /home/oracle/your_backup.sh /u01/app/oracle/product/9.2.0.1.0 devdb /home/oracleThis script is going to generate log file to you analyze.
    []´s

Maybe you are looking for