Running executable in batch file as administrator when UAC is high

Hi Team,
I have a requirement of running executable in batch file by passing the current windows login username as parameters. Below is the content of my batch file:
cmd /c start setup.exe http://testsite:7001/mobile  %username%  %username%
But, when the UAC is set high in windows 7 machine, this executable is not running properly, and giving me warnings. And, if I am running the same start command after opening command prompt as administrator, then executable is running smoothly.
So, is there any way I can run the executable as administrator by giving some options in batch file, when UAC is high?
I tried runas option, but its prompting for admin password, which we can't provide as users will not know.
Do we have some option in batch file as 'Run As Administrator' right click option, where it doesn't prompt for password but run the file with admin privilege?
Thanks,
Tina Soni

Hi,
When using Runas command, you can add a switch option /savecred
/savecred will make it ask for admin password on the first run only, after that it should be saved
Yolanda Zhu
TechNet Community Support

Similar Messages

  • Executing batch file as administrator changes working directory

    hey guys,
    I already posted this question on the msdn-forums and they sent me here. I hope, you can help me.
    My situation: I have a java program which I compile with exe4j. exe4j adds some nice features so I can install the program as a service with the command "myexe.exe /install"
    I put that command in a batch file (more user friendly).
    The problem: Only administrators can install services (in Win 7). But if I run the batch-file as administrator, the working directory changes to the system32-directory and I get an "command not found"-error.
    The question: How can I solve this? The only solution I know at the moment is setting a environment variable at installation time that points to the install-location. Is there another way?
    Thx for your help in advance

    With runas you in fact logon to another seesion. So cmd is started with his own starting directory (being where it is located, system32).
    I would recommend never to rely on the working dir for a batch file or script, but to always include the full path to the needed command/executables. If needed you can use environment variables to get the pathes of user-customised folders (for example the %usersprofile% variable).
    Using .lnk files (normal shortcuts) you can specify the working dir to start in if you would really need that functionality.
    MCSA/MCTS/MCP

  • Urgent : Executing a batch file in a JSP file

    Hi;
    I need help in executing a batch file within a jsp page, ive the following codes but it doesnt seem to work...
    These are the codes :
    <%@ page import="java.util.*,java.io.*,java.net.*" %>
    <%@ page import="java.sql.*" %>
    <%
    Process p = Runtime.getRuntime().exec("Ratio.bat");
    p.waitFor();
    int i = p.exitValue();
    %>
    The following is the error :
    ype Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.io.IOException: CreateProcess: Ratio.bat error=2
    java.lang.Win32Process.create(Native Method)
    java.lang.Win32Process.<init>(Win32Process.java:63)
    java.lang.Runtime.execInternal(Native Method)
    java.lang.Runtime.exec(Runtime.java:550)
    java.lang.Runtime.exec(Runtime.java:416)
    java.lang.Runtime.exec(Runtime.java:358)
    java.lang.Runtime.exec(Runtime.java:322)
    org.apache.jsp.invRatio_jsp._jspService(invRatio_jsp.java:52)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Anyone can tell me why it doesnt work ?... Thanks

    Aside from removing the "start" or adding the title ...
    Does your batfile really say "SET PATH=%PATH%;%JAVA_HMOE%\bin"? If so, I rather expect you meant to say "JAVA_HOME" and not "JAVA_HMOE".
    Also, I'd be cautious about those relative paths that you're passing in to the Java program. Of course I don't know what you're doing with those in the program, but if you try to just pass those paths to a File or InputStream constructor, they're going to be relative to the current directory. And if you execute a batfile using cmd from an exec that's within a JSP ... I'm not sure what your current directory would be when the bat runs. Maybe you've checked this out and it's the right place, but if not, perhaps you have a misconception there.

  • How to execute java batch file in JSP

    Kindly give a solution. I want execute a batch file which gives a preview window ,. I want call that batch file in my jsp, .I am using Tomcat 5.5, I have tried that using a Process object and Runtime.getRuntime().exec(path) , where path is location of my batch file. As a java class i could execute the batch file, but when i import the method in JSP nothing is happening (even no jsp error).
    Is it possible to execute the batch file in JSP?
    Can any one help me?

    itsdhanasaraa wrote:
    But as this a web application ... By using Runtime i'm getting some probs ..
    Let me guess, you want your web application to run a program on the client and to your surprise that's not working?
    Ain't gonna happen.
    its taking more time to execute .... that's y is there any other option to execute .exe file other than Runtime.getRuntime().exec("filename");Write proper English and you may be taken more seriously.
    1) it's not "taking more time to execute", whatever that's supposed to mean.
    2) there's no other way to execute something. Not that you should every use even that way anyway
    3) whenever you start thinking of executing external programs from Java, start thinking of not using Java in the first place.

  • Executing a batch file (.bat) on a different PC

    Hi,
    Is it possible to execute a batch file on a different pc.
    Look at the following piece of code.
    import java.io.*;
    public class StartRemoteCmd {
         public static void main(String[] args) throws IOException
              System.out.println("Starting remote Command");
    Process p = Runtime.getRuntime().exec("\\\\Itop001\\Tomcat\\commons-net-1.0.0\\setclasspath.bat");
              if (p==null){
              System.out.println("Process is null");
              System.exit(1);
              System.out.println("Started remote Command");
    The machine ITOP001 has this setclasspath.bat...which sets classpath and has a java CustPgm.
    I want to start this CustPgm program on ITOp001 from my machine.
    Is it possible..? Am I doing some mistake in the code..pls suggest.
    Thanks guys

    Can't really add much to the online help:
    The AT command schedules commands and programs to run on a computer at
    a specified time and date. The Schedule service must be running to use
    the AT command.
    AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
    AT [\\computername] time [/INTERACTIVE]
        [ /EVERY:date[,...] | /NEXT:date[,...]] "command"
    \\computername     Specifies a remote computer. Commands are scheduled on the
                       local computer if this parameter is omitted.
    id                 Is an identification number assigned to a scheduled
                       command.
    /delete            Cancels a scheduled command. If id is omitted, all the
                       scheduled commands on the computer are canceled.
    /yes               Used with cancel all jobs command when no further
                       confirmation is desired.
    time               Specifies the time when command is to run.
    /interactive       Allows the job to interact with the desktop of the user
                       who is logged on at the time the job runs.
    /every:date[,...]  Runs the command on each specified day(s) of the week or
                       month. If date is omitted, the current day of the month
                       is assumed.
    /next:date[,...]   Runs the specified command on the next occurrence of the
                       day (for example, next Thursday).  If date is omitted, the
                       current day of the month is assumed.
    "command"          Is the Windows NT command, or batch program to be run.

  • Java.io.filepermission error while executing a batch file from java prog

    Hi,
    i want run a java program which executes a batch file, both are in a jar file. while am trying this using webstart it shows error:access denied java.io.filepermission <<ALL FILES>>execute. why this happens how to rectify this.
    By
    Vinod

    Clearly, it would be a security vulnerability to be able to do such a thing from the web w/o user granting trust to the application.
    Java Web Start applications run in the Java SE secure sandbox unless they have been granted all-permissions by the user:
    1.) sign all jar files.
    2.) add <security><all-permissions/></security> to the jnlp file.
    The user would then be prompted to grant trust to the applications.
    /Andy

  • How to execute a batch file on different remote server using TFS Build

    I have a build server and have 2 web servers. I am deploying using TFS Builds. Now, I have a requirement to execute a batch file which is kept on these 2 web servers. i.e. C:\MyBatch\CreateMe.bat
    After my build is successful, I need to execute this batch from the build server.
    Note, I cannot make any shared folder.

    Hi Sameer, 
    Thanks for your post.
    What’s the version of your TFS?
    How do you deploy solution using TFS Build, run MSBuild deploy command or using Release Management?
    That C:\MyBatch\CreateMe.bat file stay on your two web server machines separately? 
    If you want execute this bat file on your two web server machines separately using build process template, you need configure your web server machine as build agent, then add the InvokeProcess activity in build process template to run the bat file on build
    agent machine after build, please refer to Hari’s answer reply in this post:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/b8bcb19f-1296-441c-8356-e701b949445a/tfs-2010-how-to-execute-a-batch-file-after-build?forum=tfsbuild.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Execute a Batch file

    Hi,
    I need help in writing a method that execute a batch file which is in a different directory from my java application and show the result(after executing the batch file) in the java application. Can anyone tell me how to do that?
    Thanks,
    Khim

    Hi,
    Below are the codes in my application. Using these codes, the batch file can execute but I cannot get the output of the result from the batch file. (if I run the batch file from cmd, it shows: "Error: 0 : Cannot authenicate the information after all the attempts")
    String cmd = new String();
    Runtime rt = Runtime.getRuntime();
    System.out.println("Executing VocaliD check..");
    cmd="C:\\JNI\\Elva\\debug\\plug.bat";
    Runtime rn = Runtime.getRuntime();
    Process pc1 = rn.exec(cmd);
    String result=new String(pc1.getInputStream().toString ());
    System.out.println(result);
    The result I got is below:
    Executing VocaliD check..
    java.io.BufferedInputStream@3179c3
    Thanks,
    Khim

  • Executing a batch file from a jsp

    hi,
    i have a jsp running on tomcat 3.1
    now upon submit, i want a batch file to execute .
    how do i do that..( i mean what will be the correct syntax for this ) say the batch file exists in /tomcat/batch/ do i have to give the abosolute path for this or a relative path will do.. ( if the relative path works then, do i have to mention a context for the batch directory in server.xml..
    pls help.. this is urgent
    thanx

    Hi truptip,
    This is the code to execute a batch file or any system command,
    Process p = Runtime.getRuntime().exec("shell command you want to exit");
    p.waitFor();
    In regards to whether you should access it using a relative location, the answer is no. Execution of a batch file is not part of the the webserver, so the webserver's concept of the current directory for the client does not apply.
    On a side note I wanted to say that I would highly recommend that you don't put the batch files anywhere on the webserver that is accessible to the user, not that the webserver would execute the code, but it may let out some information that you don't want available.
    Hope this is of some help,
    James

  • Executing an Executable or Batch file in DOS/Unix Env. - Urgent Urgent.

    Hi there
    We are currently using Oracle 8i with 9ias as the Application Server. I have a requirement where I should be executing a batch file or a executable on the local client system (from where the browser runs).
    I have downloaded a script from Oracle Metalink which creates a class file. This class file enables me to create a executable or a batch file on to the local client machine. But does not allow me to execute it.
    Can anyone kindly send me a script which enables me to execute a .exe file on the client machine.
    Many thanks in advance.
    Regards
    Pavan Chelvaraj

    I have the below program. I need to embedd, the script for executing a file. Please help.
    Regards
    Pavan Chelvaraj
    import oracle.forms.ui.*;
    import oracle.forms.properties.ID;
    import oracle.ewt.lwAWT.lwText.*;
    import java.awt.*;
    import java.io.*;
    public class TextPJC extends VTextArea {
    private static final ID READFILE = ID.registerProperty("readfile");
    private static final ID WRITEFILE = ID.registerProperty("writefile");
    private String filename=null;
    public TextPJC() {
    super();
    public boolean setProperty(ID pid, Object value)
    if(pid ==READFILE) {
    try {
    File inputFile = new File((String)value);
    FileReader in = new FileReader(inputFile);
    char c[] = new char[(int)inputFile.length()];
    char c1[]= new char[(int)inputFile.length()];
    in.read(c);
    int j=0;
    for (int i=0;i<inputFile.length();i++)
    if((int)c==13);
    else
    c1[j++]=c[i];
    String str = String.copyValueOf(c1,0,j);
    this.setContent(new LWTextArea(str));
    in.close();
    catch(Exception e) {System.out.println("Error in PJC " );e.printStackTrace();}
    return true;
    else if(pid==WRITEFILE) {
    try {
    File inputFile = new File((String)value);
    FileWriter in = new FileWriter(inputFile);
    LWTextArea lw = (LWTextArea)(this.getContent());
    String text1 = lw.getText();
    int length1 = text1.length();
    char c[] = new char[(int)length1];
    char c1[]= new char[(int)length1*2];
    text1.getChars(0,length1,c,0);
    int j=0;
    String s1= System.getProperty("line.separator");
    for(int i=0;i<length1;i++)
    if ((int)c[i]==10)
    s1.getChars(0,s1.length(),c1,j);
    j=j+s1.length();
    else
    c1[j++]=c[i];
    in.write(c1,0,j);
    in.flush();
    in.close();
    catch(Exception e) {System.out.println("Error " );e.printStackTrace();}
    return true;
    else
    return super.setProperty(pid,value);

  • How to run the emca batch file

    Hello,
    I would just like to know how to run the emca batch file for a single test database on my PC with SID = ORCL1.
    Hope someone can help me.
    Thanks!

    Hi
    If you mean running EMCA as batch file and test something.
    I think the best way is to write OS level script to handle this

  • External task -  run batch file as administrator

    Hi,
    My name is Sid. I am working on developing an EDQ project to parse a collection of log files.
    I have run into a roadblock on the first step!
    My EDQ server is on a Windows Server 2008 platform.
    I am calling a batch file that copies these log files between two locations.
    The batch file copies the files fine when i run it as administrator from the commandarea in  EDQ server, but it does not work when called from the External Tasks in EDQ.
    I tried using the runas user:/Administrator in the batch file but that does not work either.
    Would greatly appreciate any pointers in this regard.
    Thank You,
    Sid

    With runas you in fact logon to another seesion. So cmd is started with his own starting directory (being where it is located, system32).
    I would recommend never to rely on the working dir for a batch file or script, but to always include the full path to the needed command/executables. If needed you can use environment variables to get the pathes of user-customised folders (for example the %usersprofile% variable).
    Using .lnk files (normal shortcuts) you can specify the working dir to start in if you would really need that functionality.
    MCSA/MCTS/MCP

  • When triggering a UBE filter to run an external batch file, it doesn't work, although the rule is triggered.

    UBE filters are not running a batch file as
    an external program. The batch file is located in the postoffice spool
    directory and has the correct permissions.
    <P>
    Change the RUN command to REJECT to check that it was actually triggered.
    <P>
    <B>Background:</B>
    <P>
    Example:
    <P>
    filter.cfg is as follows:
    <P>
    :Test Channel-To "ecxpert@host\.domain\.com" RUN "test.bat"<BR>
    :sendback Channel-To "ecxpert@host\.domain\.com" COPY "pvtest1@host\.domain\.com"
    <P>
    filter.opt is as follows:
    <P>
    # To parse header fields as well as envelope fields remove the comment (#) from the following<BR>
    # line. See Help for more information<BR>
    parseheader:1
    <P>
    test.bat resides in C:\Netscape\Suitespot\MailServer\Spool and is as follows:
    <P>
    date /t >> test.txt
    <P>
    This would be 100% correct for any Unix system, with the addition of a top line
    to the script determining what shell to use. However, with NT, shell type
    definition is not part of a batch file.
    Correcting the UBE filter in filter.cfg to read as follows cures the problem:
    <P>
    :Test Channel-To "ecxpert@host\.domain\.com" RUN "cmd.exe /c test.bat"
    <BR>
    :sendback Channel-To "ecxpert@host\.domain\.com" COPY "pvtest1@host\.domain\.com"
    <P>
    The following also works:
    <P>
    :Test Channel-To "ecxpert@host\.domain\.com" RUN "cmd.exe /c date /t test.txt"<BR>
    :sendback Channel-To "ecxpert@host\.domain\.com" COPY "pvtest1@host\.domain\.com"
    <P>
    The reasoning behind this is that batch files are scripts for CMD.EXE, the
    NT Shell, and therefore cannot be executed directly. CMD.EXE has the /C
    switch to run a following command, or batch file, and exit on completion.
    <P>
    Another solution would be to write an executable program in BASIC or any
    other chosen language to perform the same functions. However, do compile it to an
    executable before trying to use it since, for example, a *.BAS file will
    run in Windows but it means nothing to Messaging Server.

    Look at the documentation of Runtime.exec()
    There are versions of that method that allow you to specify the name of an executable (the name of your batch file) and also an array of strings with environment parameters. I've never used this myself, but it should work like this (lookup the documentation!):
    Runtime.getRuntime().exec("bla.bat", new String[] { "ROOTDIR=" + rootdir });

  • Running a windows batch file on the middle teir

    Hi, I am converting a client/server Forms app to 10iAS (9.0.4). in Client Server mode, one of the forms calls a batch file that runs on the client. The same batch file must now run on the middle teir app server where iAS is installed, not the client's computer (no need for WebUtil).
    No change was made to the batch file, and it can be run with supplied params at the command prompt on the iAS server. However, when run through the web app, the batch file is failing. It is being executed, but when it hits this line:
    FOR %%F in (%1\arp*.w) do type %%F | gawk -f ARKeys.awk | gawk -f SMSar.awk
    it fails.
    Q: is there a different method to program DOS batch files wheb being called from the Forms server?

    Hi, I am converting a client/server Forms app to 10iAS (9.0.4). in Client Server mode, one of the forms calls a batch file that runs on the client. The same batch file must now run on the middle teir app server where iAS is installed, not the client's computer (no need for WebUtil).
    No change was made to the batch file, and it can be run with supplied params at the command prompt on the iAS server. However, when run through the web app, the batch file is failing. It is being executed, but when it hits this line:
    FOR %%F in (%1\arp*.w) do type %%F | gawk -f ARKeys.awk | gawk -f SMSar.awk
    it fails.
    Q: is there a different method to program DOS batch files wheb being called from the Forms server?

  • Irregular delay while running a dos batch file using a servlet class

    i used RunTime( ) class to execute a dos-batch file containing some commands like changing the directory, running an exe(executable.exe) file...etc in a servlet class. while this servlet class is invoked, the exe file(executable.exe) is run after irregular delay at different trials.
    Note: When this batch file is run in a stand alone java class, it is working fine.
    what can be the possible cause of this prob? Help me in this.

    It's ok - I've found the answer.
    I'll post it here for anyone else who is interested.
    The problem stemmed from the fact that I had to put the path to javaw.exe in quotes, as the batch file is dynamically generated from the user's environment, and then run. The user's system properties gives a path to java home using a full path name, which WinNT/Win2K doesn't like.
    The following batch file content solves it, closing the DOS box after starting javaw.exe. Before this part of my batch file, there is just some file copying that goes on for the autoupdate process.
    set PATH=%PATH%;"D:\Program Files\JavaSoft\JRE\1.3.1\bin"
    start /B javaw.exe -Dmyapp.home=C:\myapp myapp.client.MyAppClient subSys
    exit
    The parameter subSys is just a command line parameter that MyApp.java looks for, so not relevant for everyone.
    /B prevents a second DOS box from opening.
    exit simply closes the DOS box once the javaw.exe process has started.
    Too easy! Although I can't believe how difficult it was to find information about this. Hopefully it will be of benefit to others.

Maybe you are looking for