Link to home
Start Free TrialLog in
Avatar of robthomas09
robthomas09

asked on

Problems Calling VBS through MSSQL

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!
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Good point.
I'm not sure if that's the case...it's just a gues...