Page 1 of 1 1
Topic Options
#180001 - 2007-08-30 07:58 PM Running .exe, .bat., .msi and such out of kix
akolos Offline
Fresh Scripter

Registered: 2007-08-27
Posts: 10
Hello.
I want to run the following out of .kix:
.exe - to install a program
.bat - to apply update to it
.msi - to install another program to work with first one
.reg - to add reg_hack into registry to make it all work

As i understand:
.exe <-- SHELL
.bat <-- CALL or INCLUDE
.msi <-- not sure here, call msiexex.exe and pass the parameter to it
.reg <-- ??? no clue at all. Found a function to read the key, how to right into it, how to add new value or new key

i may have another question about error check some time down the road, but not before i try and fail to figure it out myself

Top
#180003 - 2007-08-30 08:00 PM Re: Running .exe, .bat., .msi and such out of kix [Re: akolos]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
No, they are all SHELL or RUN.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#180005 - 2007-08-30 09:58 PM Re: Running .exe, .bat., .msi and such out of kix [Re: Les]
akolos Offline
Fresh Scripter

Registered: 2007-08-27
Posts: 10
so, for .reg file it will be
SHELL "\\path_to_file\file.reg"
?

Top
#180007 - 2007-08-30 10:26 PM Re: Running .exe, .bat., .msi and such out of kix [Re: akolos]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You should probably SHELL directly to regedit and provide the parms rather than rely on file association.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#180008 - 2007-08-30 10:50 PM Re: Running .exe, .bat., .msi and such out of kix [Re: Les]
akolos Offline
Fresh Scripter

Registered: 2007-08-27
Posts: 10
.exe <-- SHELL "\\path_to_file\program.exe
.bat <-- CALL or INCLUDE. CALL is "to start another .kix script", INCLUDE to "treat the contents of a specified file as if those contents had appeared in the script at the point where INCLUDE appears". Is INCLUDE becoming absolete now?
.msi <-- SHELL "%SystemRoot%\whatever\msiexec.exe /parameters"
.reg <-- SHELL "%SystemRoot%\whatever\regedit.exe \\path_to_file\file.reg /parameters"

Is that how it's done?

Top
#180009 - 2007-08-30 11:01 PM Re: Running .exe, .bat., .msi and such out of kix [Re: akolos]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4563
Loc: USA
All Shells in your case.

Call is to call another kix file. BATs, VBSs are not called.

So in your case the best bet would be:

shell '%comspec% /c filename.bat'

Top
#180015 - 2007-08-31 09:54 AM Re: Running .exe, .bat., .msi and such out of kix [Re: Allen]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Try to get into the habit of quoting any file path that is going to be passed to the command line - it'll save the aggravation caused by spaces in paths.
 Code:
shell '"'+%COMSPEC%+'" /c "x:\path to \filename.bat"'

Top
#180017 - 2007-08-31 10:07 AM Re: Running .exe, .bat., .msi and such out of kix [Re: Allen]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Indeed Shell or Run
Run start the program and continues with the script
Shell will wait for the program to finish and after that continue the script
.exe --> Shell '"\\server\path to\pro gram.exe" /switch1'
.bat --> Shell '"%ComSpec%" /c "\\server\path to\My Batch.bat"'
.msi --> Shell 'msiexec /i "\server\path to\pro duct.msi"'
.reg --> Shell 'regedit /c "\\saerver\path to\keys.reg"'
.reg --> I would try to use WriteValue()

Top
#180024 - 2007-08-31 01:24 PM Re: Running .exe, .bat., .msi and such out of kix [Re: Witto]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
 Originally Posted By: Witto
.reg --> Shell 'regedit /c "\\saerver\path to\keys.reg"'


Well, aside from the fact that you spell server similar to daemon (which run on saervers?) the argument should be /s, as in Silent. Without this, the regedit command will prompt for confirmation - not likely what you want in a script.

\:D

Also - be sure you understand the difference between Shell and Run. Shell = "go do this for me, I'll wait..." where Run = "Go do this for me, I'll go on with my tasks...".

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

Top
#181302 - 2007-10-08 06:35 PM Re: Running .exe, .bat., .msi and such out of kix [Re: Glenn Barnas]
MEldridge Offline
Fresh Scripter

