Jump to content

Help Automating Remote USMT


Recommended Posts

Hi, if anyone can help out, it would be much appreciated. I am trying to have my script initiate either scan or loadstate on a remote machine. I think I am close now, but when I run the create method it returns the "cannot find path" error. I am not sure why this is happening. He is the script

'AutomateUSMT.vbs
'Script to automate USMT commands
'Author: Steve Stern
'Modified Last: Craig Smith
'Updated: 3-07-2008
'
'ToDo
'Change the UI
'Validate User profile exists
'Validate USMT is there (maybe automatically move the needed files there)
'Verify PC is Turned on and able to be reached (Ping?)
'Let Admin know when process finishes
'Auto start loadstate on new machine when scanstate finishes
'
'---------------------------------------------

Option Explicit
Dim objWMIService, objProcess, strUE, strTags, strSTag
Dim strShell, objProgram, strComputer, strScanState, strLoadState
Dim strUser, strServer, strInput, strUSMT, strUI, strExe
Dim objStartup, intProcessID, objConfig, intReturn

'strServer = " \\FQDN\tempxfer$\" 'Keep the space in front
strServer = " c:\USMT" 'Delete this line when not testing locally
strScanState = Chr(34) & "c:\program files\USMT301\ScanState.exe" & Chr(34)
strLoadState = Chr(34) & "%programfiles%\USMT301\LoadState.exe" & Chr(34)
strTags = " /i:migapp.xml /i:migsys.xml /i:miguser.xml /c" 'Keep the Space in the front
strSTag = " /targetxp" 'Keep the space in the front
strUE = " /ue:*\*" 'Keep the space in the front

Do
strUser = (InputBox("Input the AD name of the User to migrate","User Name"))
If strUser <> "" Then
strInput = True
End If
Loop until strInput = True
'strUI = " /ui:" & chr(34) & "faa\" & strUser & chr(34)
strUI = " /ui:" & strUser 'Delete This Line when not using with local accounts
strInput = ""

Do
strComputer = (InputBox("Input the Computer DNS Name","Computer Name"))
If strComputer <> "" Then
strInput = True
End If
Loop until strInput = True
strInput = ""
Do
strUSMT = (InputBox("Type ""Scan"" for ScanState and ""load"" for LoadState","USMT"))
If strUSMT <> "" Then
strInput = True
End If
Loop until strInput = True

Select Case strUSMT
Case "scan"
'Build the command
strExe = Chr(34) & strScanState & chr(34) & strServer & strUser & chr(34) & strSTag & strTags & Chr(34)
runUSMT
Case "load"
'Build the command
strExe = strLoadState & chr(34) & strServer & strUser & chr(34) & strTags & _
strUE & strUI
runUSMT
Case Else
MsgBox = ("You did not enter a correct option")
WScript.Quit
End Select



Sub runUSMT
set objWMIService = getobject("winmgmts://"& strComputer & "/root/cimv2")
set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = 0
objConfig.PriorityClass = 32
set objProcess = objWMIService.Get("Win32_Process")
intReturn = objProcess.Create(strExe, Null, objConfig, intProcessID)
'Error Checking
Select Case intReturn
Case 0
WScript.echo "Process Started Successfully. Process ID: " _
& intProcessID
Case 2
WScript.echo "Access is Denied"
Case 3
WScript.echo "Insufficient Privilege"
Case 8
WScript.echo "Unknown Failure"
Case 9
WScript.echo "Path Not Found"
Case 21
WScript.echo "Invalid Parameter"
Case Else
Wscript.echo "Something went horribly wrong"
End Select
End Sub

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...