BEGIN TRY
EXEC xp_cmdshell "net use Z: \\10.44.111.124\dpsshare Demo@123 /user:balamuralirc /persistent:yes"
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() AS ErrorNumber
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine
,ERROR_MESSAGE() AS ErrorMessage;
END CATCH
While using this above try catch it's not working is there any other way to achieve this.