问题
So i need to push a batch script out as a login script through Group Policy
Batch Script Example:
@echo off
Set USPS=%1 %2
Command %USPS%
I'm using a VB Script to call the .bat file
VB Script
Dim var1, var2
Set objShell = WScript.CreateObject("WScript.Shell")
'Parameter1, begin with index0
var1 = WScript.Arguments(0)
'Parameter2
var2 = WScript.Arguments(1)
objShell.Run "Script.bat" var1 & var2, 0, True
I'm placing parameters in the script parameters text box in group policy
So what im trying to do is pass the two parameters (Username and Password)to the VB Script then have the VB Script pass them to the batch file but it isn't passing them any like to point out where im messing up?
I'm doing it this way because i need to hide the username and password so i cant put them inside the scripts.
Thanks
回答1:
Here's how you can grab the args to your script and pass them along:
If WScript.Arguments.Count <> 2 Then
WScript.Echo "This script needs two args."
WScript.Quit -1
End If
Dim var1, var2
var1 = WScript.Arguments(0)
var2 = WScript.Arguments(1)
With CreateObject("WScript.Shell")
.Run "Script.bat " & var1 & " " & var2, 0, True
' Or, if you want to leave the batch file out of this...
.Run Chr(34) & "\\server\Folder\program.exe" & Chr(34) & " /remoteauth " & var1 & " " & var2
End With
来源:https://stackoverflow.com/questions/31006179/passing-parameters-from-group-policy-to-vbscript