Skip to content

Instantly share code, notes, and snippets.

@MarioBinder
Last active April 3, 2024 09:27
Show Gist options
  • Save MarioBinder/f2d9823f84a6977a5dbfabc9b1bd0916 to your computer and use it in GitHub Desktop.
Save MarioBinder/f2d9823f84a6977a5dbfabc9b1bd0916 to your computer and use it in GitHub Desktop.
execute job from database
Use Master
GO
EXEC master.dbo.sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
EXEC master.dbo.sp_configure 'xp_cmdshell', 1
RECONFIGURE WITH OVERRIDE
GO
--EXEC sp_xp_cmdshell_proxy_account 'DOMAIN-DOM\depl-mb', 'PASSWORD';
--GRANT exec ON xp_cmdshell TO [wdmm-doMm\depl-mb];
EXEC AS User = 'wdmm-dom\depl-mb'
GO
declare @myparams as varchar(255)
declare @sql as varchar(255)
set @myparams='test'
set @sql = '\\hw-srv-job3\Services\PWTest\PANIDEnrichment.exe "sendAddressDataToIveBoard ' + @myparams + '"'
EXEC xp_cmdshell 'whoami'
EXEC xp_cmdshell @sql
REVERT; -- set back to nt service\mssqlserver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment