gshaw Posted September 9, 2009 Posted September 9, 2009 (edited) Bit of an odd one I've been battling with so just to try and shed some light on things... I've been using BGInfo via batch files for ages now and it worked really well so I thought I'd go one better and get something to detect the screen res and do the BGInfo that way. Got a script that reads the resolution via WMI then does the Select Case method to run the right wallpaper. Script runs fine if you run it manually as admin but when put as a startup script it doesn't modify the registry setting for the wallpaper or make the temporary bitmap file I'm wondering if it's something to do with the shell.run command I'm using and the security context of the startup script? Seen a few odd bits on Google of similar problems but no real solution or reason behind it... anyone else using VBS and BGInfo to set the logon screen wallpaper? (The same script works fine for user desktops btw) Set objFSO = CreateObject("Scripting.FileSystemObject") Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery ("Select * From Win32_DisplayConfiguration") Dim shell Set shell=createobject("wscript.shell") Dim cmdline1024 cmdline1024="c:\windows\bgibmp\bginfo.exe /i" & "\\domain\sysvol\domain\UserSettings\tools\logon1024.bgi" & " /accepteula /timer:0" Dim cmdline1680 cmdline1680="c:\windows\bgibmp\bginfo.exe /i" & "\\domain\sysvol\domain\UserSettings\tools\logon1024.bgi" & " /accepteula /timer:0" Const OverwriteExisting = TRUE ' Determine the size of the desktop For Each objItem in colItems X = objItem.PelsWidth Y = objItem.PelsHeight Next strScreenRes = X & "x" & Y Select Case strScreenRes Case "1024x768" Shell.run cmdline1024 set shell=nothing Case "1680x1050" Shell.run cmdline1680 set shell=nothing Case "1920x1200" Shell.run cmdline1680 set shell=nothing case Else Shell.run cmdline1024 set shell=nothing End Select Edited September 9, 2009 by gshaw
maniac Posted September 9, 2009 Posted September 9, 2009 I am using BG info sucessfully with VBS script. I have a startup script which copies down the correct wallpapers and the BGinfo program locally to the machine in the same locations for every workstation, but the BGI file is on the netlogon share so I can make clobal changes to it easily. I then use the lines; Set objWshShell = CreateObject( "WScript.Shell" ) objWshShell.Run "C:\bginfo\bginfo.exe \\DOMAIN\NETLOGON\BGINFO\Students.bgi /timer:0 /NOLICPROMPT" To run the program from my student login script. Works like a charm for me Mike.
gshaw Posted September 9, 2009 Author Posted September 9, 2009 I'm guessing that's to change the student desktop background? That works fine for me, it's when I try to execute a BGI file at startup that it seems to break, but only when called via vbscript
maniac Posted September 9, 2009 Posted September 9, 2009 Ahhh, yes sorry miss-read your origenal post. That is a login script to modify the student desktop background. However, I also have it working on a startup script to modify the background before login, but I couldn't get it to work like you are trying to, so I cheated and got it to generate the .BMP file into a folder, and used a Registry hack to get it to display on the logon screen, that works fine but does require a restart of the workstation before it displays. Startup script runs the BGI file in the same way your script does, but also calls regedit to apply some settings - In the full script there's a marker file placed on the HDD to indicate if this has been run, so it only runs once. VB script to call registry file WshShell.Run "regedt32.exe /s \\DOMAIN\NETLOGON\STUDENTLOGONSETTINGS.REG" Content of Registry file STUDENTLOGONSETTINGS.REG Windows Registry Editor Version 5.00 [HKEY_USERS\.DEFAULT\Control Panel\Desktop] "Wallpaper"="c:\\bginfo\\system.bmp" Then get BGinfo to generate its BMP file as C:\BGinfo\system.bmp and that will be your background at the login prompt, works well for me. Mike
mac_shinobi Posted September 9, 2009 Posted September 9, 2009 Select Case strScreenRes Case "1024x768" Shell.run cmdline1024 set shell=nothing Case "1680x1050" Shell.run cmdline1680 set shell=nothing Case "1920x1200" Shell.run cmdline1680 set shell=nothing case Else Shell.run cmdline1024 set shell=nothing End Select Where is the code for the function for cmdlineXXXX where XXXX is the 4 digit number ie 1024 etc ?
gshaw Posted September 9, 2009 Author Posted September 9, 2009 Further up the top of the script... Dim cmdline1024 cmdline1024="c:\windows\bgibmp\bginfo.exe /i" & "\\domain\sysvol\domain\UserSettings\tools\logon1024.bgi" & " /accepteula /timer:0" Dim cmdline1680 cmdline1680="c:\windows\bgibmp\bginfo.exe /i" & "\\domain\sysvol\domain\UserSettings\tools\logon1024.bgi" & " /accepteula /timer:0" Works lovely at any other point apart from as a startup script, it definitely runs as I've put wscript.echo lines in there to print out the strings and paths but just doesn't seem to have any effect
PiqueABoo Posted September 9, 2009 Posted September 9, 2009 I've had BGInfo working at Computer Startup, but that's via a CMD and I RoboCopy mirror all the files beforehand (the only thing that bothers me about it is the curious amount of time BGInfo takes to run, typically 10-15 seconds). I wonder what happens if you get your VBS to call a batch file which just has the BGInfo command line in it. Or better still surround that line with some times: echo %date% %time:~0,8%: ***** START ***** > c:\bgtest.txt c:\windows\bgibmp\bginfo.exe ... etc. echo %date% %time:~0,8%: ***** END ***** >> c:\bgtest.txt That way you'll at least see whether it's running at all i.e. tiny time = no.
maniac Posted September 9, 2009 Posted September 9, 2009 I've had BGInfo working at Computer Startup, but that's via a CMD and I RoboCopy mirror all the files beforehand (the only thing that bothers me about it is the curious amount of time BGInfo takes to run, typically 10-15 seconds). It takes a split second to run on my system. I've got it setup to customise the wallpaper for students with their user name and logon time in the top right hand corner, and also customise the logon screen with some text that says who the last user to logon to that machine was, trying out the psychology that the users might be less inclined to damage the computers if they know their name's going to be on the front screen when they logoff. Both of these are called from a VBS logon script, although I worked out BGinfo doesn't like it if more than one instance of it is running, so I had to put a delay in the script before it called the second one, but that's only about 2 seconds to allow the first one to complete. You have to put the /timer:0 in the command or it will take a while, as by default it does have a 15 second delay when you run it with no switches. Mike.
maniac Posted September 9, 2009 Posted September 9, 2009 Just reaslised you're using the /i option. I didn't bother with that and it worked fine for me without it - it may be worth giving it a try without the /i and just the .BGI file immediatly after bginfo.exe just as a possibility. Mike.
PiqueABoo Posted September 9, 2009 Posted September 9, 2009 There's no "/i" option mentioned in the help for the version I've got (latest) so I don't use that either. There is a "/log" option though which is probably worth using to help see what's happening with that VBS call. It takes a split second to run on my system. Still 5 seconds running it manually logged on as an admin. Don't know, perhaps it depends on the info (I've got IP adresses and computer name in this case).
maniac Posted September 9, 2009 Posted September 9, 2009 Still 5 seconds running it manually logged on as an admin. Don't know, perhaps it depends on the info (I've got IP adresses and computer name in this case). Mine is doing machine name, username and time and date of logon. It is slower on wireless laptops, but on my cabled machines it's literally half a second or less for it to run. Mike.
gshaw Posted September 10, 2009 Author Posted September 10, 2009 Tbh I can't remember why the /i switch was on there! Will give it a go without and see what happens
john Posted September 10, 2009 Posted September 10, 2009 Must admit I haven't had any success with the latest download of it via VBS, tried various version of script from here with no joy so went back to a batch file instead.
maniac Posted September 10, 2009 Posted September 10, 2009 Must admit I haven't had any success with the latest download of it via VBS, tried various version of script from here with no joy so went back to a batch file instead. That's a good point, the version I'm using is an older one that I had already downloaded a while back - it does the job so I stuck with it. That may be the difference. Mike.
gshaw Posted September 11, 2009 Author Posted September 11, 2009 (edited) Hmmmm I wonder if that's it... maniac what version are you running exactly? Any chance of posting it up so I can try the older one? Just checked, got v4.14 on one network, v4.12 on the other (that version isn't working via VBS on startup at the moment) and the website shows a v4.15 as the latest one If not I'll leave BGInfo and just use a reg hack pointing to BMP files I create manually Edited September 11, 2009 by gshaw
gshaw Posted September 11, 2009 Author Posted September 11, 2009 Got bored with fighting BGInfo in the end and did the logon background with a scripted reg hack and copying the bitmap over... can live with doing it manually for that one.
maniac Posted September 11, 2009 Posted September 11, 2009 Hmmmm I wonder if that's it... maniac what version are you running exactly? Any chance of posting it up so I can try the older one? Just checked, got v4.14 on one network, v4.12 on the other (that version isn't working via VBS on startup at the moment) and the website shows a v4.15 as the latest one If not I'll leave BGInfo and just use a reg hack pointing to BMP files I create manually Actually funny enough it's 4.15 I'm using, it must have been out for a while as I downloaded it quite a while back so I kinda assumed it would be an older version. Mike.
PiqueABoo Posted September 13, 2009 Posted September 13, 2009 ::ho hum:: Re. my mysteriously slow BGInfo times it was obvious really. Screamingly, screamingly obvious. As usual, if there's no sane reason for [some behaviour] then it's: A/V interfering!
gshaw Posted September 14, 2009 Author Posted September 14, 2009 ::ho hum:: Re. my mysteriously slow BGInfo times it was obvious really. Screamingly, screamingly obvious. As usual, if there's no sane reason for [some behaviour] then it's: A/V interfering! Haha welcome to my world... AV is messing up my Computer Settings loading times but no fix as yet
MyITGuy Posted July 18, 2012 Posted July 18, 2012 (edited) I know this is an old thread, but we just ran into this issue at our company. Just wanted to post what we saw and the solution we implemented. For our company, the issue was with the WScript.Shell Run method. This method has a syntax of WScript.Shell.Run (strCommand, [intWindowStyle], [bWaitOnReturn]). In our environment we were, originally, specifying False for bWaitOnReturn (and it worked). At some point, this stopped working. When we changed bWaitOnReturn to True, it started working as expected. Keep in-mind, that in the code mentioned in the original post, no bWaitOnReturn parameter is provided, which is the same as stating False. In our environment, I believe a Group Policy Object (GPO) changed that also changed the functionality (possibly Synchronous vs Asynchronous execution); but I have not verified this. I hope this helps others experiencing this same issue. Also, adding a WScript.Shell.Run command for %WinDir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters will allow the logon screen to update after execution of BGInfo. Be sure to use the same WScript.Shell.Run method format. Edited July 18, 2012 by MyITGuy Grammar 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now