How to: Execute DOS commands from T-SQL

Discus and support How to: Execute DOS commands from T-SQL in Windows 10 Tutorials to solve the problem; Sometimes you might have the need to execute a copy, delete or run a batch file from a stored procedure. This can be done by using the xp_cmdshell and... Discussion in 'Windows 10 Tutorials' started by Noel, Jun 21, 2018.

  1. Noel New Member

    How to: Execute DOS commands from T-SQL


    Sometimes you might have the need to execute a copy, delete or run a batch file from a stored procedure. This can be done by using the xp_cmdshell and execute your command line.

    This can be done as below

    EXECUTE master..xp_cmdshell 'copy c:\test.txt c:\test1.txt'

    You can run it using parameters as below

    DECLARE @sql VARCHAR(200)
    SET @sql = 'copy c:\test.txt c:\test1.txt'
    EXECUTE master..xp_cmdshell @sql

    If you are running the xp_cmdshell and get the error "SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server." Follow the code below to enable the feature.

    EXEC sp_configure 'show advanced options', 1;
    GO
    RECONFIGURE;
    GO
    EXEC sp_configure 'xp_cmdshell', 1;
    GO
    RECONFIGURE;
    GO

    (32)

    read more...
     
  2. Brink Win User

    SQL Server Guidance against speculative execution vulnerabilities


    Source: https://support.microsoft.com/en-us/...for-sql-server
     
    Brink, Jun 21, 2018
    #2
  3. sccm_learner Win User
    Execute a command from SCCM Task sequence step "Run a Command line"

    Hi,

    Thanks for your suggestion.

    That will work indeed, however I need to run it from the SCCM Task Sequence's Run Command Line Step and I am not able to figure out how to do that.

    Can we change line while executing command from SCCM Task Sequence's Run Command Line Step?

    Regards
     
    sccm_learner, Jun 21, 2018
    #3
  4. AmosMacharia Kamau Win User

    How to: Execute DOS commands from T-SQL

    SQL Error

    Am trying to reinstall SQL express and am getting below Error message.

    Error 27506, Error executing SQL script CreateDB. Line 27. CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (1802)
     
    AmosMacharia Kamau, Jun 21, 2018
    #4
Thema:

How to: Execute DOS commands from T-SQL

Loading...
  1. How to: Execute DOS commands from T-SQL - Similar Threads - Execute DOS commands

  2. How do I turn off "Antimalware Service Executable"?

    in AntiVirus, Firewalls and System Security
    How do I turn off "Antimalware Service Executable"?: It's using memory, disk and CPU power for days now and it's making my computer run very slow. Even opening the Explorer takes about 15 seconds. What can I do about it? Here is an image from the task manager: [ATTACH]...
  3. how to stop antimalware service executable

    in Windows 10 Customization
    how to stop antimalware service executable: hloo.i want to stop anti malware serviceexecutable in my pc.necause it using lot of memory and disk space.therby it making my computer very slow.pls provide steps to stop it or close it.while im trying to stop it in task manager,it shows as access is denied....
  4. How to manage App execution aliases on Windows 10

    in Windows 10 News
    How to manage App execution aliases on Windows 10: [ATTACH] In Windows 10, we can run many apps from Command Prompt using their alias. Eg. The default alias to open Notepad through Command Prompt is notepad.exe. Simply type it, and press Enter and the Notepad application would open. The alias [...] This post How to manage...
  5. Fix: Cannot run Executables with parameters using PowerShell

    in Windows 10 Tutorials
    Fix: Cannot run Executables with parameters using PowerShell: When running a command in-line PowerShell with parameters usually you would do this like & "ipconfig.exe /all". When you run it like that you will get the error saying that it is not recognized. & : The term 'ipconfig.exe /all' is not recognized as the name of a cmdlet,...
  6. autoclose cmd after execution

    in Windows 10 Support
    autoclose cmd after execution: Hello, i need to autoclose cmd, after execution. I changed dword 32 value in regedit under HKEY_CLASSES_ROOT\batfile\shell\open\command to: "cmd.exe /k "%1" %*" Now it won't autoclose, i needed it to see error message and now i can't google default value. Thanks for help....
  7. CVE-2018-8245 Microsoft Publisher Remote Code Execution Vulnerability

    in Windows 10 News
    CVE-2018-8245 Microsoft Publisher Remote Code Execution Vulnerability: A remote code execution vulnerability exists when Microsoft Publisher fails to utilize features that lock down the Local Machine zone when instantiating OLE objects. An attacker who successfully exploited the vulnerability could force arbitrary code to be executed in the...
  8. McAfee discovers code execution vulnerability using Microsoft’s Cortana

    in Windows 10 News
    McAfee discovers code execution vulnerability using Microsoft’s Cortana: Microsoft has improved the search feature in Windows 10 with Cortana digital assistant, and it’s now easier to find the information that you’re looking for straight from Cortana with simple voice command. The talented security researchers at McAfee discovered a code execution...
  9. Surface Guidance for speculative execution side-channel vulnerability

    in Windows 10 News
    Surface Guidance for speculative execution side-channel vulnerability: Surface Guidance to protect against speculative execution side-channel vulnerabilities Applies to: Surface Pro 4, Surface Book, Surface Studio, Surface Pro (latest), Surface Laptop, Surface Pro with LTE Advanced, Surface Book 2 - 13 inch, Surface Book 2 - 15 inch...
  10. New Speculative Execution Side-Channel Vunerability (Variant 4)

    in Windows 10 News
    New Speculative Execution Side-Channel Vunerability (Variant 4): Addressing New Research for Side-Channel Analysis Details and Mitigation Information for Variant 4 By Leslie Culbertson Following Google Project Zero’s (GPZ)* disclosure of speculative execution-based side-channel analysis methods in January, Intel has continued working...