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





Similar help and support threads
Thread Forum
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
Make GPO changes from a batch file?
Hi I'm confused and seeking guidance. I physically manage well over 100 systems on a hardware level and very little on a software level. Yet, there are many tiny modification I've install to keep things running for the end users. The only time I actually interact with the system on a...
System Security
How to make a multible copy batch file
Below is a batch file I created to copy all the files from a program called A5V5. This batch file works to copy the files to two different drives What I want to do is if the J: Directory is not availble (This is a flash drive) that it will copy to the E:\ directory which is a second HDD and not...
Software
cant make a batch file:)
hello i need help making .bat file from .txt Windows 7 wont make it for me when i rename the thing to .bat i just see it as .bat.txt thx
General Discussion
Make shortcuts using a batch file
Is it possible in any way to make shortcuts (.lnk files) using command prompt/batch files without using any 3rd party apps? I did some googling and found this Solutions found on alt.msdos.batch - Creating Shortcuts in NT but cant make anything out of it. Appreciate any comments and help.
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 15:35.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App