+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
Scripts Thread, Set background on a select group of computers using BGInfo in Coding and Web Development; Hi all, I have been asked to set a background/wallpaper on a group of computers on our curriculum network and ...
  1. #1

    Join Date
    May 2006
    Posts
    1,319
    Thank Post
    101
    Thanked 25 Times in 18 Posts
    Rep Power
    25

    Set background on a select group of computers using BGInfo

    Hi all,

    I have been asked to set a background/wallpaper on a group of computers on our curriculum network and this background will be different from the background on the rest of the network.

    Currently we control the background via the tool BGInfo, I believe it is quite popular around here. This also requires a line or two in the login script. However the obvious problem here is that this couple of lines in the login script control the background for the entire network. Now I need a different background in a certain ICT Suite.

    I'm guessing the only way to do this is adding some extra lines to the script to check what the computer name is and set the background / use the correct BGInfo command accordingly.

    The computer names in question are IT-SUITE-27 to IT-SUITE-36.

    Does anyone have any ideas of what script would be best in this case?

    Thanks

    James

  2. #2

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124

    Re: Set background on a select group of computers using BGInfo

    set oShell=createobject("wscript.shell")
    set oNet=createobject("wscript.network")
    sComputer=ucase(oNet.computername")
    sCmd="bginfo etc etc - non IT Suite"
    if left(sComputer,8)="IT-SUITE" then
    iNum=right(sComputer,2)
    if iNum >=27 and iNum<=36 then
    sCmd="bginfo etc etc IT Suite special"
    end if
    end if
    oShell.run sCmd

    Replace the lines starting "scmd" with the lines you want to happen for each position.

    Basically, all the script does is get the computer name in upper case. If it starts with "IT-SUITE" then it takes the last 2 characters and checks the value. Note that this will all fall over if you have any machines like "IT-SUITEXX" (ie letters instead of numbers - has anyone been flash and numbered in hex, for example :-))

  3. Thanks to srochford from:

    _Bat_ (26th October 2012)

  4. #3

    Join Date
    May 2006
    Posts
    1,319
    Thank Post
    101
    Thanked 25 Times in 18 Posts
    Rep Power
    25

    Re: Set background on a select group of computers using BGIn

    Sorry... I forgot to mention it has to be done in batch script *looks embarassed for not mentioning that before* sorry! Thanks for the effort though.

  5. #4

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124

    Re: Set background on a select group of computers using BGInfo

    OK; let's make life more difficult :-)

    computername should be present as an environment variable; using the :~ construct allows you to extract part of it. this is a bit kludgy but should work.

    to be honest, I'd start moving towards vbscript for stuff like this - it's a lot easier! Even if the main file is a batch file there's nothing to stop you putting:

    cscript <script.vbs>

    in the cmd file to call out to a vbscript

    @echo off
    set cstart=%computername:~0,7%
    if not %cstart%==IT-SUITE goto standard
    cnumber=%computername:~7,2%
    if cnumber==27 goto special
    if cnumber==28 goto special
    if cnumber==29 goto special


    goto standard
    :special
    bginfo /special switches
    goto end

    :standard
    bginfo /standard switches

    :end

  6. #5

    Join Date
    Mar 2007
    Location
    Central Scotland
    Posts
    829
    Thank Post
    12
    Thanked 8 Times in 8 Posts
    Rep Power
    19

    Re: Set background on a select group of computers using BGInfo

    ace scripts Srochford, out of curiosity is the VB one someone I could run at logon or even in a workstation OU?

    Tempted to work something like that out, different set backgrounds depending on department, but all changable centrally (hosted on the server). Be handy as I'm renaming all of our suite PCs over the summer

  7. #6

    Join Date
    May 2006
    Posts
    1,319
    Thank Post
    101
    Thanked 25 Times in 18 Posts
    Rep Power
    25

    Re: Set background on a select group of computers using BGInfo

    Thanks a lot srochford, I'll give it a shot tomorrow . I agree, the scripts look brilliant.

  8. #7

    Join Date
    May 2006
    Posts
    1,319
    Thank Post
    101
    Thanked 25 Times in 18 Posts
    Rep Power
    25

    Re: Set background on a select group of computers using BGIn

    (Just putting them in code tags to make them easier to read)

    VBScript:

    Code:
    set oShell=createobject("wscript.shell")
    set oNet=createobject("wscript.network")
    sComputer=ucase(oNet.computername")
    sCmd="bginfo etc etc - non IT Suite"
    if left(sComputer,8)="IT-SUITE" then 
     iNum=right(sComputer,2)
     if iNum >=27 and iNum<=36 then
       sCmd="bginfo etc etc IT Suite special"
     end if
    end if
    oShell.run sCmd
    Batch:

    Code:
    @echo off
    set cstart=%computername:~0,7%
    if not %cstart%==IT-SUITE goto standard
    cnumber=%computername:~7,2%
    if cnumber==27 goto special
    if cnumber==28 goto special
    if cnumber==29 goto special
    
    
    goto standard
    :special
    bginfo /special switches
    goto end
    
    :standard
    bginfo /standard switches
    
    :end

  9. #8

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124

    Re: Set background on a select group of computers using BGInfo

    Quote Originally Posted by Halfmad
    ace scripts Srochford, out of curiosity is the VB one someone I could run at logon or even in a workstation OU?

    Tempted to work something like that out, different set backgrounds depending on department, but all changable centrally (hosted on the server). Be handy as I'm renaming all of our suite PCs over the summer
    It needs to run on a "per user" basis so running it at logon is fine. It's the kind of thing I have in a login script for all users (attached at domain level) - the script can then decide what you want to happen (eg on ours we don't change the wallpaper on a server but do change it on a workstation)

    If you attach it to a workstation OU then you need to make sure you set the script as "user logon" not "machine startup". I don't like doing stuff at OUs unless it is very specific to an OU.

    For example, we have an OU of "special PCs" (they are noticeboards, clocking in machines etc) and the stuff they run is very different from everything else. All other machines will do different things but it's essentially the same - eg you might want one wallpaper for group A but a different one for OU B but you still want a wallpaper everywhere.

  10. #9
    kearton's Avatar
    Join Date
    May 2007
    Location
    Yorkshire, via NZ ;)
    Posts
    880
    Thank Post
    171
    Thanked 106 Times in 88 Posts
    Rep Power
    45

    Re: Set background on a select group of computers using BGInfo

    Having read this thread I've just started using this nifty little app too. I packaged it up as an MSI in 5 mins and put a shortcut in the startup items

  11. #10

    Join Date
    May 2006
    Posts
    1,319
    Thank Post
    101
    Thanked 25 Times in 18 Posts
    Rep Power
    25

    Re: Set background on a select group of computers using BGInfo

    Okay, I tried using the batch version first of all and that just didn't work... all of the computers used the "non ict suite" BGInfo code.

    So I tried the VBS version and got the following error:

    "\\server\netlogon\bglogon.vbs(3, 36) Microsoft VBScript compilation error: Unterminated string constant"

    This appeared to be due to a missing speech mark, which I added.

    I then ran it again and got the following:

    "\\server\netlogon\bglogon.vbs(4, 35) Microsoft VBScript compilation error: Syntax error"

    Line 4 is actually the following:
    sCmd="%SYSTEMROOT%\bginfo.exe /i"\\SERVER\NETLOGON\BGINFO\curric.bgi" /timer:0"
    Any ideas? Is it the \\server bit? Or is it being affected by speech marks?

  12. #11

    Join Date
    Mar 2007
    Location
    Central Scotland
    Posts
    829
    Thank Post
    12
    Thanked 8 Times in 8 Posts
    Rep Power
    19

    Re: Set background on a select group of computers using BGInfo

    That line you've quoted suggests that the bginfo exe is in the systemroot. I know it isn't on my clients. Perhaps that's causing the problem?

    I haven't actually tried this yet, still sorting out problems from my pupil servers HDDs breaking on Friday

  13. #12

    Join Date
    May 2006
    Posts
    1,319
    Thank Post
    101
    Thanked 25 Times in 18 Posts
    Rep Power
    25

    Re: Set background on a select group of computers using BGInfo

    It is in the systemroot. All the code related to BGInfo is correct, it just doesn't want to work when combined with the script from Steve .

  14. #13

    Join Date
    May 2006
    Posts
    1,319
    Thank Post
    101
    Thanked 25 Times in 18 Posts
    Rep Power
    25

    Re: Set background on a select group of computers using BGInfo

    Can you let me know when you give this a go, halfmad? I'm wondering how much success others will have with it

  15. #14
    Iain's Avatar
    Join Date
    Oct 2006
    Location
    Warwickshire
    Posts
    188
    Thank Post
    28
    Thanked 93 Times in 53 Posts
    Rep Power
    32

    Re: Set background on a select group of computers using BGIn

    You need to escape those quote characters in the middle of the string sCmd

    sCmd="%SYSTEMROOT%\bginfo.exe /i"\\SERVER\NETLOGON\BGINFO\curric.bgi" /timer:0"
    should read
    Code:
    sCmd="%SYSTEMROOT%\bginfo.exe /i""\\SERVER\NETLOGON\BGINFO\curric.bgi"" /timer:0"
    Hope this helps,

    Iain.

  16. #15

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124

    Re: Set background on a select group of computers using BGInfo

    Just for info, bginfo will run from a server share - you don't need to install it on the machine or even copy it to the machine (but it won't do any harm if you have!)

    Double double quotes is always a problem - one of the things I often do is put a:

    wscript.echo sCmd

    in a script while I'm testing it - this can then give you an idea of what's actually going to be run.

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. BGinfo help!
    By mmoseley in forum Windows
    Replies: 34
    Last Post: 3rd October 2008, 06:29 PM
  2. Replies: 1
    Last Post: 7th September 2007, 02:16 PM
  3. BGInfo in logon script example?
    By ninjabeaver in forum How do you do....it?
    Replies: 16
    Last Post: 24th August 2007, 12:49 PM
  4. Replies: 22
    Last Post: 6th July 2007, 08:56 AM
  5. BGInfo on logon screen
    By Ric_ in forum Windows
    Replies: 17
    Last Post: 16th September 2006, 01:25 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •