Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Running HTA with elevated permissions sporadically gets "access denied"

$
0
0

I am writing an HTA with VBScript that will fire off at the end of a new image provisioning process.  The script will do actions such as; rename the computer, change the OU and set the computer description. 

The computer is joined to the domain through the unattend file.  After sysprep has done its magic, the computer is rebooted and autologged in with a domain account that has permissions to make the required AD changes and is a member of a group that is in the local admin group.  There is a registry update that happens as a provisioning action to allow HTA's to be run as an administrator.  The last provisioning action is to kick of a script that invokes the HTA as an administrator.

The HTA will fire up nicely, but will give access errors in the subs that perform the AD actions.  If I immediately reboot the computer, it may or may not give the access errors.  I have added a provisioning action to perform another reboot before the HTA kicks off and have the same results.  The code works fine on a machine that has been rebooted several times, but has worked infrequently in the intended process.

I am using the ADSystemInfo object to perform the modifications on the computer account:

Set objSysInfo = CreateObject("ADSystemInfo")
 strComputerDN = objSysInfo.ComputerName
 
 strTargetOU = ouChooser.value & ",OU={OU},DC={Domain},DC=COM"
 
 Set objNewOU = GetObject("LDAP://OU=" & strTargetOU)
 Set objMoveComputer = objNewOU.MoveHere _
  ("LDAP://" & strComputerDN, "cn=" & txtComputerName.value)

When it fails, it fails on the objNewOU.MoveHere action.  Any idea why this will not work consistently?

Thanks for your help. 


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>