locked
MDT 2012 fails to run command line in TS RRS feed

  • Question

  • I'm trying to run a VBscript (as another user) in my Task Sequence, but it fails. (I'm deploying Windows 7 x64 with the Standard Client Task Sequence-template).

    • When running the script manually, outside the MDT environment, it works flawless.
    • Also creating a custom Task Sequence with only the 'Run Command Line'-step, running my VBS (as a service account), works great!
    • Tried this workaround: Run command line as domain user – Incorrect Function Error. Without success.

    I'm using a 'Run Command Line' step, with this as command line;

    cscript.exe "%deployroot%\scripts\MyScript.vbs"


    The script is copied to the deployment share, in the scripts-folder. I'm sure the syntax is correct, because the Custom Task Sequence does work.

    Error message after deployment:

    Litetouch deployment failed, Return Code = -2147467259 0x80004005 Failed to run the action: Add domain user based on the current computername. Incorrect function. (Error: 00000001; Source: Windows) The execution of the group (State Restore) has failed
     and the execution has been aborted. An action failed. Operation aborted (Error: 80004004; Source: Windows) Failed to run the last action: Add domain user based on the current computername. Execution of task sequence failed. Incorrect function. (Error: 00000001;
     Source: Windows) Task Sequence Engine failed! Code: enExecutionFail Task sequence execution failed with error code 80004005 Error Task Sequence Manager failed to execute task sequence. Code 0x80004005


    smsts.log;

    Failed to run the action: Add domain user based on the current computername. Incorrect function. (Error: 00000001; Source: Windows)
    The execution of the group (State Restore) has failed and the execution has been aborted. An action failed.Operation aborted (Error: 80004004; Source: Windows)
    Failed to run the last action: Add domain user based on the current computername. Execution of task sequence failed.Incorrect function. (Error: 00000001; Source: Windows)
    Task Sequence Engine failed! Code: enExecutionFail
    Task sequence execution failed with error code 80004005
    Error Task Sequence Manager failed to execute task sequence. Code 0x80004005

    .

    Because the scripts works manually and in a custom Task Sequence, I don't understand what I'm doing wrong. Can someone help me out please?








    Tuesday, July 24, 2012 10:43 PM

All replies

  • Can you give us an idea as to what the script is doing? This may help diagnose the problem.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”

    Wednesday, July 25, 2012 12:49 AM
  • The script creates an user in AD (based on the computername of the machine).

    But it doesn't even start; the first test-msgbox isn't showing. When 'm running the script in the TS without the service account, the scripts starts like it should and the test-msgbox is showing. (but ofcourse the user isn't created because the local admin doesn't have permissions in AD).

    ' Create domain user, based on the current computername
    ' Ben De Vriese (ICTinus)
    ' Juli 2012
    	
    	msgbox "TEST"
    
    	Dim strComputerName
    	Dim strPWD
    	
    	Set wshNetwork = WScript.CreateObject( "WScript.Network" )
    	strComputerName = wshNetwork.ComputerName
    	
    	strUsername="user_" & strComputerName
    	msgbox strUsername
    	
    	strPWD=strreverse(strComputerName) & "_resu$"	
    	msgbox strPWD
    
    		Set objDomain = GetObject("LDAP://dc=esense,dc=local")
    		Set objOU = GetObject("LDAP://ou=users,ou=Unmanaged,dc=esense,dc=local")
    		Set objUser = objOU.Create("User", "cn=" & strUsername)
    		objUser.Put "sAMAccountName", strUsername
    		objUser.SetInfo													'write data
    		
    		objUser.userAccountControl = 512								'activate account
    		objUser.pwdLastSet = 0											'reset last pwd change
    		objUser.SetPassword strPWD										'set password to reverse computername + _resu$
    		objUser.SetInfo													'write data
    	
    	Wscript.quit

    Wednesday, July 25, 2012 4:23 AM
  • From smsts.log;

    Start executing an instruciton. Instruction name: Run Command Line AddUserTestPC. Instruction pointer: 64	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Set a global environment variable _SMSTSCurrentActionName=Run Command Line AddUserTestPC	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Set a global environment variable _SMSTSNextInstructionPointer=64	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Set a local default variable PackageID	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Set a local default variable RunAsUser	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Set a local default variable SMSTSRunCommandLineUserName	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Set a local default variable SMSTSRunCommandLineUserPassword	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Set a local default variable LoadProfile	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Set a global environment variable _SMSTSLogPath=C:\Users\ADMINI~1\AppData\Local\Temp\SMSTSLog	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Expand a string: %TOOLROOT%\bddrun.exe /runas cscript.exe %SCRIPTROOT%\_AddUserTestPC.vbs	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Expand a string: 	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Command line for extension .exe is "%1" %*	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Set command line: %TOOLROOT%\bddrun.exe /runas cscript.exe %SCRIPTROOT%\_AddUserTestPC.vbs	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Start executing the command line: %TOOLROOT%\bddrun.exe /runas cscript.exe %SCRIPTROOT%\_AddUserTestPC.vbs	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    !--------------------------------------------------------------------------------------------!	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Expand a string: WinPEandFullOS	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Executing command line: %TOOLROOT%\bddrun.exe /runas cscript.exe %SCRIPTROOT%\_AddUserTestPC.vbs	TSManager	25/07/2012 9:59:05	2824 (0x0B08)
    Process completed with exit code 1	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    !--------------------------------------------------------------------------------------------!	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Failed to run the action: Run Command Line AddUserTestPC. 
    Incorrect function. (Error: 00000001; Source: Windows)	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Sending status message . . .	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Executing in non SMS standalone mode. Ignoring send a task execution status message request	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Set a global environment variable _SMSTSLastActionRetCode=1	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Set a global environment variable _SMSTSLastActionSucceeded=false	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Clear local default environment	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Let the parent group (State Restore) decides whether to continue execution	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    The execution of the group (State Restore) has failed and the execution has been aborted. An action failed.
    Operation aborted (Error: 80004004; Source: Windows)	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Failed to run the last action: Run Command Line AddUserTestPC. Execution of task sequence failed.
    Incorrect function. (Error: 00000001; Source: Windows)	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Sending status message . . .	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Executing in non SMS standalone mode. Ignoring send a task execution status message request	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Execution::enExecutionFail != m_eExecutionResult, HRESULT=80004005 (e:\nts_sms_fre\sms\client\tasksequence\tsmanager\tsmanager.cpp,767)	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Task Sequence Engine failed! Code: enExecutionFail	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    ****************************************************************************	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Task sequence execution failed with error code 80004005	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Cleaning Up. Removing Authenticator	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Cleaning up task sequence folder	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    DeleteFileW(sVolumeIDFile.c_str()), HRESULT=80070002 (e:\nts_sms_fre\sms\framework\tscore\resolvesource.cpp,508)	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Successfully unregistered Task Sequencing Environment COM Interface.	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Command line for extension .exe is "%1" %*	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Set command line: "C:\MININT\Tools\x64\TsProgressUI.exe" /Unregister	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Executing command line: "C:\MININT\Tools\x64\TsProgressUI.exe" /Unregister	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    ==========[ TsProgressUI started in process 2388 ]==========	TsProgressUI	25/07/2012 9:59:06	792 (0x0318)
    Command line: "C:\MININT\Tools\x64\TsProgressUI.exe" /Unregister	TsProgressUI	25/07/2012 9:59:06	792 (0x0318)
    Unregistering COM classes	TsProgressUI	25/07/2012 9:59:06	792 (0x0318)
    Unregistering class objects	TsProgressUI	25/07/2012 9:59:06	792 (0x0318)
    Shutdown complete.	TsProgressUI	25/07/2012 9:59:06	792 (0x0318)
    Process completed with exit code 0	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Successfully unregistered TS Progress UI.	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    g_TSManager.Run(), HRESULT=80004005 (e:\nts_sms_fre\sms\client\tasksequence\tsmanager\tsmanager.cpp,657)	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Error Task Sequence Manager failed to execute task sequence. Code 0x80004005	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Sending error status message	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    In non SMS staqndalone mode.Ignoring SendStatusMessage request	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Finalizing logging from process 2644	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    LOGGING: Setting log directory to "C:\Users\ADMINI~1\AppData\Local\Temp\".	TSManager	25/07/2012 9:59:06	2824 (0x0B08)
    Process completed with exit code 2147500037	TSMBootstrap	25/07/2012 9:59:06	2844 (0x0B1C)
    Exiting with return code 0x80004005	TSMBootstrap	25/07/2012 9:59:06	2844 (0x0B1C)
    

    Wednesday, July 25, 2012 8:28 AM
  • Fixed by connecting to AD and specifying credentials (instead of using MDT's RunAsAnotherUser-option);

    	'CONNECT TO AD ###
    	Set dso = GetObject("LDAP:") 
    	Set objOU = dso.OpenDSObject("LDAP://dc.domain.local/ou=users,ou=Unmanaged,dc=domain,dc=local", "domain\serviceAccount", "pwd", 1) 

    Also enabled CONTINUE ON ERROR in the Run Command Line-step in the Task Sequence where the script runs (Options Tab).

    I also implemented the DeploymentGuys REGDBVersion workaround: Run command line as domain user – Incorrect Function Error (URL in first post).

    Not sure what exaclty fixed it: Credentials in script, Continue On Error in TS and/or the DeploymentGuys fix .. need more testing to figure out.

    Wednesday, July 25, 2012 8:22 PM
  • I have the same exact problem; where you able to solve?  All I am doing is doing oshell.run sscriptdir & "\customscript\isi.cmd"
    • Edited by teanae Friday, September 14, 2012 4:13 PM
    Friday, September 14, 2012 4:12 PM
  • Yes, I was able to launch the VBScript. My explanation in the posts above didn't worked for you? (AFAIK; I used all three workarounds: Credentials in script, Continue On Error in TS and the DeploymentGuys fix). 

    If you need to know something specific, my lab-environment still contains the TS with the VBscript .. I'm happy to provide you the info you want to know.

    Ben

    Saturday, September 15, 2012 5:13 PM
  • I also had this problem when trying to perform a script that would move the computer object from our staging OU to a production OU.  I found that the account I was using in the step was not a member of the Domain Users group in AD.  The user was only a member of one security group which had the correct permissions to the OU's but would still get the incorrrect function error when running the TS.  Once I add the user to the Domain Users group, it ran successfully.

    Martin

    Tuesday, January 8, 2013 10:21 PM