Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GPO Startup VBScript not running

Status
Not open for further replies.

disturbedone

Vendor
Sep 28, 2006
781
AU
I've posted this in the Windows Server 2008 forum as it is more related to Group Policies but as it is a GPO that applies to Win7 clients I thought I should post here in case anyone has some thoughts.



I've got a (currently) W2K8R2 domain with XPSP3 clients. One particular VBScript runs in a GPO as a computer startup script that a) checks the resolution and b) based on the resolution runs BGInfo.exe from a specified folder utilizing the relavant *.bgi file to create a desktop that is displayed before the user logs on. This is so we can see what the computer name & IP is before logon. Another GPO as a logon script uses a different *.bgi file to display more information.

That works perfectly on XP but not on Win7. The logon script still works fine but the startup script does not.

The VBScript works perfectly fine if run once a user is logged on. For example, I logon and run the script manually and it creates the appropriate *.jpg file and places it in %windir%system32\oobe\info\backgrounds and names then according to this so the script does work but just not on startup.

I assume this is something to do with Win7 permissions somehow that XP didn't have. Does Win7 not like running VBScript with knowing which user is running it and determining if it should be allowed?

Anyone know a way around this? Either using the existing VBScript or another way (will PowerShell work better?).
 
if I remember correctly, under XP, one had to usually just list the EXE file for it to be executed, under Win7 you have to use the START command...

also the script needs to run as an Administrator, here use the runas command, e.g. runas /user:REQUIREDUSERNAME /savecred c:\MountDrive.BAT ...

perhaps if you'd care to share the script, we may be able to discern better where the problem lies...



Ben
"If it works don't fix it! If it doesn't use a sledgehammer..."
How to ask a question, when posting them to a professional forum.
Only ask questions with yes/no answers if you want "yes" or "no"
 
I don't think the /runas with the /savecred switch would work because there is nowhere to save the password.

Structure is:

\\domain.local\NETLOGON\W7IBScripts\BackgroundWallpaper
bginfo.exe
scrnres.exe
wallpaper.vbs
\\domain.local\NETLOGON\W7IBScripts\BackgroundWallpaper\1280800
logon.bgi
wallpaper.bgi
\\domain.local\NETLOGON\W7IBScripts\BackgroundWallpaper\1440900
logon.bgi
wallpaper.bgi
\\domain.local\NETLOGON\W7IBScripts\BackgroundWallpaper\12801024
logon.bgi
wallpaper.bgi
\\domain.local\NETLOGON\W7IBScripts\BackgroundWallpaper\16801050
logon.bgi
wallpaper.bgi

Code:
'wallpaper.vbs
'This script determines screen resolution, and executes BGInfo with the correct BGI configuration file

'Base path
path = "\\domain.local\NETLOGON\W7IBScripts\BackgroundWallpaper"
'Arguments for the executable
arguments = "/silent /timer:0 /accepteula"

'Arguments passed to VBScript
Set args = WScript.Arguments
bgi = args.item(0)

Set WshShell = WScript.CreateObject("WScript.Shell")
'Return screen resolution
res = WshShell.run(path & "\scrnres.exe", 0, true)

'Append the resolution to the path
pathFull = path & "\" & res

Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

'If directory for resolution exists, run both instances of BGInfo
If objFSO.FolderExists(pathFull) Then
	If bgi = "wallpaper" Then
		WshShell.run """" & path & "\bginfo.exe """ & pathFull & "\Wallpaper.bgi " & arguments, 0, true
	Else
		WshShell.run """" & path & "\bginfo.exe """ & pathFull & "\Logon.bgi " & arguments, 0, true
	End If
'If there is no corresponding directory for the resolution, run the 1680x1050 version
Else
	If bgi = "wallpaper" Then
		WshShell.run """" & path & "\bginfo.exe """ & path & "16801050\Wallpaper.bgi " & arguments, 0, true
	Else
		WshShell.run """" & path & "\bginfo.exe """ & path & "16801050\Logon.bgi " & arguments, 0, true
	End If
End if

The GPO runs the script wallpaper.vbs with the parameter logon as a Startup Script. The same .vbs is used as a Logon Script with the parameter wallpaper which works perfectly.

The logon.bgi file is configured to save the wallpaper to %windir%\system32\oobo\info\backgrounds
Running the wallpaper.vbs logon command once logged on works perfectly - it creates a file name of, [link maximumpcguides.com/windows-7/change-windows-7s-logon-background/]as per this advice[/url], eg background1440x900.jpg. With this file in that location the image is displayed before logon when the computer boots. This shows that the script works. It's just that it won't run as a Startup Script.

I have just found that another VBScript is also not running as a Startup Script. This is a failry simple on that should enable NumLock.
Code:
set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "{NUMLOCK}"

So it appears to have nothing to do with the scripts themselves but rather a Windows 7 thing and it not running VBScript. Using a *.cmd that calls *.reg files works fine as a Startup Script. It's just *.vbs for some reason.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top