Continue batch after UAC disable

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Continue batch after UAC disable

#31 Post by Ed Dyreen » 18 Jul 2012 15:56

'
Here is that 'runAs.VBS' I was talking about previously, that way you can automate your batch
so you won't have to type your password yet pass it as a parameter.
http://www.jdhitsolutions.com/resources/scripts/vbrunas.txt
Providing passwords with scripts is a security risk !

Code: Select all

>REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /t "REG_DWORD" /d "0" /f 1>nul
ERROR: Access is denied.
Once the script has administrator privileges, you should not get an access denied error as you stated previously.

gymiv
Posts: 38
Joined: 10 Jul 2012 13:47

Re: Continue batch after UAC disable

#32 Post by gymiv » 19 Jul 2012 08:01

when i run your script, by itself, i get this message. i just copied it to a new txt file and named it then double clicked on it. What am i missing.

?Help?

Usage: cscript|wscript vbrunas.vbs Username Password Command
You should use the full path where necessary and put long file names or commands with parameters in quotes
For example:
Cscript vbrunas.vbs jdhitsolutions\jhicks luckydog e:\scripts\admin.vbs
cscript vbrunas.vbs 1stParameter 2ndParameter
cscript vbrunas.vbs /?-? will display this message

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: Continue batch after UAC disable

#33 Post by Squashman » 19 Jul 2012 08:03

gymiv wrote:when i run your script, by itself, i get this message. i just copied it to a new txt file and named it then double clicked on it. What am i missing.

?Help?

Usage: cscript|wscript vbrunas.vbs Username Password Command
You should use the full path where necessary and put long file names or commands with parameters in quotes
For example:
Cscript vbrunas.vbs jdhitsolutions\jhicks luckydog e:\scripts\admin.vbs
cscript vbrunas.vbs 1stParameter 2ndParameter
cscript vbrunas.vbs /?-? will display this message


It is telling you exactly how to use it. The script needs parameters. You are trying to run a program with elevated privileges so you need to tell it what program to run elevated and the credentials to run it elevated.

gymiv
Posts: 38
Joined: 10 Jul 2012 13:47

Re: Continue batch after UAC disable

#34 Post by gymiv » 19 Jul 2012 08:37

Thats what i figured but what i can't figure out is where in the script i need to put this info. I am not great with vbs scripting but i do not see anywhere to put that info. Do you?

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: Continue batch after UAC disable

#35 Post by Squashman » 19 Jul 2012 08:42

gymiv wrote:Thats what i figured but what i can't figure out is where in the script i need to put this info. I am not great with vbs scripting but i do not see anywhere to put that info. Do you?


You don't put it in the script. You execute the vbrunas.vbs script like it is showing you.

Code: Select all

Cscript vbrunas.vbs Squashman Password "e:\scripts\script I wan to run elevated.bat"

gymiv
Posts: 38
Joined: 10 Jul 2012 13:47

Re: Continue batch after UAC disable

#36 Post by gymiv » 19 Jul 2012 09:43

I put that in my batch and it is coming up with an input error. Here is the line i put in the batch the script is on my desktop.
Microsoft (R) Windows Script Host Version 5.8. I have tried it without the computername in the login also, same results.
Copyright (C) Microsoft Corporation. All rights reserved.

cscript vbrunas.vbs %computername%\jim password123 "C:\Users\p1tech\Desktop"

Input Error: Can not find script file "C:\Windows\system32\vbrunas.vbs".

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: Continue batch after UAC disable

#37 Post by Squashman » 19 Jul 2012 09:47

gymiv wrote:I put that in my batch and it is coming up with an input error. Here is the line i put in the batch the script is on my desktop.
Microsoft (R) Windows Script Host Version 5.8. I have tried it without the computername in the login also, same results.
Copyright (C) Microsoft Corporation. All rights reserved.

cscript vbrunas.vbs %computername%\jim password123 "C:\Users\p1tech\Desktop"

Input Error: Can not find script file "C:\Windows\system32\vbrunas.vbs".


You are not telling it what script you want to run elevated. What don't you understand from my example and ED's documentation?

gymiv
Posts: 38
Joined: 10 Jul 2012 13:47

Re: Continue batch after UAC disable

#38 Post by gymiv » 19 Jul 2012 11:07

Your right i am an idiot. I was screwing up the syntax.
I put this in my bat file and ran it. It popped up a dos window and stopped after running the script. Brought up a second window asking for a password. After that it ran the bat file with creds given to it, and yes the login i am using is marked as administrator, and gave me the access denied error when it tried to write the reg entery.

cscript "C:\Users\Jim\Desktop\vbrunas.vbs" jim password123 "C:\Users\Jim\Desktop\NewMachineSetup.bat"

Post Reply