Question

Locked

logon VBscript to run BGinfo

By kevin ·
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.

This conversation is currently closed to new comments.

9 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Have you...

by scott_heath In reply to logon VBscript to run BGi ...

... 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.

Collapse -

It works, but.....

by kevin In reply to Have you...

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.

Collapse -

No problem!

by scott_heath In reply to It works, but.....

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!!

Collapse -

Awesome!

by kevin In reply to No problem!

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!

Collapse -

My Pleasure

by scott_heath In reply to Awesome!

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

Collapse -

Can we replace SYSTEMDRIVE.......

by Sumit2010 In reply to No problem!

with the UNC path where the bginfo.exe resides?

Collapse -

Typically...

by scott_heath In reply to Can we replace SYSTEMDRIV ...

Yes. But if it doesn't work just create a WScript.Network object and map a drive.

Scott

Visit my blog @
http://scottisageek.spaces.live.com

Collapse -

This is the code I use

by vannten In reply to logon VBscript to run BGi ...

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)

Back to Software Forum
9 total posts (Page 1 of 1)  

Related Discussions

Related Forums