Page 1 of 3 123>
Topic Options
#26807 - 2002-08-09 04:02 PM vbs -> Kix
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
What do I need to know about converting vbs to work in the kix world. I have the following script and can shell out and call it but what it I want to include it as kix code? Can this be done?

code:
 Set oConnection = CreateObject("ADODB.Connection")

If WScript.Arguments.Count <> 4 Then
WScript.Echo "Usage: Change.vbs <Server> <SQLLogin> <OldPassword> <NewPassword>"
WScript.Quit 1
End If

oConnection.Open "Provider=SQLOLEDB" & _
";Server=" & WScript.Arguments(0) & _
";User ID=" & WScript.Arguments(1) & _
";Password=" & WScript.Arguments(2)

oConnection.Execute "EXEC sp_password '" & _
WScript.Arguments(2) & "', '" & _
WScript.Arguments(3) & "', '" & _
WScript.Arguments(1) & "'"

For Each oError In oConnection.Errors
strMessage = strMessage & oError.Description & vbCrLf
Next

WScript.Echo strMessage

oConnection.Close

WScript.Quit 0

Thanks
_________________________
Austin Henderson

Top
#26808 - 2002-08-09 04:04 PM Re: vbs -> Kix
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
I should say I intend to take the arguments feature out and just use kix variables in their place.

Thanks
_________________________
Austin Henderson

Top
#26809 - 2002-08-09 04:06 PM Re: vbs -> Kix
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yes, it can be translated int KiXtart code. You might need to change the way it gets the input parameters, though.

Take a look at the following UDF for database connectivity:
DBConnOpen()
DBConnclose()
DBExecuteSQL()
_________________________
There are two types of vessels, submarines and targets.

Top
#26810 - 2002-08-09 04:09 PM Re: vbs -> Kix
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
to turn vbs code to kix. some usual changes:
1)Set -not needed. just use $
Set oConnection = CreateObject("ADODB.Connection")
becomes:
$Connection = CreateObject("ADODB.Connection")

2)WScript.Echo -not needed. just use "blaa"

3)& is just a +

4)WScript.Quit 0 -not needed but you may use exit 0
_________________________
!

download KiXnet

Top
#26811 - 2002-08-09 04:16 PM Re: vbs -> Kix
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
sealopard... using the DBConnOpen udf and a DSN of SQL do you have to declare a database if you are only going to be executing a sp_password command?

Thanks
_________________________
Austin Henderson

Top
#26812 - 2002-08-09 04:18 PM Re: vbs -> Kix
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I don't believe so since you would normally connect to the default database for that specific user (based on the user credentials used).
_________________________
There are two types of vessels, submarines and targets.

Top
#26813 - 2002-08-09 07:04 PM Re: vbs -> Kix
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Great.. thank you all for your help.

Is it possible to build an exe from the kix code?
_________________________
Austin Henderson

Top
#26814 - 2002-08-09 07:11 PM Re: vbs -> Kix
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, there is no kix-compiler.
so no, you can't "build" an exe.

but you can package kix and script in same archive and make it selfexecuting.
_________________________
!

download KiXnet

Top
#26815 - 2002-08-09 07:15 PM Re: vbs -> Kix
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
What I am doing now is having bat file that gives path to kix and script.. is there another way you are stating this is possible?
_________________________
Austin Henderson

Top
#26816 - 2002-08-09 07:50 PM Re: vbs -> Kix
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
I have excellent luck using kixcrypt

Bryce

Top
#26817 - 2002-08-09 10:48 PM Re: vbs -> Kix
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
where can I get it?
_________________________
Austin Henderson

Top
#26818 - 2002-08-09 10:53 PM Re: vbs -> Kix
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You can get it here: http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=2;t=002560
_________________________
There are two types of vessels, submarines and targets.

Top
#26819 - 2002-08-09 10:55 PM Re: vbs -> Kix
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hahaa... [Big Grin]

just click either link.
pick the one which looks nicer [Wink]
_________________________
!

download KiXnet

Top
#26820 - 2002-08-09 11:00 PM Re: vbs -> Kix
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
I got and and started using it.. I also read the post that I was directed to.... this is good stuff... are there any limitations that I shoudl know about? Also I am curious about the idea that was posted to use w32kix to take the command away.. was that ever developed? How about the fact that the kix32.exe file must be in the same directory as the output'd file... can I include in the exe?

Thanks for your support.
_________________________
Austin Henderson

Top
#26821 - 2002-08-09 11:22 PM Re: vbs -> Kix
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
I got both versions... I dont really notice any different in the console-less version other than it has no header information in the console.. it is still opening a console... can anyone comment on that?

Thanks
_________________________
Austin Henderson

Top
#26822 - 2002-08-09 11:27 PM Re: vbs -> Kix
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
all versions up to 4.10 give you console when you do output to console in your script.

4.11 has changed that a little bit.

so, you should read the manual about the differences.
_________________________
!

download KiXnet

Top
#26823 - 2002-08-09 11:30 PM Re: vbs -> Kix
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
I will see what I can find.. I am using 4.0.2 kix32.exe... could this be the issue? I am not outputting to the console in the script that is what I am confused about. I will try to get the newest version and see what I come up with.

Thanks for your sugguestions.
_________________________
Austin Henderson

Top
#26824 - 2002-08-09 11:42 PM Re: vbs -> Kix
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
There must be some differences in the way it executes the code. The new version doesnt run my script as expected. The old version does.
_________________________
Austin Henderson

Top
#26825 - 2002-08-10 12:06 AM Re: vbs -> Kix
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
austin, again kix is like 99.9% backwards compatible.
if you don't find note in manual, then there is nothing changed.
could you post your code.
I'll also check the output thing if you do as you will do it if you get console with 4.02 wkix

cheers,
_________________________
!

download KiXnet

Top
#26826 - 2002-08-10 12:10 AM Re: vbs -> Kix
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Sure thing.. I took much of this code from the board at any rate.. I dl'd the new kix and it is like at the second @error check it doesnt work.. something to do with the $SQLExe = DBExecuteSQL($objConn,$sql,)

Here is the code..

code:
 ;******************************************************************************
;-Author: Austin Henderson
;-Date: 08.05.02
;-Script: Beta Script For Password Sync
;
;-Dependancies: kix32.exe
;******************************************************************************

;Define variables...

;CODING BEGINS
;------------------------------------------------------------------------------
:TOP

CLS
color w+/n
:TOP
$NEWPWD = guipassprompt(1,1) ;Call code to get password
if ingroup ("TMT User") or ingroup ("TMW User")
$ConnDSN = "DRIVER={SQL Server};SERVER=TRINITY;UID=@UserId;PWD=$GUIPassPromptOld;"
$objConn = DBConnOpen($ConnDSN,,)
while @error <> 0
$nul = Messagebox("- CURRENT PASSWORD INCORRECT -", "ERROR",4144)
$NEWPWD = guipassprompt(1,1) ;Call code to get password
$ConnDSN = "DRIVER={SQL Server};SERVER=TRINITY;UID=@UserId;PWD=$GUIPassPromptOld;"
$objConn = DBConnOpen($ConnDSN,,)
loop
$SQL = "sp_password NULL,'$NEWPWD','@UserID'"
$SQLExe = DBExecuteSQL($objConn,$sql,)
if @error <> 0
$nul = Messagebox("- ERROR CONTACT ADMIN -", "ERROR",4144)
else
$nul = Messagebox("- PASSWORD CHANGED -", "ALERT",4160)
endif
$close = DBConnClose($objConn)
endif

