All I want to do is run a vbscript that will add the tech support distribution group into the local admin group.  It seems like the vbscript never executes.  The command line i use is the name of my vbs file (addadmingroup.vbs).

Do you know if i'm doing this correctly?  The vbscript works when executed manually.  I was not able to find a solution for this as a batch command.  I'm more familiar with vbscript too.   Any help would be appreciated.



Answer Summary:
0 Comments   [ - ] Hide Comments


Please log in to comment

Community Chosen Answer



Is the tech support group a domain group? Is your script ran after it joins the domain?

Answered 08/17/2012 by: dugullett
Red Belt

  • this is a domain group. I have the task after the "join domain" task.
    • Is there a reboot between join domain and this script?
  • Hmm, there's supposed to be but it doesn't work with our Windows 7 image. We're using the Join Domain script from Kace. Should I put in a manual reboot post installation task after the "rename and join domain" task?
  • now that you got my brain working a little, i was thinking of modifying the "Rename and Join Domain" job itself to include the adding of the domin group. that way I know it would be rebooted.
    • I'm not sure if that would be the problem or not. It would be worth a shot though. We use this for tasks that require a reboot. I would join the domain and after a reboot run your script.

  • I'm now able to reboot the pc during the sysprep portion thanks to the tool you showed me. I can't figure out for the life of me to execute the vbscript after the pc is on the domain. I"m using the vbscript

    Dim WshNetowrk, objGroup, strComputer
    strComputer = "."
    On Error Resume Next
    Set WshNetwork = CreateObject("WScript.Network")
    Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
    objGroup.Add "WinNT://Domain/Tech Support"

    I tried using the cscript.exe and just running the script by calling the path of the vbs file.

    Any other suggestions?

    • One thing I did notice is the script did not work for me until I opened a CMD prompt as admin and called the VBscript. Even though I am an admin on my machine it would not work. Try this and see if it will work for you. This will elevate to run as admin.

      If WScript.Arguments.Named.Exists("elevated") = False Then
      'Launch the script again as administrator
      CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ /elevated", "", "runas", 1
      'Change the working directory from the system32 folder back to the script's folder.
      Set oShell = CreateObject("WScript.Shell")
      oShell.CurrentDirectory = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
      End If
      Dim WshNetowrk, objGroup, strComputer
      strComputer = "."
      On Error Resume Next
      Set WshNetwork = CreateObject("WScript.Network")
      Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
      objGroup.Add "WinNT://Domain/Tech Support"
  • Use Autologon as an admin and call your script as a run once

    start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v AutoAdminLogon /d 1 /f
    start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v AutoLogonCount /t REG_DWORD /d 1 /f
    start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v DefaultDomainName /d tmccacad /f
    start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v DefaultUserName /d installer /f
    start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" /v DefaultPassWord /d ************** /f
    start /wait reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v RunMyScript /d "cscript c:\path\tovbs\myfile.vbs"
    shutdown -r -t 1
Please log in to comment
Answer this question or Comment on this question for clarity



are you using   -    cscript addadmingroup.vbs (you may need to spec full path to vbs file)?

Answered 08/17/2012 by: SMal.tmcc
Red Belt

  • you can also use something like "net localgroup administrators domain\tech_support_distribution /add" as an admin
  • i tried that but there's a space between tech support so I get an error message. "there is no such global user or group admins:. I tried to put quotes but got another error message.
  • I'm actually not putting cscript there. I wasn't sure if i was supposed to. I can try that out. I would use the batch script but I cant seem to get it to work with the space.
  • put quotes around the "domain\group"
Please log in to comment