add to Runas command

  • Thread starter Thread starter Mint
  • Start date Start date
M

Mint

Guest
I tried adding some more functionality to the batch file below with no

success.

Is there a way that I can add to this batch file?



For example, color 1f and loading some macros would be great too.



Thanks.



runas.exe /user:Administrator cmd.exe
 
Below is an example batch file (incorporating the command you quoted ) I

have working on my system to add some helpful stuff to a new "cmd"

window....



*NB Make sure the batch-file is named ADMCMD.BAT and is in the system's

"path" (i.e.; in a folder included in the PATH variable, usually C:\WINDOWS

is one) and that the file containing the macros is named ADMIN.MAC and is

[also] placed in C:\WINDOWS.





ADMCMD.BAT

------------------- copy between lines -(start)------------------



@echo off

if %1]==start] goto BATCH

runas.exe /user:Administrator cmd.exe /k call admcmd.bat start

goto :EOF



:BATCH

SET DIRCMD=/A /O /P /X

PATH=%path%;C:\WINDOWS\COMMAND

DOSKEY /INSERT /MACROFILE=C:\WINDOWS\ADMIN.MAC

COLOR 0B

CLS

VER

echo.



------------------- copy between lines -(end)-------------------



The first line "@echo off" prevents the commands from being displayed

[echoed] on the screen as they are executed and the "@" prevents that

command itself from being displayed.



The next couple of lines incorporate your command to start a cmd.exe window

with ADMIN credentials and also points it back to the starting batch-file

again to run the other commands from the line labelled "BATCH". You can

use the "goto LABEL" command to jump to another part of the batch-file

beginning with a colon followed by a chosen word i.e.; :LABEL

The "goto :EOF" line is different, as you don't normally use the colon *in*

the goto command and the line-label :EOF does not exist. This special form

of the "goto" command means : "goto [E]nd [O]f [F]ile"



The SET command can be used to set an environment variable that can be

recalled in various ways and in this case is used by the DIR command to set

chosen "switches" that will be applied automatically when set in the DIRCMD

variable. You can display a list of environment variables currently set,

by typing the SET command with no parameters.



The COLOR command changes the default text color to cyan-on-black (my

personal favourite). Some doskey macros (see next item) can be set to

simply change the text color by typing such as "red", "blue" and "green".



The DOSKEY command is for a command-line editor program that allows you to

use the up / down left /right arrow keys to modify past typed commands.

This allows you to change a small part of a large command or repeat a

command often used to save time in both cases. It also points doskey to

the file: ADMIN.MAC is a file which contains doskey command-line macros, a

sample of which is reproduced below :



ADMIN.MAC

------------------- copy between lines -(start)------------------



maced=edit C:\WINDOWS\ADMIN.MAC

macm=DOSKEY /MACROS

macf=DOSKEY.EXE /MACROFILE=C:WINDOWS\ADMIN.MAC

c=cls

q=exit

red=color 0C

blue=color 09

green=color 0A

cyan=color 0B

cmdhelp=hh.exe ntcmds.chm::/ntcmds.htm



------------------- copy between lines -(end)-------------------



For a list of commands for use with the "command-line" (that is; in a

"dos-box") type the following into the "Run" box on the Start Menu :



hh.exe ntcmds.chm::/ntcmds.htm



==



Cheers, Tim Meddick, Peckham, London. :-)









"Mint" wrote in message

news:78ea8389-c926-4b19-be77-cddfb10302af@z33g2000vbb.googlegroups.com...

>I tried adding some more functionality to the batch file below with no

> success.

> Is there a way that I can add to this batch file?

>

> For example, color 1f and loading some macros would be great too.

>

> Thanks.

>

> runas.exe /user:Administrator cmd.exe
 
Back
Top