if ingroup ("GP User")
$ConnDSN = "DRIVER={SQL Server};SERVER=GATES;UID=@UserId;PWD=$GUIPassPromptOld;"
$objConn = DBConnOpen($ConnDSN,,)
while @error <> 0
$nul = Messagebox("- CURRENT PASSWORD INCORRECT -", "ERROR",4144)
$NEWPWD = guipassprompt(1,1) ;Call code to get password
$ConnDSN = "DRIVER={SQL Server};SERVER=GATES;UID=@UserId;PWD=$GUIPassPromptOld;"
$objConn = DBConnOpen($ConnDSN,,)
loop
$SQL = "sp_password NULL,'$NEWPWD','@UserID'"
$SQLExe = DBExecuteSQL($objConn,$sql,)
if @error <> 0
$nul = Messagebox("- ERROR CONTACT ADMIN -", "ERROR",4144)
else
$nul = Messagebox("- PASSWORD CHANGED -", "ALERT",4160)
endif
$close = DBConnClose($objConn)e($objConn)
endif

;Let the functions begin
;------------------------------------------------------------------------------
Function DBConnOpen($ConnDSN, optional $ConnTimeout, optional $CmdTimeout)
Dim $objConn, $adStateOpen

$adStateOpen=val('&00000001')

if vartype($ConnTimeout)
$ConnTimeout=val($ConnTimeout)
else
$ConnTimeout=15
endif

if vartype($CmdTimeout)
$CmdTimeout=val($CmdTimeout)
else
$CmdTimeout=30
endif

$ConnDSN=trim($ConnDSN)
if not $ConnDSN
exit 87
endif

$objConn = CreateObject("ADODB.Connection")
if @ERROR
exit @ERROR
endif

$objConn.ConnectionTimeout = $ConnTimeout
if @ERROR
exit @ERROR
endif

$objConn.CommandTimeout = $CmdTimeout
if @ERROR
exit @ERROR
endif

$objConn.Open($ConnDSN)
if @ERROR
exit @ERROR
endif

if not $objConn.State=$adStateOpen
$objComm=''
$DBConnOpen=''
exit @ERROR
endif
$DBConnOpen=$objConn

EndFunction

;------------------------------------------------------------------------------
Function DBConnClose($objConn)
Dim $adStateOpen

$adStateOpen = 1

If vartype($objConn)=9
If $objConn.State = $adStateOpen
$objConn.Close()
if @ERROR
exit @ERROR
endif
EndIf
$objConn=''
else
exit 87
endif

$DBConnClose=@ERROR
EndFunction


;------------------------------------------------------------------------------
function DBExecuteSQL($objConn, $sql, optional $cmdType)
dim $cmdCommand, $rsRecordset
dim $adCmdUnspecified, $adCmdText, $adCmdTable, $adCmdStoredProc, $adCmdUnknown, $adCmdFile, $adCmdTableDirect

$adCmdUnspecified = -1
$adCmdText = 1
$adCmdTable = 2
$adCmdStoredProc = 4
$adCmdUnknown = 8
$adCmdFile = 256
$adCmdTableDirect = 512

if vartype($cmdType)
$cmdType=val($cmdType)
else
$cmdType=$adCmdText
endif

if vartype($objConn)<>9 or $sql=''
exit 87
endif

$cmdCommand = CreateObject('ADODB.Command')
if @ERROR
exit @ERROR
endif

$cmdCommand.ActiveConnection = $objConn
if @ERROR
exit @ERROR
endif

$cmdCommand.CommandType = $cmdType
if @ERROR
exit @ERROR
endif

$cmdCommand.CommandText = $sql
if @ERROR
exit @ERROR
endif

$rsRecordset=$cmdCommand.Execute()
$cmdCommand=''
$rsRecordset=''
if @ERROR
exit @ERROR
endif

$DBExecuteSQL=@ERROR

endfunction

;------------------------------------------------------------------------------
function GUIPassPrompt($case, $force, optional $title)
;This is a GUI password Prompt.
; Syntax:
; GUIPassPrompt(Case Sensetive[0/1] | force[0/1] | Optional Title )
; Case Sensetive [0,1]
; 0 = ignore case
; 1 = all password are case sensitive
;
; Force [0,1]
; "0" will not force a password
; "1" will force the user to enter a password
;
; Title(optional) "Your title here"
; Defalut title = "Please enter your password."
; set this option to change it.
;
;Example:
; ;This will show a non case sensetive password prompt with the default title and not forced
; $password = GUIpassprompt(0,0)
;
; ;this is a forced case sensetive password prompt with the title "Enter your password"
; $password = GUIPassPrompt(1,1,"Enter your password")

