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

 
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

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

Windows 8 Core 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

Windows 7 Ultimate x86
 
 

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

Elevated Program Shortcut without UAC Prompt - Create

-DG
My System SpecsSystem Spec
22 Dec 2010   #5

 

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

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

 

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

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



Similar help and support threads for2: Can you tell me what I need to make this batch file run?
Thread Forum
Solved How to run a batch file at logoff & some batch scripting help please Backup and Restore
Solved Batch File that grabs file names from folder to insert into batch file General Discussion
Make GPO changes from a batch file? System Security
How to make a multible copy batch file Software
How to create a batch file that will move files based on the file type General Discussion
cant make a batch file:) General Discussion
Make shortcuts using a batch file General Discussion

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 07:03 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33