从组策略参数传递给VBScript中 [英] Passing parameters from Group Policy to VBScript

查看:208
本文介绍了从组策略参数传递给VBScript中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我需要把一个批处理脚本出来通过组策略登录脚本

So i need to push a batch script out as a login script through Group Policy

批处理脚本示例:

@echo off
Set USPS=%1 %2
Command %USPS%

我使用VB脚本调用.bat文件

I'm using a VB Script to call the .bat file

VB脚本

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

因此​​,任何喜欢什么即时试图做的是传递两个参数(用户名和密码),以VB脚本然后让VB脚本将它们传递到批处理文件,但它不是将它们传递给指出哪里IM搞乱?

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.

感谢

推荐答案

下面是你如何能抓住args设置为你的脚本,并一起传递它们:

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

这篇关于从组策略参数传递给VBScript中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