Page 1 of 1

Windows 7 UAC

Posted: Sun Nov 27, 2011 1:49 pm
by casaestrada
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.

Windows 7 UAC

Posted: Sun Nov 27, 2011 2:42 pm
by casaestrada
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.

Windows 7 UAC

Posted: Mon Nov 28, 2011 12:49 am
by jvierra
They run the same on Win7 as on XP.

What errors are you getting?

Windows 7 UAC

Posted: Mon Nov 28, 2011 4:57 am
by casaestrada
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)
'========================================================================================

Windows 7 UAC

Posted: Mon Nov 28, 2011 7:14 am
by jvierra
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.

Windows 7 UAC

Posted: Mon Nov 28, 2011 7:39 am
by casaestrada
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....

Windows 7 UAC

Posted: Mon Nov 28, 2011 7:59 am
by jvierra
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

Windows 7 UAC

Posted: Mon Nov 28, 2011 11:34 am
by casaestrada
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

Windows 7 UAC

Posted: Mon Nov 28, 2011 12:33 pm
by jvierra
The bat is an example of nothing. What is sorted? What does sorting have to do with anything?




Windows 7 UAC

Posted: Mon Nov 28, 2011 12:49 pm
by casaestrada
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