How do I write a command in a .batch file written in NOTEPAD to run a powershell command?

How do I write a command in a .batch file written in NOTEPAD to run a powershell command?
Example:
powershell -Command "& {Update-Help;}"
would this be a correct command to put in a .batch file to update help information in powershell.
All I want to know is how to write a windows powershell command in a .batch file.
Multi-Commands
Single-Commands
Charles Wright

Hi,
You can separate multiple commands with a semicolon (;).
Don't retire TechNet! -
(Don't give up yet - 13,085+ strong and growing)

Similar Messages

  • How to allow write privileges by a process to files?

    Hi there
    In SPARC-Solaris8:
    How to allow write privileges by a process to files?
    Tks in advance,
    C�sar

    The access to files will be controlled by the owner of the files, the owner of the process trying to access the files and the permissions set on the files.
    You can use either user, group or world permissions to limit access to files by processes owned by different users.
    For example, a files with permissions of 777 (rwxrwxrwx) could be written to by every user on the system. A files with 760 (rwxrw----) could be written to by anyone who owned it, or anyone in the same group, but not have general write permissions.
    read man pages on group, chmod, etc to get an understanding of how the permissions and the owner of a process interact.

  • How can I write new objects to the existing file with already written objec

    Hi,
    I've got a problem in my app.
    Namely, my app stores data as objects written to the files. Everything is OK, when I write some data (objects of a class defined by me) to the file (by using writeObject method from ObjectOutputStream) and then I'm reading it sequencially by the corresponding readObject method (from ObjectInputStream).
    Problems start when I add new objects to the already existing file (to the end of this file). Then, when I'm trying to read newly written data, I get an exception:
    java.io.StreamCorruptedException
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    Is there any method to avoid corrupting the stream? Maybe it is a silly problem, but I really can't cope with it! How can I write new objects to the existing file with already written objects?
    If anyone of you know something about this issue, please help!
    Jai

    Here is a piece of sample codes. You can save the bytes read from the object by invoking save(byte[] b), and load the last inserted object by invoking load.
    * Created on 2004-12-23
    package com.cpic.msgbus.monitor.util.cachequeue;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.RandomAccessFile;
    * @author elgs This is a very high performance implemention of Cache.
    public class StackCache implements Cache
        protected long             seed    = 0;
        protected RandomAccessFile raf;
        protected int              count;
        protected String           cacheDeviceName;
        protected Adapter          adapter;
        protected long             pointer = 0;
        protected File             f;
        public StackCache(String name) throws IOException
            cacheDeviceName = name;
            f = new File(Const.cacheHome + name);
            raf = new RandomAccessFile(f, "rw");
            if (raf.length() == 0)
                raf.writeLong(0L);
         * Whne the cache file is getting large in size and may there be fragments,
         * we should do a shrink.
        public synchronized void shrink() throws IOException
            int BUF = 8192;
            long pointer = getPointer();
            long size = pointer + 4;
            File temp = new File(Const.cacheHome + getCacheDeviceName() + ".shrink");
            FileInputStream in = new FileInputStream(f);
            FileOutputStream out = new FileOutputStream(temp);
            byte[] buf = new byte[BUF];
            long runs = size / BUF;
            int mode = (int) size % BUF;
            for (long l = 0; l < runs; ++l)
                in.read(buf);
                out.write(buf);
            in.read(buf, 0, mode);
            out.write(buf, 0, mode);
            out.flush();
            out.close();
            in.close();
            raf.close();
            f.delete();
            temp.renameTo(f);
            raf = new RandomAccessFile(f, "rw");
        private synchronized long getPointer() throws IOException
            long l = raf.getFilePointer();
            raf.seek(0);
            long pointer = raf.readLong();
            raf.seek(l);
            return pointer < 8 ? 4 : pointer;
         * (non-Javadoc)
         * @see com.cpic.msgbus.monitor.util.cachequeue.Cache#load()
        public synchronized byte[] load() throws IOException
            pointer = getPointer();
            if (pointer < 8)
                return null;
            raf.seek(pointer);
            int length = raf.readInt();
            pointer = pointer - length - 4;
            raf.seek(0);
            raf.writeLong(pointer);
            byte[] b = new byte[length];
            raf.seek(pointer + 4);
            raf.read(b);
            --count;
            return b;
         * (non-Javadoc)
         * @see com.cpic.msgbus.monitor.util.cachequeue.Cache#save(byte[])
        public synchronized void save(byte[] b) throws IOException
            pointer = getPointer();
            int length = b.length;
            pointer += 4;
            raf.seek(pointer);
            raf.write(b);
            raf.writeInt(length);
            pointer = raf.getFilePointer() - 4;
            raf.seek(0);
            raf.writeLong(pointer);
            ++count;
         * (non-Javadoc)
         * @see com.cpic.msgbus.monitor.util.cachequeue.Cache#getCachedObjectsCount()
        public synchronized int getCachedObjectsCount()
            return count;
         * (non-Javadoc)
         * @see com.cpic.msgbus.monitor.util.cachequeue.Cache#getCacheDeviceName()
        public String getCacheDeviceName()
            return cacheDeviceName;
    }

  • How do you write an image threshold to a file

    Hi, I use IMAQ threshold to threshold an RGB image. How do I write this image to a file? Whenever I use the IMAQ Write JPG or Write PNG vI and try to view the file with the windows image viewer all I see is a black image. Does anyone know how to save a binary image?

    If you cast it to an eight bit image and save it as a BMP or JPEG does it show up correctly? If so the problem probably lies in the fact that a 16-bit image in LabVIEW is signed, while third party viewers usually assume that it is unsigned. So rather than pixel values going from -32766 to 32767, they go from 0 to 65536. There are example programs on ni.com to get around this. One is called "Mapping a 16-bit Image to an 8-bit Image," another is called "Bit Shift an IMAQ Vision 12-bit Image and Resave for External Viewer." If you search for these titles on the ni.com search bar, you should be able to find them.
    Kyle V

  • The reverse of the "findstr" command in a batch file.

    Hi.
    I hope I'm in the right place.  I am trying to run a command/batch file on a really large text file to replace all lines of text with the exception of certain lines which contain a certain word.  I know this can be done to 'delete' certain lines
    and keep the others using the "findstr" command.  What this command does is deletes all lines in a text file that contain specific words whilst keeping all other lines.
    I want to do the exact opposite to this.  I want to keep certain lines of text containing specific words whilst deleting all others.
    Does anyone know what this command might be?  Or is there a switch one can use with "findstr" command to do it?
    All help appreciate
    J

    In general you could write:
    (Get-Content.\inputfile.txt)
    -match"keyword"|Out-File.\outputfile.txt-Encodingascii
    Outputfile.txt would then contain all lines that contain "keyword".
    This should work for files with a size <4GB.
    I've just tried: The powershell.exe process didnt get more than 4GB RAM. :-)
    Walter

  • How do I stop ODI if my DOS BATCH file flags an error?

    I have a DOS batch file as the first step in my ODI package. How do I send a code to ODI to tell it that it has failed and to stop processing the rest of the package? I was told I could use an ODI variable to accomplish this but not sure how.
    Also, how do I pass a semaphore/flag an error in my DOS batch file to ODI ?
    Thanks in advance for your help.
    I tried to search for this info in John's blog: http://john-goodwin.blogspot.com/search?q=error
    but was not able to find it.
    :)

    In your package 1st step is OS Command then some other steps involved, right ?
    In that case you can have your package like this
    OS Command (first step) ---------OK--------------> 2nd step -------------------> 3rd step
    So your 2nd step will run only when the 1st step is successful, it will not start 2nd step as 1st itself has failed .
    Thanks,
    Sutirtha

  • Is there any command in windows batch file similar to the unix grep command

    Hi,
    I have a batch file which will return status of the Database to a file ex: "OPEN". Now I want to read this output file and check for the "OPEN" string from another batch file. any suggestions?. This is similar to "grep" command in unix. I want this to be done in windows batch file.
    This is my actual batch file
    rem -- Description: Check whether the Database is UP
    rem -- Usage:
    rem -- ORACLE_SID is input parameter for the file
    rem --
    rem --start of batch file
    @echo off
    set ORACLE_SID=%1
    echo connect plp/ltd1plp@%1
    echo set cmdsep on
    echo set cmdsep '"'; --"
    echo set term on
    echo spool c:/status_log.log
    echo select status from v$instance;
    echo spool off
    ) | sqlplus /nolog
    rem --end batch file
    Thanks.

    The same link from [google cache|http://209.85.229.132/search?q=cache:EJrm9tgj0a8J:www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/find.mspx+windows+find&cd=1&hl=en&ct=clnk&client=opera]. Also you can use help:
    find /?

  • How to handle trailing Null columns in a Batch file when ESB reads the file

    Dear All,
    How can I handle trailing Null columns in a batch file (csv file) that is been used by an ESB FTP adapter for batch file processing.
    Since ESB is some times taking up the whole next record as the last column data..
    Please update
    many thanks...

    If your file is not designed to be amazingly large, then you don't need to use a temporary file -- you can just read the data into memory and manipulate it there. (Like, into a Document object or something.)
    But if you are dealing with really large files, you might want to consider using a database back end instead of a text file, which is a completely different approach I know but... well, that's why databases were invented.

  • Batch file gives error "is not recognized as internal command.." after first character

    For every batch file I create, I receive the same error displaying after only running the first character in the file: ' d' is not recognized as an internal or external command, operable command or batch file.
    This occurs whether I run 'dir' cd '../..' or java.exe
    I've confirmed the path environment variable has the correct paths, cmd.exe is assigned to comspec, I'm running as admin, etc. What have I not setup correctly to run batch files. I can run these same commands directly at the command line.
    I'm running the latest version of 8.1, on Toshiba Satellite C855

    We do not have access to your computer, we cannot read your mind, and we cannot see your screen.
    Please copy and paste the exact command you are using and also copy and paste the
    exact error message.
    -- Bill Stewart [Bill_Stewart]

  • Commands within the batch file?

    Is there any way to enter commands directly into the batch file which will take effect on the java application?
    For example within the java application, there is a method "reload()" and to call that method you can type "reboot" and press enter in the batch file, is that possible? Thanks.

    I run my java application with a file (run.bat) (windows xp).
    @echo off
    title Stanyer's 503 (server)
    cd bin
    java -Xmx1024m net.stanyer.server 43594
    pauseSo basically, it runs in a cmd box.

  • How to check Oracle DB Status from Windows batch file

    Hi,
    I need a script which can be used to check the Oracle Database Status from windows command batch file.
    Thanks,
    Kishore

    Hi Virendra,
    I have followed the steps mentioned in ur reply, But couldn't get the output.
    I am getting the below error
    C:\>db_utility.bat PLPDEV
    ERROR:
    ORA-12560: TNS:protocol adapter error
    SP2-0306: Invalid option.
    Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
    where <logon> ::= <username>[<password>][@<connect_string>] | /
    SP2-0306: Invalid option.
    Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
    where <logon> ::= <username>[<password>][@<connect_string>] | /
    SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
    C:\>
    Below is my bat file
    @echo off
    set ORACLE_SID=%1
    echo sys/ltd1_plp as sysdba
    echo set cmdsep on
    echo set cmdsep '"'; --"
    echo set term on
    echo "select status from v$instance;"
    ) | sqlplus -s
    Thanks

  • How can I write some informations in a text file ?

    Hello.
    I am a beginner in java in general and in Web Dynpro Java in particular.
    I have to work in an application written by a consultant wich works no more at my office.
    Due to performances problems (slowness of the application at unpredictable instants),
    I have to write in an external file all the actions which make the users in the application.
    The problem is I don't know how to proceed.
    Somebody can help me ?
    Edited by: Serge L. on Aug 10, 2009 2:21 PM

    Hi Serge,
    You can try this as well to generate a text file.
    Use Filedownload UI element. And try following code in Webdynpro.....
    IOUtil IOUtil=new IOUtil();
    File f = new File("skill_master.txt");
    FileWriter fw = new FileWriter(f);
    fw.write(formattedStr);
    fw.close();
    InputStream template  = new FileInputStream(f);
    ByteArrayOutputStream templateSourceOutputStream = new ByteArrayOutputStream();
    IOUtil.write(template, templateSourceOutputStream);
    IWDCachedWebResource resource=WDWebResource.getWebResource(templateSourceOutputStream.toByteArray(), WDWebResourceType.getWebResourceType( "txt","text/html"));
    resource.setResourceName("User.txt");
    wdContext.currentContextElement().setVa_FileData(resource);
    Here formattedStr is the string which contain all the contents you want in the file. Here Va_FileData  attribute is of type com.sap.ide.webdynpro.uielementdefinitions.Resource.
    Map this Va_FileData attribute to the Filedownload UI. So that when u click on the FileDownload UI it will generate a txt file.
    Hope it helps you.
    Regards,
    Swati

  • How can I write waveform data to a txt file or an excel sheet?

    I want have a table that I can follow up in excel. In first column should be the timestamp (in ms or better in us), in the second column should be the value. I made an effort but it doesn´t work.
    Attachments:
    PWMReadWrite.vi ‏167 KB

    Yes, you must change block (Get Date/Time String.vi).
    You must write new subVI - this new VI convert date and time to the second [or ms or us].
    First choice is: time column will be count of second [the better ms or best us] since 12:00 a.m., January 1, 1904, Universal time[function "Get Date/Time In Seconds.vi"].
    Text file:
    3216546154,000 0.000000
    3216546154,050 0.062791
    3216546154,100 0.125333
    Second choice is: first record in TXT file will be time when test start and after will be table with time [ms or us] and value.
    Text file:
    Start time: Monday 30-th February 2005.
    0,000 0.000000
    0,050 0.062791
    0,100 0.125333
    Have a nice day.
    JCC
    P.S.: I recommend you creat header of result table to text file.
    Text file:
    time [ms] U [V]
    3216546154,000 0.000000
    3216546154,050 0.062791
    3216546154,100 0.125333

  • How do you write a class to return a file?

    So I've read http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html
    But I still do not know how to pass a file to a calling method of another class. How does the FileChooser class retrun the file. Please help.

    You mean something like this?
    import java.io.File;
    public class FileTest {
         public File getFile(String path) {
         //Example path =  "C:\\path\\to\\file.txt"
              return new File(path);
    }

  • How to hide sys and other passwords from batch files

    Hi all,
    I have my production database install on win 2003 server.The DB version is 9.2.0.4. There are some batch jobs are made to perform certain tasks like one job updates stats on daily basis run by user system,other job does online hot backups of all tablespaces as user sys.The scripts of these jobs are made on text file ,that contains user passwords.I want to hide those passwords from other people say system administrator etc who has access to production server.How can I hide these passwords.Any help from your side is appreciated.
    Best Regards,
    Majid.

    >
    I have my production database install on win 2003 server.The DB version is 9.2.0.4. There are some batch jobs are made to perform certain tasks like one job updates stats on daily basis run by user system,other job does online hot backups of all tablespaces as user sys.The scripts of these jobs are made on text file ,that contains user passwords.I want to hide those passwords from other people say system administrator etc who has access to production server.How can I hide these passwords.
    >
    If you have administrator rights on the win server, you could make use of OS authentication for sys and a user, you create externally and give him dba role. These users could then connect to the database after being logged on on the win server with
    SQL> connect / as sysdba
    SQL> connect /Look at
    http://download.oracle.com/docs/cd/E11882_01/network.112/e10574/authentication.htm#CHDBBFBF
    to see how to create an externally identified DB user.
    Kind regards
    Uwe
    http://uhesse.wordpress.com
    Edited by: Uwe Hesse on 22.01.2010 08:53

Maybe you are looking for