timothy
Thu Dec 07 09:15:13 CST 2006
WOW. That was the most comprehensive answer I have ever received from a
post. Thank you so much...all went well and I am now running my (your)
script via group policy.
Cheers,
Tim
alex wrote:
> I am unsure why you can't put the batch file in the sysvol on your DC
> and have the btach execute via group policy, but if you need to use a
> vbscript here are two options.
>
> Use the vbscript to execute the batch file:
>
> Save your batch file on the server... for example ..
> "\\131.62.80.10\HelpDesk\Scripts\BGInfo\BGInfo Server\mybatchfile.bat"
>
> ======= Option 1 ===========
>
> copy the following code into a file and save it as logon.vbs
> 'Begin code
> 'this is line 1
> set shell=createobject("wscript.shell")
> 'this is line 2 ===Wathch the word wrap
> shell.Run "cmd /k "\\131.62.80.10\HelpDesk\Scripts\BGInfo\BGInfo
> Server\mybatchfile.bat", 0, false
> 'End Code
>
> then configure Group policy to run the logon.vbs at logon on whenever.
> This will lauch your batch file.
>
>
>
> ======= Option 2 ============
>
> copy the following code and save it as logon.vbs and configure group
> policy to execute the script at logon. Depending on network latency
> factors this could fail if the network drives are not available at the
> time of the script execution.
>
>
> ' line 1 ======= Begin script
> set shell=CreateObject("Wscript.Shell")
> ' line 2 -- Put the following on one line
> cmd1 = Chr(34) & "\\131.62.80.10\HelpDesk\Scripts\BGInfo\BgInfo
> Server\Server.bgi" & chr(34)
> ' line 3 put following on one line
> cmd2 = Chr(34) & "\\131.62.80.10\HelpDesk\Scripts\BGInfo\BGInfo
> Server\BGInfo.exe" & chr(34) & " /SILENT /NOLICPROMPT /timer:0"
> 'line 4
> shell.run cmd1,0,false
> 'line 5
> shell.run, cmd2,0,false
> ' End Script
>
> One of the two options above should work. An end note:
> the shell.run methos accepts three parameters
> shell.run Param1, param2, param3
>
> Param1 -- is the the path & command you want to execute. If you have
> spaces in the file path the you may need to enclose the command in
> quotations. This can be done as followed
> Chr(34) & "c:\documents and settings\%username%\test.bat" & chr(34)
> alternately you can do this as well
> ""c:\documents and settings\%username%\test.bat""
> However when joining longer strings the later can become confusing so I
> usually use the chr(34) constant.
>
> Param 2 - the style of the window the command is to be ran in. I used 2
> to hide the script window, wich will probably be your best bet for an
> enterprise logon. Other options are as follows.
> values as as follows:
> 0 Hides the window and activates another window.
> 1 Activates and displays a window. If the window is minimized or
> maximized, the system restores it to its original size and position. An
> application should specify this flag when displaying the window for the
> first time.
> 2 Activates the window and displays it as a minimized window.
> 3 Activates the window and displays it as a maximized window.
> 4 Displays a window in its most recent size and position. The active
> window remains active.
> 5 Activates the window and displays it in its current size and
> position.
> 6 Minimizes the specified window and activates the next top-level
> window in the Z order.
> 7 Displays the window as a minimized window. The active window remains
> active.
> 8 Displays the window in its current state. The active window remains
> active.
> 9 Activates and displays the window. If the window is minimized or
> maximized, the system restores it to its original size and position. An
> application should specify this flag when restoring a minimized window.
>
> 10 Sets the show-state based on the state of the program that started
> the application.
>
> param3 - Boolean to wait on return. Specifies if the script should
> wait until the command finishes executing before processing the next
> line of the script. I usually set this to true when possible.
> However, when executing an command on a remote computer, the the script
> could possibly through an error that it can not wait for the process to
> complete. Test your particular situation and choose the best one
> False - Continues with the script without waiting for the the command
> to finish execution,
> True - Waits for the the current command to execute until processing
> the next line.
>
>
> Hope this Helps
>
> Alexander Higgins
>
http://afforablewebdesignsinc.com
>
http://afforablewebdesignsinc.com.blog-spot.com
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> timothy.malloy@gmail.com wrote:
> > Will someone please be so kind as to help me translate a .bat to
> > vbscript? I can't seem to do it despite my best attempts. Here's the
> > .bat:
> >
> > @echo off
> >
> > "\\131.62.80.10\HelpDesk\Scripts\BGInfo\BGInfo Server\BGInfo.exe"
> > "\\131.62.80.10\HelpDesk\Scripts\BGInfo\BgInfo Server\Server.bgi"
> > /SILENT /NOLICPROMPT /timer:0
> >
> > As you can see, I am trying to run the BGInfo app from a share. I don't
> > want to copy the .bat to everyone's startup folder rather I would like
> > to run the vbscript command from group policy logon script. Thanks for
> > any help you can offer.
> >
> > Tim