Page 1 of 2 12>
Topic Options
#196855 - 2009-11-27 02:23 PM change ip address
serr57 Offline
Fresh Scripter

Registered: 2008-11-10
Posts: 18
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

Top
#196867 - 2009-11-27 06:57 PM Re: change ip address [Re: serr57]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, you have everything set except the popup asking for the IP?
_________________________
!

download KiXnet

Top
#196869 - 2009-11-28 07:14 AM Re: change ip address [Re: Lonkero]
serr57 Offline
Fresh Scripter

Registered: 2008-11-10
Posts: 18
Excactly
I don't know how to have a popup that allow user to enter his given IP

That's it

Top
#196872 - 2009-11-29 05:39 PM Re: change ip address [Re: serr57]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
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 
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#196874 - 2009-11-30 11:56 AM Re: change ip address [Re: Mart]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
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
_________________________
Actually I am a Rocket Scientist! \:D

Top
#196875 - 2009-11-30 02:45 PM Re: change ip address [Re: Glenn Barnas]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
Sorry, deleted my post, was against my principles :-)

Edited by apronk (2009-11-30 02:49 PM)

Top
#196876 - 2009-11-30 02:58 PM Re: change ip address [Re: Arend_]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Thank god for RSS feeds \:\)
Suggesting VBS......shame on you Arend
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#196879 - 2009-11-30 05:05 PM Re: change ip address [Re: Mart]
serr57 Offline
Fresh Scripter

Registered: 2008-11-10
Posts: 18
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

Top
#196883 - 2009-11-30 07:09 PM Re: change ip address [Re: serr57]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
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
_________________________
Actually I am a Rocket Scientist! \:D

Top
#196890 - 2009-11-30 08:44 PM Re: change ip address [Re: Glenn Barnas]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
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

Top
#196898 - 2009-12-01 01:13 AM Re: change ip address [Re: Arend_]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
 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.. ;\)
_________________________
Actually I am a Rocket Scientist! \:D

Top
#196899 - 2009-12-01 03:12 AM Re: change ip address [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
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

Top
#196900 - 2009-12-01 09:15 AM Re: change ip address [Re: Allen]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
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

Top
#196902 - 2009-12-01 12:06 PM Re: change ip address [Re: Richard H.]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
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
_________________________
Actually I am a Rocket Scientist! \:D

Top
#196905 - 2009-12-01 03:00 PM Re: change ip address [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
"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.

Top
#196906 - 2009-12-01 04:12 PM Re: change ip address [Re: Allen]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 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

Top
#196908 - 2009-12-01 04:27 PM Re: change ip address [Re: Richard H.]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
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

Top
#196931 - 2009-12-02 11:04 AM Re: change ip address [Re: Allen]
serr57 Offline
Fresh Scripter

Registered: 2008-11-10
Posts: 18
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

Top
#196932 - 2009-12-02 12:12 PM Re: change ip address [Re: serr57]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
The InputBox() UDF posted above can be used directly in KiXtart, it just borrows the function from VBS.
Top
#197071 - 2009-12-10 09:19 PM Re: change ip address [Re: Allen]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
 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!!!!

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 557 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

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

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