Solved

Problems Calling VBS through MSSQL

Posted on 2011-09-20
4
599 Views
Last Modified: 2012-05-12
Dear Experts,

I’m currently trying to call this VBS through MSSQL using xp_cmdshell.  Works in cmd, and ‘executes’ in SQL – but without actually running the VBS.  The script calls ImageMagick to convert (split) a single multiple page tiff, to multiple single page files.

I’ve tried relocating the VBS to the C:\Windows\system32\ directory, along with all of the following commands to no avail, and I can’t find anything that works on the web.

EXEC master.dbo.xp_cmdshell 'C:\Windows\System32\cscript.exe "C:\tests\convert.VBS" //B', NO_OUTPUT

EXEC master.dbo.xp_cmdshell 'cscript convert.VBS' –-.vbs in system32 directory

EXEC master.dbo.xp_cmdshell '"C:\tests\convert.VBS"'

Open in new window

Here’s the VBS

set img = CreateObject("ImageMagickObject.MagickImage.1")
set fso = CreateObject("Scripting.FileSystemObject")
set files = fso.GetFolder("C:/TESTS").Files
for each file in files
	img.Convert file.name, "C:/TESTS/converted/%d_" & file.name

	'if file.name == ("convert.VBS") then
		'do nothing
	'else
		'fso.deletefile(file.name)
	'end if
next
set files = fso.GetFolder("C:/TESTS/converted").FIles
for each file in files
	wscript.echo file.name
next
WScript.Quit(0)

Open in new window




Thank you, experts!
0
Comment
Question by:robthomas09
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 250 total points
ID: 36569716
You need to use the full path and the startup account for the SQL Server service needs to have access to it.
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 250 total points
ID: 36570497
And if EXEC can't deal with parameters, make a batch file that has
cscript.exe "C:\tests\convert.VBS" //B

and then try calling the batch file:
EXEC master.dbo.xp_cmdshell 'c:\tests\runvbs.bat'

Rob.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 36571155
Good point.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 36571295
I'm not sure if that's the case...it's just a gues...
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question