AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 679307
Accepted
Matthias Güntert
Matthias Güntert
Asked: 2015-03-31 05:50:56 +0800 CST2015-03-31 05:50:56 +0800 CST 2015-03-31 05:50:56 +0800 CST

如何在不使用包装脚本的情况下对用户 (.vbs) 隐藏正在运行的登录脚本?

  • 772

我有一个运行登录脚本 (.vbs) 并将其链接到包含 W2012R2 RDS 主机的 OU 的 GPO(配置了环回替换)。

我对政策进行了这些(与问题相关的)更改:

Computer Configuration -> Policies -> Administrative Templates -> System -> Group Policy -> Configure Logon Script Delay -> Enabled -> minute: 0 

User Configuration -> Policies -> Windows Settings -> Scripts (Logon/Logoff) -> MyScript.vbs 

User Configuration -> Policies -> Administrative Templates -> System -> Run legacy logon scripts hidden -> Enabled 

User Configuration -> Policies -> Administrative Templates -> System -> Display instructions in logon scripts as they run -> Disabled

当用户登录时,脚本在前台完美运行,但根据我所做的设置,我本来希望命令提示符根本不会弹出。那么我在这里做错了什么,微软对“遗留脚本”的定义到底是什么?

我知道我可以编写一个cscript.exe使用隐藏参数调用的小型“包装脚本”,但我想保持它尽可能干净,并想了解为什么我的设置不起作用。

windows
  • 1 1 个回答
  • 5651 Views

1 个回答

  • Voted
  1. Best Answer
    Matthias Güntert
    2015-03-31T22:47:07+08:002015-03-31T22:47:07+08:00

    我弄清楚是什么原因造成的,因为我的 GPO 设置是正确的。我需要运行的脚本使用一个函数来强制使用 32 位版本的脚本主机。

    Function fncForce32bitCscript()
        Dim strCurrentScriptHost : strCurrentScriptHost  = lcase(wscript.fullname)
        dim strRequiredScriptHost: strRequiredScriptHost = "c:\windows\system32\cscript.exe"
        if fncCheckOS = "X64" Then
            strRequiredScriptHost = "c:\windows\syswow64\cscript.exe"
        end If  
    
        Dim objShell
        Set objShell = CreateObject("WScript.Shell")
        objShell.run "cscript //h:cscript",0,True
    
        If strCurrentScriptHost = strRequiredScriptHost Then
            'no switching to cscript required
        Else
          Dim strArgColl
              strArgColl = " "
              If WScript.Arguments.Count>0 Then
                Dim ArgCollect
                For ArgCollect = 0 To WScript.Arguments.Count-1
                  strArgColl = strArgColl & chr(34) & (WScript.Arguments.Item(ArgCollect)) & chr(34) & " "
                Next
              End If
              'wscript.echo "script will be re-launched with the required script host " & strRequiredScriptHost
              objShell.Run  "cmd /C " & strRequiredScriptHost & " " & WScript.ScriptFullName & " " & strArgColl,1,false
              'Set objShell = Nothing
              'wscript.sleep 3000
              WScript.Quit  
        End If
    End Function
    

    所以把这个电话换成cmd.exe......

    'objShell.Run "cmd /C " & strRequiredScriptHost & " " & WScript.ScriptFullName & " " & strArgColl, 0, false
    

    ...这使它隐藏起来。任务完成。

    objShell.Run strRequiredScriptHost & " " & WScript.ScriptFullName & " " & strArgColl, 0, false
    
    • 1

相关问题

  • 知道任何适用于 Windows 的快速可编写脚本的 ftp 客户端吗?[关闭]

  • 如果 Windows 服务崩溃,如何自动重新启动它?

  • 无法安排任务(访问被拒绝)

  • 物理机重启时自动重启虚拟机(VMWare)

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve