Question Locked

logon VBscript to run BGinfo

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

What I'm looking for is a VBscript that I can use as a logon script in Group Policy to run BGinfo from Sysinternals. I have a batch script setup that works, but we block the CMD prompt for users in group policy, so the script doesn't run. I have a VBscript that works to open BGinfo.exe, but I don't know how to get the switches that you would use in CMD to work in VBscript. Here is what my VBscript looks like:

Set objShell = CreateObject("WScript.Shell")
objShell.Run "C:\bginfo.exe"

My batch script that works is:

@ECHO OFF
cd\
%LOCALDIR%\Bginfo.exe %LOCALDIR%\bgconfig.bgi /timer:0 /nolicprompt
@ECHO OFF
exit

I hope what I need is clear in my description, if not I'll explain further.

9 replies

by scott_heath

... tried adding them to the command line? I have used plenty of switches via Wscript.Shell Run method.

If you need to use variable then you do something like:

sLocalDir = "c:\test"

sCommand = sLocalDir & "\bginfo.exe " & sLocalDir & "\bgconfig.bgi /timer:0 /nolicpropmt"

Let me know if this makes sense or if you have more details to provide.

by kevin

Here is a script that I was able to get working on user logon:

Option Explicit
Dim theShell
Set theShell = CreateObject("WScript.Shell")
theShell.Run "C:\bginfo.exe C:\bgconfig.bgi /timer:0 /nolicprompt"
Set theShell = Nothing
WScript.Quit(0)

But now I have a problem. It turns out that there is 1 computer in the organization that I've found doesn't have a "C:" drive, it's "E:\". I've looked online for an equivalent to %LOCALDIR% in VBscript, but I can't find it anywhere. Ideally this script should run the BGinfo.exe from the local system disk no matter what the drive letter.

by scott_heath

I am assuming %LOCALDIR% is the system drive like c: based on what the code says. So add this:

Set colProcessEnvVars = theShell.Environment("Process")
SysDrive = colProcessEnvVars("SYSTEMDRIVE")

CmdLine = SysDrive & "\bginfo.exe " & SysDrive & "\bgconfig.bgi /timer:0 /nolicprompt"
theShell.Run CmdLine

Enjoy!!

by kevin

It worked! Here is my final code:

Option Explicit
Dim theShell, colProcessEnvVars, SysDrive, CmdLine
Set theShell = CreateObject("WScript.Shell")
Set colProcessEnvVars = theShell.Environment("Process")
SysDrive = colProcessEnvVars("SYSTEMDRIVE")

CmdLine = SysDrive & "\bginfo.exe " & SysDrive & "\bgconfig.bgi /timer:0 /nolicprompt"
theShell.Run CmdLine

Set theShell = Nothing
WScript.Quit(0)

Thanks for your help!

by scott_heath

Feel free to give my answer the "thumbs up". I do love to see that little number increment. ;)

by vannten

Option Explicit
Dim theShell
Set theShell = CreateObject("WScript.Shell")
theShell.Run "C:\Downloads\BGinfo\bginfo.exe C:\Downloads\BGinfo\default.bgi /timer:0 /nolicprompt"
Set theShell = Nothing
WScript.Quit(0)

This discussion is closed to new replies.