Page 1 of 1 1
Topic Options
#190358 - 2008-10-28 11:47 PM Do I need a .bat file to call a URL?
Bonfils Offline
Just in Town

Registered: 2008-10-28
Posts: 4
Pardon the ignorance but VERY new to KiXtart.

I am trying to load internet explorer with a specific URL during startup, would anyone be able to tell me how I would go about doing this? Am I right in thinking I should run a bat file with URL or is there a native command in Kix I can use?

Many thanks


Edited by Bonfils (2008-10-29 12:34 AM)

Top
#190359 - 2008-10-29 01:12 AM Re: Do I need a .bat file to call a URL? [Re: Bonfils]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Welcome!

Now - everyone join in and say: "No!" \:\)

You can use the Shell command to invoke external commands that Kix will wait for, or Run to invoke a command that runs independent of your script.

One of the best ways to accomplish this (and the easiest to debug) is to create a variable that holds the command, then display it, and finally run it. When it is working fine, you can remove the "display it" step. Something like:
 Code:
$Cmd = 'iexplore.exe'        ; base command
$Cmd = $Cmd + ' http://url'  ; define the URL part
; repeat the above to add any additional parameters or arguments
; Pay attention to the leading space in each command component

'About to run: ' $Cmd ?      ; show the command (for debugging)
Run $Cmd                     ; run the command string

This may seem more complicated, but it allows you to pay close attention to each argument/parameter, getting the quotes right, etc. Speaking of quotes, we tend to use single quotes in Kix (especially in this case)because DOS comands usually require double quotes - it's easier to embed the double quotes this way.

Glenn

PS - if you have several consecutive shell commands to run, a BAT file might be the way to go - you can even create it with Kix as you need it. For single commands, use Shell or Run.
_________________________
Actually I am a Rocket Scientist! \:D

Top
#190360 - 2008-10-29 01:34 AM Re: Do I need a .bat file to call a URL? [Re: Glenn Barnas]
Bonfils Offline
Just in Town

Registered: 2008-10-28
Posts: 4
Thanks for your quick reply. Just to confirm, seeing I only need to run a single URL could I do the below?

Code:
IF @USERID = "Sysadmin"
goto end
ENDIF

IF INGROUP("Dir-entry-check") = 1

run "c:\Program Files\Internet Explorer\iexplore" http://hww-kingsweb/secure/directory/authenticate/autotest.asp

ENDIF

:END
exit

Top
#190361 - 2008-10-29 03:44 AM Re: Do I need a .bat file to call a URL? [Re: Bonfils]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Ditch the Goto/Gosub methods - they usually result in code that's hard to debug.

Here's how to do what you need:
 Code:
If Not @USERID = 'Sysadmin'

  If INGROUP('Dir-entry-check')

    $Cmd = '"c:\Program Files\Internet Explorer\iexplore"'
    $Cmd = $Cmd + ' http://hww-kingsweb/secure/directory/authenticate/autotest.asp
    'run: ' $Cmd ? ; for verification
    run $Cmd

  EndIf

EndIf

Exit 0

Note the layered If statements, and the negative logic of the first If - if the user is NOT the SysAdm user, check if they are a member of a specific group. If they are, do stuff...

The If could be combined with an AND, like this
If Not @USERID='xxx' And InGroup('yyy')
but that can be a bit more complex to understand at first, even though it reduces the logic to a single If.

The advantage of the $Cmd and display is that you can copy the command from the screen and run it by pasting it into a command prompt - does it work? Then the script should, too.

I usually comment-out the Run/Shell statements and read what is going to happen - if it looks good, I uncomment the run command. When it works, I comment-out the display command. This is especially true when the commands can do something destructive, or otherwise modify data. For your example - launching a browser on a specific page - there's little danger to combining the display and run commands.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#190372 - 2008-10-29 07:09 PM Re: Do I need a .bat file to call a URL? [Re: Glenn Barnas]
Bonfils Offline
Just in Town

Registered: 2008-10-28
Posts: 4
Hi Glenn,

Worked a treat!! Thanks for helping ;o)

Top
#190375 - 2008-10-29 08:15 PM Re: Do I need a .bat file to call a URL? [Re: Bonfils]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
that would assume iexplore is always in the same place.

and that's why I prefer explorer.exe:
$Cmd = 'explorer.exe http://hww-kingsweb/secure/directory/authenticate/autotest.asp
'run: ' $Cmd ? ; for verification
run $Cmd
_________________________
!

download KiXnet

Top
#190380 - 2008-10-29 08:59 PM Re: Do I need a .bat file to call a URL? [Re: Lonkero]
Bonfils Offline
Just in Town

Registered: 2008-10-28
Posts: 4
I take your point ;o)
Top
#190383 - 2008-10-29 09:10 PM Re: Do I need a .bat file to call a URL? [Re: Bonfils]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Agreed - as in my first example. In the second, I just copied/adjustedBonfils code, which apparently introduced the explicit path. Didn't catch that.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#190514 - 2008-11-05 09:27 PM Re: Do I need a .bat file to call a URL? [Re: Glenn Barnas]
MattColeman Offline
Fresh Scripter

Registered: 2008-05-19
Posts: 12
Loc: Kitchener-Waterloo, ON
I'm all about clean and easy scripts - so I use the following command:

 Code:

RUN "C:\Program Files\Internet Explorer\iexplore.exe http://portal" 

Top
#190516 - 2008-11-05 11:08 PM Re: Do I need a .bat file to call a URL? [Re: MattColeman]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
coleman, still, this version will fail in approx 5% of workstations...
_________________________
!

download KiXnet

Top
Page 1 of 1 1


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

Who's Online
0 registered and 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.15 seconds in which 0.105 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