DIM $title, $case, $top, $left, $height, $Width, $False, $true
DIM $status, $Password1, $password2, $doc, $nul, $html

$password = ""
$top = "100"
$left = "200"
$height = "180"
$width = "275"
$false = 0
$true = -1
If $title = ""
$title = "SQL PASSWORD UTLILTY"
endif

$html = '
<html><head>
<title>$title</title>

<style>
<!---body{ background-color: silver; color: black;font-family: tahoma, arial; font-size:
10pt; margin: 3px "input.tbox { border: lpx black solid;}td { font: 10pt tahoma; }--->
</style></head>

<body scroll=no onresize="window.resizeto(240,120);">

<table align=center>
<form name=frm>
<tr>
<td align=right>Current: </td>
<td colspan=2><input id=password0 type=password value="" class=tbox></td>
</tr>
<tr>
<td align=right>Password: </td>
<td colspan=2><input id=password1 type=password value="" class=tbox></td>
</tr>
<tr>
<td align=right>Confirm: </td>
<td colspan=2><input id=password2 type=password value="" class=tbox></td>
</tr>
<tr>
<td><input id=reset type=button value=" Submit " onclick="frm.status.value=1"><input type=hidden id=status name=status value=0></td>
<td align=right><input id=close type=button value=" Cancel " onclick="frm.status.value=2"></td>
</tr>
</form>
</table></body></html>'

:Closed_Window
$ie = CreateObject("internetexplorer.application")
; Set properties and display form ...
$ie.addressbar = $false
$ie.menubar = $false
$ie.toolbar = $false
$ie.statusbar = $false
$ie.resizable = $false
$ie.top = $top
$ie.left = $left
$ie.height = $height
$ie.width = $width
$ie.visible = $true

$ie.navigate("about:blank")

while $ie.busy <>0 and @error = 0 loop

; Get a handle to the open document ...
$doc = $ie.document
$doc.write($html)
while setfocus("$title") <> 0 loop

$status = $doc.GetElementById("status")
$password0 = $doc.GetElementById("password0")
$password1 = $doc.GetElementById("password1")
$password2 = $doc.GetElementById("password2")

while @error = 0 and $status.value <> ""
select
case $status.value = "1"
;submit was clicked
Select
case $password1.value <> $password2.value
$nul = Messagebox("Passwords do not match", "ERROR",4144)
$password0.value = ""
$password1.value = ""
$password2.value = ""
case $password1.value = "" or $password2.value = ""
$nul = Messagebox("Blank passwords are not allowed", "ERROR",4144)
$password0.value = ""
$password1.value = ""
$password2.value = ""
case $case = 1
if $password1.value == $password2.value
$GUIPassPrompt = $password1.value
$GUIPassPromptOld = $password0.value
$ie.quit()
exit
else
$nul = Messagebox("Passwords do not match", "ERROR",4144)
$password0.value = ""
$password1.value = ""
$password2.value = ""
endif
case $case = 0
if $password1.value = $password2.value
$GUIPassPrompt = lcase($password1.value)
$ie.quit()
exit
else
$nul = Messagebox("Passwords do not match", "ERROR",4144)
$password0.value = ""
$password1.value = ""
$password2.value = ""
endif

endselect

$status.value = 0
case $status.value = "2"
;cancel was clicked
if $force = "1"
$nul = Messagebox("You Must Change your password!", "ERROR",4144)
else
$ie.quit()
exit(1067)
endif
$status.value = 0
endselect
loop
if $force = "1"
$nul = Messagebox("You Must Change your password!", "ERROR",4144)
goto Closed_Window
else
$ie.quit()
exit
endif

endfunction

Also as I stated.. when using wkixcrypt or kixcrypt it pops a console in both new and old kix32.exe. Thank you so much for your help with this.
_________________________
Austin Henderson

Top
Page 1 of 3 123>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 202 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.074 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org