0

我有一个我正在尝试运行的脚本,它将获取 IP 地址和计算机名称并弹出他们的默认邮件客户端。我不知道如何让邮件获取变量。任何帮助将不胜感激!

    Set objShell = CreateObject("Wscript.Shell") 

    Set objEnv = objShell.Environment("Process") 
    strComputer = objEnv("COMPUTERNAME") 
    strUser = "Scanner.User" 
    strPass = "SomePassword" 

    Set colAccounts = GetObject("WinNT://" & strComputer & ",computer") 

    Set objUser = colAccounts.Create("user", strUser) 

    objUser.SetPassword strPass 

    Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000 
    objPasswordExpirationFlag = ADS_UF_DONT_EXPIRE_PASSWD 
    objUser.Put "userFlags", objPasswordExpirationFlag 

    objUser.SetInfo 

    Set Group = GetObject("WinNT://" & strComputer & "/Administrators,group") 
    Group.Add(objUser.ADspath) 

    temp = "select IPAddress from Win32_NetworkAdapterConfiguration "& _ 
    "where IPEnabled=TRUE" 

    temp2 = "winmgmts:{impersonationLevel=impersonate}" 

    set IPConfigSet = GetObject(temp2).ExecQuery(temp) 

    for each IPConfig in IPConfigSet 
     if Not IsNull(IPConfig.IPAddress) then 
        for i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress) 

            objShell.Run("mailto:MyEmail@address.com&subject=strComputer&body=IPConfig.IPAddress(i)") 
           Msgbox IPConfig.IPAddress(i) 
        next 
     end if 
    next 
4

1 回答 1

2

您需要使用 & 符号(VBScript 的连接运算符)来生成您的 mailto URI。

objShell.Run("mailto:MyEmail@address.com&subject=" & strComputer & "&body=" & IPConfig.IPAddress(i))
于 2013-08-13T16:26:18.370 回答