It is currently Sun May 26, 2013 1:38 am



Register for Windows Forums


New posts Register

Register for Windows Forums now to gain access to: post messages, download free books, competitions for great prizes, and get to know others. Members also see NO ADVERTS. Join today!




 Page 1 of 4 [ 34 posts ]  Go to page 1, 2, 3, 4  Next
Message Author
 Post subject: Start batch file as administrator?  Topic is solved
New postPosted: Wed Oct 05, 2011 6:56 pm 

I'm writing a(nother) script that when an image is dropped onto, it sets said image as the login screen background for Windows 7.
When UAC is off/ in Admin account, the image (which is defined as %1 in the batch file) is copied to system32 and some reg values are changed. When i start as a regular user or on a machine with UAC on, i get access denied messages (obviously), there doesn't seem to be anyway to elevate the script. Any ideas out there guys?

Example:

@echo off
copy /y %1 %windir%\system32\blah.jpg
regedit.exe blah blah


TIA :D



_________________
Image
Years of membershipYears of membershipYears of membershipYears of membership
User avatar
Site Admin
Site Admin
Windows Guru²
Windows Guru²

Joined: Sat Jun 07, 2008 9:08 am
Posts: 3186
Thanks given: 375 times
Thanks received: 441 times
Location: 0x7C00
OS: 8 RT
 Profile E-mail  
 
Offline
 
 Post subject: Re: Start batch file as administrator?
New postPosted: Thu Oct 06, 2011 12:51 am 

Try Right Click 'Run as Admin" LOL


Edit : I think you are trying to something like changing 7's Start up wall from .bat file ? Am i Right ?



_________________
Image
Years of membershipYears of membership
User avatar
Contributor
Contributor
Windows Guru
Windows Guru

Joined: Sat Aug 21, 2010 2:08 pm
Posts: 1499
Thanks given: 121 times
Thanks received: 261 times
Location: UVAIS-PC
OS: 7 Ultimate
 Profile E-mail  
 
Offline
 
 Post subject: Re: Start batch file as administrator?
New postPosted: Thu Oct 06, 2011 3:21 pm 

UVAIS wrote:
I think you are trying to something like changing 7's Start up wall from .bat file ? Am i Right ?


Yes. As per my initial post i am trying to change the login screen.

UVAIS wrote:
Try Right Click 'Run as Admin" LOL


Thanks for the suggestion. That'd work if there was no argument (ie the image file).



_________________
Image
Years of membershipYears of membershipYears of membershipYears of membership
User avatar
Site Admin
Site Admin
Windows Guru²
Windows Guru²

Joined: Sat Jun 07, 2008 9:08 am
Posts: 3186
Thanks given: 375 times
Thanks received: 441 times
Location: 0x7C00
OS: 8 RT
 Profile E-mail  
 
Offline
 
 Post subject: Re: Start batch file as administrator?
New postPosted: Thu Oct 06, 2011 5:12 pm 

Well this sort of stuff is beyond me but I was kinda wondering about what Uvais said..... does your admin username not need to added in the batch file?

If I am talking mince just tell me LOL



_________________
Image
Years of membershipYears of membership
User avatar
Top Content Contributor
Top Content Contributor

Joined: Mon Nov 15, 2010 7:20 pm
Posts: 565
Thanks given: 47 times
Thanks received: 132 times
Location: UK
OS: 8 RT
 Profile E-mail  
 
Offline
 
 Post subject: Re: Start batch file as administrator?
New postPosted: Thu Oct 06, 2011 6:33 pm 

Right clicking the batch file and running as admin or making a shortcut and setting it to always run as admin will work so long as the batch file is run directly (double clicked), if we invoke the batch file via an image being dropped onto it we have no way (yet) to elevate so both methods are useless in this case.

You could use the runas /user:administrator but that means that the built-in hidden Admin account has to have a password set and is enabled. Also if this is done, i have to invoke another command prompt window as the runas command requires a program to run (ie runas /user:administrator notepad.exe) so we have ourselves a loop.



_________________
Image
Years of membershipYears of membershipYears of membershipYears of membership
User avatar
Site Admin
Site Admin
Windows Guru²
Windows Guru²

Joined: Sat Jun 07, 2008 9:08 am
Posts: 3186
Thanks given: 375 times
Thanks received: 441 times
Location: 0x7C00
OS: 8 RT
 Profile E-mail  
 
Offline
 
 Post subject: Re: Start batch file as administrator?
New postPosted: Thu Oct 06, 2011 6:41 pm 
For this post the author Makcalable has received gratitude : Stu

Well if you wanted to post this on my forum as there are many guys over there deal in all this sort of stuff and may be able to shed some light on it for you.

either way no harm done ;-)



_________________
Image
Years of membershipYears of membership
User avatar
Top Content Contributor
Top Content Contributor

Joined: Mon Nov 15, 2010 7:20 pm
Posts: 565
Thanks given: 47 times
Thanks received: 132 times
Location: UK
OS: 8 RT
 Profile E-mail  
 
Offline
 
 Post subject: Re: Start batch file as administrator?
New postPosted: Thu Oct 06, 2011 6:43 pm 

Makcalable wrote:
Well if you wanted to post this on my forum as there are many guys over there deal in all this sort of stuff and may be able to shed some light on it for you.

either way no harm done ;-)


I don't have an account to post. You could link back to this post if you like?
I was literally just looking through your programming forum!!!



_________________
Image
Years of membershipYears of membershipYears of membershipYears of membership
User avatar
Site Admin
Site Admin
Windows Guru²
Windows Guru²

Joined: Sat Jun 07, 2008 9:08 am
Posts: 3186
Thanks given: 375 times
Thanks received: 441 times
Location: 0x7C00
OS: 8 RT
 Profile E-mail  
 
Offline
 
 Post subject: Re: Start batch file as administrator?
New postPosted: Thu Oct 06, 2011 6:53 pm 
For this post the author Makcalable has received gratitude : Stu

Ok I have been told that you cannot do this using DOS you will need to use Visual Basic instead....

I will repost the question over there for you and see what comes back



_________________
Image
Years of membershipYears of membership
User avatar
Top Content Contributor
Top Content Contributor

Joined: Mon Nov 15, 2010 7:20 pm
Posts: 565
Thanks given: 47 times
Thanks received: 132 times
Location: UK
OS: 8 RT
 Profile E-mail  
 
Offline
 
 Post subject: Re: Start batch file as administrator?
New postPosted: Thu Oct 06, 2011 6:57 pm 

It can be done without Visual Basic, whoever told you that is telling porky pies! :lol: + the fact i don't know VB! (neither am i using DOS)

Seen the post over on your, thanks for that ;)



_________________
Image
Years of membershipYears of membershipYears of membershipYears of membership
User avatar
Site Admin
Site Admin
Windows Guru²
Windows Guru²

Joined: Sat Jun 07, 2008 9:08 am
Posts: 3186
Thanks given: 375 times
Thanks received: 441 times
Location: 0x7C00
OS: 8 RT
 Profile E-mail  
 
Offline
 
 Post subject: Re: Start batch file as administrator?
New postPosted: Thu Oct 06, 2011 7:21 pm 

LOL sure thing, I am sure it will attract plenty of attention over the next couple of days and we have a good bunch of young guys who are well into this type of stuff so fingers crossed.



_________________
Image
Years of membershipYears of membership
User avatar
Top Content Contributor
Top Content Contributor

Joined: Mon Nov 15, 2010 7:20 pm
Posts: 565
Thanks given: 47 times
Thanks received: 132 times
Location: UK
OS: 8 RT
 Profile E-mail  
 
Offline
Display posts from previous:  Sort by  
 Page 1 of 4 [ 34 posts ]  Go to page 1, 2, 3, 4  Next


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

cron