Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Can you tell me what I need to make this batch file run?

22 Dec 2010   #1
blockie

 
Can you tell me what I need to make this batch file run?

I run a batch file to do image backups. It will only run if I am in the built- in-admin account. When I saw the command line option I thought I had it made. Because the batch file runs in C:\windows\system32\cmd I figured I was already at an elevated commandprompt so I merely added 'net user administrator /active:yes' as the first line in the batch file. I also got a error 5 when the net user line was used. Can you tell me what I need to make this batch file run? I have it on the scheduler to run while I am sleeping.


My System SpecsSystem Spec
.

22 Dec 2010   #2
SledgeDG

Windows 7 Ultimate x86
 
 

blockie;Error 5 = Access denied
The command prompt is not automatically elevated just because it runs in \system32\
You'd have to call CMD in the search bar, right click and run as Administrator.
ONLY if it looks like this, it's an elevated command prompt
Name:  Capture.JPG
Views: 32
Size:  30.3 KB

-DG


My System SpecsSystem Spec
22 Dec 2010   #3
Ztruker

Windows 8.1 Pro X64
 
 

Create a link on the Desktop to the batch file.
Right click on the link and select Properties.
Click on the Compatibility tab.
Check Run this program as administrator under Privilege Level.

If Run this program as administrator is greyed out, that means you have UAC disabled. Try enabling UAC then check the box, then disable UAC again.

You also don't want
net user administrator /active:yes as the first line of the batch file. That's a one time command to enable the built in Administrator account and does not need to be run more than once.
My System SpecsSystem Spec
.


22 Dec 2010   #4
SledgeDG

Windows 7 Ultimate x86
 
 

If you use the scheduler anyways why not give it elevated rights directly from there

http://www.sevenforums.com/tutorials/11949-elevated-program-shortcut-without-uac-prompt-create-3.html#post114406

-DG
My System SpecsSystem Spec
22 Dec 2010   #5
blockie

 

DG:
Remember I am running this batch file in the scheduler so it is automatic. Is there a way to add the proper words in the batch file to insure an elevated prompt?
My System SpecsSystem Spec
22 Dec 2010   #6
SledgeDG

Windows 7 Ultimate x86
 
 

Not inside the batch, blockie...you assign that in the scheduler so it gets elevated during runtime.
Check this thread (esp. #7)

Task - Create to Run a Program at Startup and Log On

Don't let yourself get confused. that method of course works also if it's not called at startup. So just take the info from the pic at #7 and modify your task accordingly.
-DG
My System SpecsSystem Spec
23 Dec 2010   #7
blockie

 

Took your advice, Sledgedog, and it worked beutifuilly. I'ver got to pay more attention to check boxes in the future. Thanks.
My System SpecsSystem Spec
23 Dec 2010   #8
SledgeDG

Windows 7 Ultimate x86
 
 

You're very welcome, blockie
Glad it worked for you
Thanks for the feedback

-DG
My System SpecsSystem Spec
Reply

 Can you tell me what I need to make this batch file run?




Thread Tools



Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 19:09.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App