Subscribe to How-To Geek

Welcome to the How-To Geek Forums

We encourage you to register on our forums and post any questions you might have. The How-To Geeks monitor this forum and will respond to your question quickly.

How-To Geek Forums » Windows Vista

Administrative command prompt from a batch file in vista

(19 posts)
  • Started 10 months ago by Smashpmk712
  • Latest reply from Smashpmk712
  • Topic Viewed 3721 times


Smashpmk712
Smashpmk712
Posts: 313

Hi,
I am trying to create a batch file for vista that uses some commands that need to be ran from the "administrative" command prompt. Does anyone know how to do this?

Thanks
Dan

Posted 10 months ago #
 
whs
whs
Posts: 6322

I am trying to get an answer from someone in Australia who should know. But they just came into work. So bear with me.

Posted 10 months ago #
 
Lighthouse
Lighthouse
Posts: 5574

Does this give you an idea?
http://www.pcstats.com/article.....#38;page=2

Posted 10 months ago #
 
Smashpmk712
Smashpmk712
Posts: 313

Lighthouse,

Let me clarify, I know how to create a batch file the problem is I want to run the cacls command in the batch to take permission of a file before the xcopy command that I really want to run. In order to do this I need to have the command prompt running the cacls command be in the administrative mode. By default it opens in the locked down mode in vista.

Dan

Posted 10 months ago #
 
jd2066
Posts: 3205

You could just right click on the batch file and select run as Administrator.

Posted 10 months ago #
 
Smashpmk712
Smashpmk712
Posts: 313

I have tried this but for some reason it does not run the command prompt as admin. If I could set cmd.exe to "always run as administrator" I think it would work but the option is greyed out in properties -> advanced.

Posted 10 months ago #
 
jd2066
Posts: 3205

When you do that do you get a prompt to elevate?

Posted 10 months ago #
 
Smashpmk712
Smashpmk712
Posts: 313

When I go to the properties for cmd.exe I have to elevate. I believe that since it is a system file I cannot set the "always run as administrator". I think tha M$ thought that would be a security risk.

Posted 10 months ago #
 
jd2066
Posts: 3205

I mean when you "right click on the batch file and select run as Administrator" do you get a prompt to elevate?
Also having cmd.exe always run as Administrator would be a security risk as then any process could just the command "cmd.exe badstuff.bat" and it would run elevated.

Posted 10 months ago #
 
whs
whs
Posts: 6322

Here is the answer from my "Australian connection": I myself cannot add much logic:
If you cannot change the privilege of current console to ā€œadministrativeā€? using commands, it cannot be achieved.

Posted 10 months ago #
 
Lighthouse
Lighthouse
Posts: 5574

I ran the cacls command, and MS said the command is now deprecated and to use Icacls instead. This seems to be able to be run with priviledges

Posted 10 months ago #
 
Smashpmk712
Smashpmk712
Posts: 313

Okay,
So I was not paying attention properly. When I run the batch file as administrator it goes to the Administrator command prompt. Now my issue is that the command is showing in the command prompt window above the "microsoft windows version .....". does this mean that the command is being run before the command prompt is all the way started? I think this is why I thought the batch file was not working.
Thank you for all your help you guys.
Dan

Posted 10 months ago #
 
Smashpmk712
Smashpmk712
Posts: 313

Okay,
I have resolved the issue. It was my script. I had a few errors in it.... What a suprise! Thank you all for helped with this issue.

Posted 10 months ago #
 
Lighthouse
Lighthouse
Posts: 5574

Do you need cmd for user input purposes?

Posted 10 months ago #
 
Smashpmk712
Smashpmk712
Posts: 313

I don't really understand the question. But generaly none of my users ever go to the cmd prompt.

Posted 10 months ago #
 
Lighthouse
Lighthouse
Posts: 5574

No, within the batch file, is there a reason you would need a command prompt (ie to input filename, address, date, disk or whatever)?

Posted 10 months ago #
 
Smashpmk712
Smashpmk712
Posts: 313

no, no reason at all. The text of the working batch file is:

Rem You need to run this batch file as administrator or else the icacls command will not work in vista
icacls c:\users\setup\appdata\roaming\microsoft\templates /grant everyone:(F)
xcopy c:\users\%username%\appdata\roaming\microsoft\templates\wfx*.* c:\users\setup\appdata\roaming\microsoft\templates

Do you have any suggestions?

Posted 10 months ago #
 
jd2066
Posts: 3205

Why do you need the icacls command? Running as Administrator should give enough privilege to copy the files.
Also where does the C:\Users\setup folder come from? That isn't a standard Vista folder.

Posted 10 months ago #
 
Smashpmk712
Smashpmk712
Posts: 313

The logged in user is a domain user and the setup folder came from when I setup the machine initially. it is a local user. I had to make the local user generic because I syspreped and used imagex to deploy the image across multiple PC's. for some reason I have to take over rights to the folder first.... stupid vista security!

Posted 10 months ago #
 

RSS feed for this topic

Reply

You must log in to post.

Sponsored Links
Getting Started
About How-To Geek
What Is That Process?
svchost.exe
jusched.exe
dwm.exe
ctfmon.exe
wmpnetwk.exe
wmpnscfg.exe
rundll32.exe
wfcrun32.exe
Ipoint.exe
Itype.exe
Wfica32.exe
Mobsync.exe
Cmd.exe
Dpupdchk.exe

Copyright © 2006-2008 HowToGeek.com. All Rights Reserved.