I'm not too keen on this new over the top 'run as administrator' thing in vista. I know it's for my own protection, to prevent malicious code from altering my system, but it makes batch programming a pain. I'm trying to write a couple scripts, one that will kill windows aero, and one that will start windows aero. The one that starts it works fine, here it is:

@echo off
REM ************** KILL AERO ***********
taskkill /IM Dwm.exe
echo DWM Closing main memory
timeout /T 2 /nobreak
taskkill /IM Dwm.exe
echo DWM Closed
pause

(i'm not too sure why DWM needs to be closed twice, but it does...lol)

this works no problem, kills the 33 MB memory hog like a charm
its the script that closes it that is required to be run as an administrator. most executables (.exe's and .com's) have an option in their properties to always be run as an admin, but for batch files this is grayed out for some reason. is there any way, using perhaps batch commands, to set the status to administrator while in the program? I'm not looking for a better way to get rid of aero, I know there's a few other ways. I guess it just boils down to me being too lazy to right click the batch file and choose run as admin. but i'm thinking there could be much more important uses for this knowledge, such as running scripts on startup that you don't get a chance to run as admin.

here's the code to start aero, if anyone wants to steal it go hard.
@echo off
echo Starting Aero
c:\windows\system32\dwm.exe
timeout /T 2 /nobreak
net stop "uxsms"
net start "uxsms"
echo Aero Running
pause

i know there's a runas command - but i'm not sure of its use or practicality to this situation, it seems like more of a public comp or network command than a admin status command. but i could be wrong, please help!

UPDATE.

My co-worker (another comp tech) showed me how to use runas to try and run the specific commands as an admin. The problem with this is not only that you have to enter the password each time you use the command, but it doesn't even properly execute the command! maybe im just using it wrong...but here's the code:

@echo off
echo Starting Aero
runas /laptop-pc\kyle c:\windows\system32\dwm.exe
timeout /T 2 /nobreak
runas /laptop-pc\kyle "net stop \"uxsms\""
runas /laptop-pc\kyle "net start \"uxsms\""
echo Aero Running
pause


there's no errors or anything...it seems like its really trying hard to make it work...but nothing. (the reason for the \'s is because of the quotations inside of quotations, which will give you an error without them)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.