Solved

Problems Calling VBS through MSSQL

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now