serr57
(Fresh Scripter)
2009-11-27 02:23 PM
change ip address

Hello

I have some remote users that sometimes need to change their IP Address.
I would like to create a script like this:

messagebox "What is the IP given by your hotel" ----> OK for me

A popup arrive and the user can give this ip address. ----> NOT OK for me

After Registry modification with this parameters ----> OK for me

Somebody has an idea?

Many thanks

Eric


LonkeroAdministrator
(KiX Master Guru)
2009-11-27 06:57 PM
Re: change ip address

so, you have everything set except the popup asking for the IP?

serr57
(Fresh Scripter)
2009-11-28 07:14 AM
Re: change ip address

Excactly
I don't know how to have a popup that allow user to enter his given IP

That's it


Mart
(KiX Supporter)
2009-11-29 05:39 PM
Re: change ip address

You can use the Gets command for this.
If you want a nice popup window then KiXforms might be an option.
KiXforms website

 Code:
Break on

?"Please enter your IP address: "
Gets $rc

? $rc

Sleep 5 


Glenn BarnasAdministrator
(KiX Supporter)
2009-11-30 11:56 AM
Re: change ip address

Yes, but be aware that using Kixforms will require that the DLL be registered on every computer. Maybe not so bad if it's just for a handful of laptops..

Glenn


Arend_
(MM club member)
2009-11-30 02:45 PM
Re: change ip address

Sorry, deleted my post, was against my principles :-)

Mart
(KiX Supporter)
2009-11-30 02:58 PM
Re: change ip address

Thank god for RSS feeds \:\)
Suggesting VBS......shame on you Arend


serr57
(Fresh Scripter)
2009-11-30 05:05 PM
Re: change ip address

Many thanks for your answers guys...

I have already create a script who will change network configuration (via netsh command).

But I would that user receives a popup to entrer his provider IP (if not DHCP, and that this IP is wrotten inside my netsh script, afterwards this netsh script is excecuted.

I hope this can help you

Eric


Glenn BarnasAdministrator
(KiX Supporter)
2009-11-30 07:09 PM
Re: change ip address

There is no native method in Kix - you'll need to use KixForms, which requires the registration of a DLL on every computer, or use some built-in capability such as that language that contains a "V" and a "B", as Arend was struggling to say.

Maybe a future feature request?? PromptBox() - similar syntax to MessageBox(), but instead of buttons, it has a one-line input field and it returns that string. Just an OK/Cancel button, where Enter/OK return the string, and Cancel retuns nothing.

Glenn


Arend_
(MM club member)
2009-11-30 08:44 PM
Re: change ip address

Glenn, just InputBox() like the "V" program has will do ;\)

 Originally Posted By: Mart
Thank god for RSS feeds \:\)
Suggesting VBS......shame on you Arend

Yeah I know, sometimes I'm too eager to help


Glenn BarnasAdministrator
(KiX Supporter)
2009-12-01 01:13 AM
Re: change ip address

 Originally Posted By: apronk
Glenn, just InputBox() like the "V" program has will do ;\)
This assumes I have knowledge of such "V" program! \:D

I'll take your word for it, but you get the idea - a simple GUI box to prompt for and accept a line of input text.

Glenn

PS - I only use VBS on the web server, and even there, usually use it to feed Kix scripts on the back end. No need for popup dialogs there.. ;\)


AllenAdministrator
(KiX Supporter)
2009-12-01 03:12 AM
Re: change ip address

Pay no attention to how it gets done... just that it does


$value=inputbox("Type Something")
? $value


Function InputBox($Prompt,optional $Title, optional $defaultValue)
Dim $output,$ffh,$rc,$tmpvbs
$tmpvbs="%temp%\inputbox.vbs"
$output="%temp%\inputbox.tmp"
$ffh=freefilehandle()
if open($ffh,$tmpvbs,5)=0
$rc=writeline($ffh,'wscript.echo Inputbox("' + $prompt + '","' + $title + '","' + $defaultvalue + '")' + @CRLF)
$rc=close($ffh)
shell '%comspec% /c cscript "' + $tmpvbs + '" //nologo >"' + $output +'"'
if open($ffh,$output)=0 $inputbox=readline($ffh) $rc=close($ffh) endif
if exist($tmpvbs) del $tmpvbs endif
if exist($output) del $output endif
endif
Endfunction


Richard H.Administrator
(KiX Supporter)
2009-12-01 09:15 AM
Re: change ip address

