Solved

Problems Calling VBS through MSSQL

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 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