Registered: 2007-02-12
Posts: 5
Loc: Michigan
I am trying to run a bat file myself, what is the "%comspec%" ???


when I try it like that it says Error in expression...





Edited by MEldridge (2007-10-08 06:37 PM)

Top
#181303 - 2007-10-08 06:40 PM Re: Running .exe, .bat., .msi and such out of kix [Re: MEldridge]
eriqjaffe Offline
Hey THIS is FUN

Registered: 2004-06-24
Posts: 214
Loc: Arlington Heights, IL USA
 Originally Posted By: MEldridge
I am trying to run a bat file myself, what is the "%comspec%"

It's your command interpreter (usually cmd.exe). I don't know if it's really necessary when calling a batch file, though.

Top
#181307 - 2007-10-08 07:07 PM Re: Running .exe, .bat., .msi and such out of kix [Re: eriqjaffe]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
No
 Code:
Break On
Run 'c:\script\HelloWorld.bat'
Shell 'c:\script\HelloWorld.bat'
Get $

Top
#181316 - 2007-10-08 08:38 PM Re: Running .exe, .bat., .msi and such out of kix [Re: Witto]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Specifying the command processor necessary if you do any redirection or piping, which are handled directly by the command interpreter.

For example:
Shell 'find c:\temp\names.txt "Fred" > c:\temp\Frednames.txt'
will fail, while
Shell '%COMSPEC% /c find c:\temp\names.txt "Fred" > c:\temp\Frednames.txt'
will work.

You need to know what's in your batch files - if they use redirection (<>) or piping (|), you need to specify %COMSPEC% /C, otherwise you don't. If you always specify the command processor, you'll be fine. (of course, there's an extra process sometimes).

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

Top
#181325 - 2007-10-08 09:44 PM Re: Running .exe, .bat., .msi and such out of kix [Re: Glenn Barnas]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
OK, I will keep it in mind.
Top
#181390 - 2007-10-09 05:26 PM Re: Running .exe, .bat., .msi and such out of kix [Re: Witto]
RomanB Offline
Fresh Scripter

Registered: 2006-10-20
Posts: 15
Loc: Bonn, Germany
Hi Akolos!
Could you post your code, please? I'm interested in your error.

To Glenn: I always use "cmd /c" in my shell commands. What's the advantage of using %comspec%?

Regards, Roman

Top
#181392 - 2007-10-09 05:46 PM Re: Running .exe, .bat., .msi and such out of kix [Re: RomanB]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
%ComSpec% is an environment variable and points with no error to cmd.exe
Top
#181395 - 2007-10-09 06:20 PM Re: Running .exe, .bat., .msi and such out of kix [Re: Witto]
akolos Offline
Fresh Scripter

Registered: 2007-08-27
Posts: 10
RomanB

Hey, i check my posts, i didnt mention any errors.
Besides, it was about 2 months ago.
Anyway, the reason i was asking whatever it was that i asked:
i had to deploy quite a few new systems in our office. One of the programs needed reg file run on system to change certain things.
I was just finishing the logon script (basic things - shares and printer mapping), and i wanted to implement that reg file in script.
Since then we upgraded the software, and reg. file no longer needed.

As of now i dont call anything outta my script.
it may change since we are planning our domain/forest rebuild.
if you still want my code i could paste it, but it is really only about 10 CASE statements, with "addprinterconnection" and "use Z:\ "share""

Top
#181400 - 2007-10-09 07:41 PM Re: Running .exe, .bat., .msi and such out of kix [Re: akolos]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
%COMSPEC% has pointed to the valid command interpreter since MS-DOS. Using that in my scripts instead of CMD or (back then) COMMAND, simple kix scripts developed 12 years ago that call the Shell command will run without changes.

EG - if Vista had changed the name of the command interpreter to VShell, your scripts would not work, while those that used %COMSPEC% would.

It's all about portability.

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

Top
#181456 - 2007-10-10 09:33 PM Re: Running .exe, .bat., .msi and such out of kix [Re: akolos]
RomanB Offline
Fresh Scripter

Registered: 2006-10-20
Posts: 15
Loc: Bonn, Germany
OK Akolos, don't mind, forget it.
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 2419 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.075 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