With thanks to Tony I've got Winbatch calling a PowerShell script to delete a bunch of bloatware (3dbuilder, bingfinance, etc.. ) The code that works is below. This will ONLY work if I compile the script as x86 - if I compile it as x64 it throws a COM/CLR exception System.Management.Automation Object reference not set to an instance of an object. It only happens on an x64 compile - x86 breezes right on through. What am doing wrong?
cRun=FileGet(cScript)
ObjectClrOption("use", "System.Management.Automation,version=1.0.0.0,publicKeyToken=31bf3856ad364e35,culture=neutral")
objAutoPs = ObjectClrNew("System.Management.Automation.PowerShell")
oPshell = objAutoPs.Create()
oScope = ObjectType("BOOL",@TRUE)
oPshell.AddScript(cRun,oScope)
objAsync = oPshell.BeginInvoke()
oPShell.EndInvoke(objAsync)
oPshell.Dispose()
oPshell=0