Tin Amaranth
Tin Amaranth

Reputation: 701

WinXP Run Command: run CMD as administrator?

In the run command dialog, type "cmd.exe". Yet, I wonder how I can run CMD as administrator in a single run command line. (P.S. I know how to do it with the mouse, so just asking a command line to achieve so). Thank you!

Upvotes: 1

Views: 887

Answers (1)

npocmaka
npocmaka

Reputation: 57322

Here how you can do it from .bat file:

@if (@X)==(@Y) @end /* JScript comment

    @echo off
    cscript //E:JScript //nologo "%~f0"  %*
    exit /b 0

@if (@X)==(@Y) @end JScript comment */

  var fs = new ActiveXObject("Scripting.FileSystemObject");
  var args=WScript.Arguments;
  var filename=args.Item(0);

  var shell=new ActiveXObject("Shell.Application");




  shell.ShellExecute(filename,"","","runas",1); 

it's just a raw script that uses ShellExecute .But I'm afraid that the UAC pop-up is unskipable. Other option is to create a shortcut that has run as Administrator check but again there will be pop-up.

Upvotes: 1

Related Questions