ricky Posted January 22, 2014 Posted January 22, 2014 Hello, I have a command line to execute in a dos prompt, but my command line as a quote and double-quote, how can I execute it? Line : osql -E -S .SQLEXPRESS -h-1 -Q "SET NOCOUNT ON; SELECT 'Version=', CONVERT(NVARCHAR,SERVERPROPERTY('productversion'))" My function to execute the command line : Func DosCommand($command) Local $foo, $line, $temp $foo = Run(@ComSpec & " /c " & $command, @ScriptDir, @SW_HIDE, 2); $STDOUT_CHILD = 2 De Constants.au3 While 1 $line = StdoutRead($foo) If @error Then ExitLoop If $line <> "" Then $temp &= _OEMToAnsi($line) WEnd Return $temp EndFunc ;==>DosCommand Func _OEMToAnsi($sOEM) ; http://autoitscript.fr/forum/viewtopic.php?f=21&t=4108&hilit=conversion+OEM+ANSI Local $sAnsi Local $a_AnsiFName = DllCall('user32.dll', 'Int', 'OemToChar', 'str', $sOEM, 'str', '') If @error = 0 Then $sAnsi = $a_AnsiFName[2] Return $sAnsi EndFunc ;==>_OEMToAnsi Thanks for your help
michaelslamet Posted January 22, 2014 Posted January 22, 2014 (edited) $command = 'osql -E -S .\SQLEXPRESS -h-1 -Q "SET NOCOUNT ON; SELECT ' & "'Version=', CONVERT(NVARCHAR,SERVERPROPERTY('productversion'))" & '"' Edit: too many ' char Edited January 22, 2014 by michaelslamet
ricky Posted January 22, 2014 Author Posted January 22, 2014 (edited) Hello, thanks, in first test it doesn't work because a quote before Version is not necssary, working line : $command = 'osql -E -S .\SQLEXPRESS -h-1 -Q "SET NOCOUNT ON; SELECT ' & "'Version=', CONVERT(NVARCHAR,SERVERPROPERTY('productversion'))" & '"' Thanks a lot! Edited January 22, 2014 by ricky03
michaelslamet Posted January 22, 2014 Posted January 22, 2014 Hello, no, doesn't work! Sorry that I type too much ' char. Please try the edited post above
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