Windows 7 UAC

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
casaestrada
Posts: 15
Joined: Sat Mar 21, 2009 5:41 am

Windows 7 UAC

Post by casaestrada » Sun Nov 27, 2011 2:49 pm

Anyone know how to run the following via vbs script: SET __COMPAT_LAYER=RunAsInvoker I am trying to run an executable script but darn Windows 7 UAC prompts my users. This command is a way to run without the prompt but I am not sure how to run via vbs script. Hopefully someone knows a better method.

User avatar
casaestrada
Posts: 15
Joined: Sat Mar 21, 2009 5:41 am

Windows 7 UAC

Post by casaestrada » Sun Nov 27, 2011 3:42 pm

So besides removing UAC is there anyway to run scripts via windows 7?? I'm struggling with vbs hta wmi cmd kix scripts on windows 7.

User avatar
jvierra
Posts: 12399
Joined: Tue May 22, 2007 9:57 am
Contact:

Windows 7 UAC

Post by jvierra » Mon Nov 28, 2011 1:49 am

They run the same on Win7 as on XP.

What errors are you getting?

User avatar
casaestrada
Posts: 15
Joined: Sat Mar 21, 2009 5:41 am

Windows 7 UAC

Post by casaestrada » Mon Nov 28, 2011 5:57 am

I'm running a long login script and its not an error. Its with bginfo and every time I run it in windows 7 my users get a prompt to confirm running bginfo.exe. On windows Xp, it works flawlessly.

Code: Select all


Declare Variables and constants
Dim objShell, objFSO, intErrorCode

'Create objects
Set objShell = CreateObject("WScript.Shell")
Set objFSO = createobject("scripting.filesystemobject")'Create the c:bginfo folder
If not objFSO.FolderExists("C:bginfo") Then
    objFSO.CreateFolder("C:bginfo")
End If

'Copy the bginfo files
'intErrorCode = objFSO.CopyFile(objShell.CurrentDirectory & "Bginfo.lnk", "C:bginfo")
intErrorCode = intErrorCode + objFSO.CopyFile(objShell.CurrentDirectory & "Bginfo.exe", "C:bginfo")
intErrorCode = intErrorCode + objFSO.CopyFile(objShell.CurrentDirectory & "wstat.bgi", "C:bginfo")

'Add the bginfo shortcut to the run registry key
intErrorCode = intErrorCode + objshell.RegWrite("HKLMSOFTWAREMicrosoftWindowsCurrentVersionRunbginfo", "C:bginfoBginfo.exe /nolicprompt /ic:bginfowtest.bgi /timer:0", "REG_SZ")

objShell.Run "C:bginfoBginfo.exe /NOLICPROMPT /silent /i c:bginfowtest.bgi /timer:0"'Cleanup
Set objShell = Nothing
Set objFSO = NothingWScript.Quit(intErrorCode)
'========================================================================================

User avatar
jvierra
Posts: 12399
Joined: Tue May 22, 2007 9:57 am
Contact:

Windows 7 UAC

Post by jvierra » Mon Nov 28, 2011 8:14 am

If it is in the logon script it will always run. It is not designed to run in a logon script. It generates a replacement for the desktop background. Read the documentation.

User avatar
casaestrada
Posts: 15
Joined: Sat Mar 21, 2009 5:41 am

Windows 7 UAC

Post by casaestrada » Mon Nov 28, 2011 8:39 am

I did read the documentation JVierra...as i stated early- the script runs without prompting my users in Windows XP however it asks my users for confirmation to run bginfo in windows 7. This is obviously indicative of Windows UAC. I just asked if there was another method that someone may know to get around the UAC issue. From my searching for answers on UAC , the only known workarund is SET __COMPAT_LAYER=RunAsInvoker which I am not sure how to use within vbs scripting....

User avatar
jvierra
Posts: 12399
Joined: Tue May 22, 2007 9:57 am
Contact:

Windows 7 UAC

Post by jvierra » Mon Nov 28, 2011 8:59 am

Sysinternals has a forum that can better help you to understand what I am saying.

You cannot bypass the UAC but you do not need to run BGINfo on every login.

From the instructions:


See Mark's Windows IT Pro Magazine Power Tools article for a primer on using BgInfo. If you have questions or problems, please visit the Sysinternals BgInfo Forum.
By placing BGInfo in your Startup folder, you can ensure that the system information being displayed is up to date each time you boot. Once you've settled on the information to be displayed, use the command-line option /timer:0 to update the display without showing the dialog box.
You can also use the Windows Scheduler to run BGInfo on a regular basis to ensure long-running systems are kept up to date.
[/quote]

Notice that it say to just place the program into the startup folder. Once it is initialized you do not need to reimport the file on every run. That is just a way to copy settings from another system and is not intended to be used everytime.

The docs above contain the links to teh articles an forum for BGInfo.

The important thing to understand is that this is not a scripting issue. It is an issue of the functionality of a third party program. Just because you are trying to run it from a script does not make it a script problem.

UAC cannot be temprarily bypassed. My guess is that if you run it like the documentation suggests you will not get the prompt.


jvierra2011-11-28 16:03:45

User avatar
casaestrada
Posts: 15
Joined: Sat Mar 21, 2009 5:41 am

Windows 7 UAC

Post by casaestrada » Mon Nov 28, 2011 12:34 pm

I never said I had a bginfo issues per say- i said it was UAC issue. Regardless -I found a way to bypass the windows 7 UAC ...thanks Vierra.answer: use a batch file then call your script e.g.@echo offset __COMPAT_LAYER=RunAsInvoker
start regedit.exe servernameNETLOGONchange.reg /s

User avatar
jvierra
Posts: 12399
Joined: Tue May 22, 2007 9:57 am
Contact:

Windows 7 UAC

Post by jvierra » Mon Nov 28, 2011 1:33 pm

The bat is an example of nothing. What is sorted? What does sorting have to do with anything?




User avatar
casaestrada
Posts: 15
Joined: Sat Mar 21, 2009 5:41 am

Windows 7 UAC

Post by casaestrada » Mon Nov 28, 2011 1:49 pm

My problem with all my scripts running on Windows 7 with UAC is fixed. Dont know why you are are taking offense - :) my problem is solved aka sorted. Thanks

Locked