Solved

Problems Calling VBS through MSSQL

Posted on 2011-09-20
4
602 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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

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…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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