[Windows] Help needed script will not run.

Come up with a useful post-processing script? Share it here!

[Windows] Help needed script will not run.

Postby relman » September 30th, 2008, 3:48 am

Hi everyone, I am hoping someone can help me. I Have written a VBS script which takes command line arguments and then uses these as the values for an SQL insert statement. Running this from command prompt as; cscript sabnzbd.vbs one two three four  will then use the values one, two, three, four. So with this in mind a made a text file which says
Code: Select all
cscript C:\xsabnzbd.vbs %4 %3 %6 %1


However when I run this script it just hangs and in the history says "running script c:\sabnzbd.txt" and never works.  Has anyone got any ideas what I am doing wrong.

Here is the VBS
Code: Select all
Dim OdbcDSN
Dim connect, sql, resultSet

strNewzbinID = WScript.Arguments.Item(0)
strItemName = WScript.Arguments.Item(1)
strNewsGroup = WScript.Arguments.Item(2)
strFile_path = WScript.Arguments.Item(3)

OdbcDSN = "DSN=relnet;UID=dba;PWD=sql"
Set connect = CreateObject("ADODB.Connection")
connect.Open OdbcDSN

sql="INSERT INTO tvshow (tvshow_ref, show_name, file_path, Groups) VALUES ('" & strNewzbinID & "','"  & strItemName & "', '" & strFile_path & "', '" & strNewsGroup & "');commit"

Set resultSet = connect.Execute(sql)
On Error Resume Next
resultSet.MoveFirst


resultSet.Close

connect.Close
Set connect = Nothing

WScript.Quit(0)


]
relman
Release Testers
Release Testers
 
Posts: 53
Joined: September 30th, 2008, 3:42 am

Re: [Windows] Help needed script will not run.

Postby shypike » September 30th, 2008, 4:48 am

Don't tell me you named your script "c:\sabnzbd.txt"  :D

A command script should have a CMD extension, so "c:\sabnzbd.cmd".
Otherwise Windows won't know what to do with it.
If you're lucky it will start notepad.
User avatar
shypike
Administrator
Administrator
 
Posts: 16546
Joined: January 18th, 2008, 1:49 pm

Re: [Windows] Help needed script will not run.

Postby relman » September 30th, 2008, 10:49 am

Sadly you were correct. I feel so stupid  :-[ . The script is now working correctly. Cheers!!!  :D
relman
Release Testers
Release Testers
 
Posts: 53
Joined: September 30th, 2008, 3:42 am


Return to Post-Processing Scripts