m3_del Posted March 10, 2008 Share Posted March 10, 2008 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 ExplicitDim objWMIService, objProcess, strUE, strTags, strSTagDim strShell, objProgram, strComputer, strScanState, strLoadStateDim strUser, strServer, strInput, strUSMT, strUI, strExeDim objStartup, intProcessID, objConfig, intReturn'strServer = " \\FQDN\tempxfer$\" 'Keep the space in frontstrServer = " c:\USMT" 'Delete this line when not testing locallystrScanState = 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 frontstrSTag = " /targetxp" 'Keep the space in the frontstrUE = " /ue:*\*" 'Keep the space in the frontDostrUser = (InputBox("Input the AD name of the User to migrate","User Name"))If strUser <> "" ThenstrInput = TrueEnd IfLoop until strInput = True'strUI = " /ui:" & chr(34) & "faa\" & strUser & chr(34)strUI = " /ui:" & strUser 'Delete This Line when not using with local accountsstrInput = ""DostrComputer = (InputBox("Input the Computer DNS Name","Computer Name"))If strComputer <> "" ThenstrInput = TrueEnd IfLoop until strInput = TruestrInput = ""DostrUSMT = (InputBox("Type ""Scan"" for ScanState and ""load"" for LoadState","USMT"))If strUSMT <> "" ThenstrInput = TrueEnd IfLoop until strInput = TrueSelect Case strUSMTCase "scan" 'Build the command strExe = Chr(34) & strScanState & chr(34) & strServer & strUser & chr(34) & strSTag & strTags & Chr(34) runUSMTCase "load" 'Build the command strExe = strLoadState & chr(34) & strServer & strUser & chr(34) & strTags & _ strUE & strUI runUSMTCase Else MsgBox = ("You did not enter a correct option") WScript.QuitEnd SelectSub runUSMTset objWMIService = getobject("winmgmts://"& strComputer & "/root/cimv2")set objStartup = objWMIService.Get("Win32_ProcessStartup")Set objConfig = objStartup.SpawnInstance_objConfig.ShowWindow = 0objConfig.PriorityClass = 32set objProcess = objWMIService.Get("Win32_Process")intReturn = objProcess.Create(strExe, Null, objConfig, intProcessID)'Error CheckingSelect 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 SelectEnd Sub Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now