I think we can simplify that a bit:
 Code:
$IP=InputBox("Enter IP Address")
$=MessageBox("You entered: '"+$IP+"'","Result")

Function InputBox($sPrompt,Optional $sTitle,$sDefaultValue)
    Dim $sc, $result
    $sc = CreateObject("ScriptControl")
    $sc.Language = "vbscript"
    $result = $sc.Eval('Inputbox("' + $sPrompt + '","' + $sTitle + '","' + $sDefaultValue + '")')
    $sc = 0
    $InputBox = $result
EndFunction


Glenn BarnasAdministrator
(KiX Supporter)
2009-12-01 12:06 PM
Re: change ip address

Sweet, guys!

With the MessageBox in Richard's example, the result looks just as annoying as if it were written in wscript! \:D (sorry, I've dealt with too many poorly written wscripts that output 100+ messages, one msgbox at a time, and do so in such a way that you can't terminate the process.)

Still, I'll be adding this to the UDF library for those special situations, and pretend it has nothing to do with that "V" thingy.. ;\)

Glenn


AllenAdministrator
(KiX Supporter)
2009-12-01 03:00 PM
Re: change ip address

"ScriptControl" - Where does he find all these wonderful toys? (Spoken like Joker in the first Batman movie)

That's a new one to me. On my list to find out more.


Richard H.Administrator
(KiX Supporter)
2009-12-01 04:12 PM
Re: change ip address

 Originally Posted By: Allen
"ScriptControl" - Where does he find all these wonderful toys? (Spoken like Joker in the first Batman movie)

That's a new one to me. On my list to find out more.


Found right here on this board \:\)

It came as a surprise to me too when it appeared recently in this post: http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=8&Number=196767


AllenAdministrator
(KiX Supporter)
2009-12-01 04:27 PM
Re: change ip address

I saw that thread, but completely missed what/how it was working. This is a neat idea. Definitely keeping this option open for other things. Glad you saw it.

MSDN Documentation: http://msdn.microsoft.com/en-us/library/aa227413%28VS.60%29.aspx

Based on a few searches .language is supposed to default to vbscript but removing that line breaks the script.


A little more cleanup
 Code:
Function InputBox($sPrompt,Optional $sTitle,$sDefaultValue)
    Dim $sc
    $sc = CreateObject("ScriptControl")
    $sc.language = "VBScript"
    $inputbox = $sc.Eval('Inputbox("' + $sPrompt + '","' + $sTitle + '","' + $sDefaultValue + '")')
EndFunction


serr57
(Fresh Scripter)
2009-12-02 11:04 AM
Re: change ip address

Hi everybody

Many thanks for all your answer.
Sorry for the delay of mine.

As I have seen, a suggestion is to use VBS, but I would like to stay with Kix.
I will try to use inputbox from kixforms.
It is not a problem for me to install dlls (autoIt)

I will give feed back to you when I find the time to test it

Many thanks again


Eric


Richard H.Administrator
(KiX Supporter)
2009-12-02 12:12 PM
Re: change ip address

The InputBox() UDF posted above can be used directly in KiXtart, it just borrows the function from VBS.

Arend_
(MM club member)
2009-12-10 09:19 PM
Re: change ip address

 Originally Posted By: Allen
"ScriptControl" - Where does he find all these wonderful toys? (Spoken like Joker in the first Batman movie)

That's a new one to me. On my list to find out more.

What Allen said!
ScriptControl... Why haven't I found this one before!!!!


Arend_
(MM club member)
2009-12-10 09:53 PM
Re: change ip address

In that fashion, at long last:
 Code:
Function IsNumeric($strInput)
  Dim $sc, $rc
  $sc = CreateObject("ScriptControl")
  $sc.Language = "VBScript"
  $rc=$sc.Eval('IsNumeric("'+$strInput+'")')
  If $rc = -1
    $IsNumeric = 1
  Else
    $IsNumeric = 0
  EndIf
EndFunction


Mart
(KiX Supporter)
2009-12-11 10:00 AM
Re: change ip address

 Originally Posted By: Richard H.
The InputBox() UDF posted above can be used directly in KiXtart, it just borrows the function from VBS.

I posted it in the UDF section. This is too useful to get "lost" in the post history. At least now it is easy to find. Thanks Richard and Allen for providing the code.
UDF Library » InputBox() - Displays an inputpox and gets the result