Page 1 of 2 12>
Topic Options
#57402 - 2001-07-19 09:29 PM run program silently through logon script
Anonymous
Unregistered


HI there, I would like to install a program that needs to be installed on all the machines on the corporate network. I have successfully run kixtart on my network with windows 9X, NT and 2000 professional. I was wondering how I could run a program silently without user intervention. Then if the program(or upgrade) is already installed, it will not install it again? Can anyone give me a sample script that I can work with? Thanks alot. I hope you can help me ASAP.
Top
#57403 - 2001-07-19 11:45 PM Re: run program silently through logon script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Whether the install will go silently depends on the installer. For example, if it is using InstallShield, you can create a response file (setup.iss) by running setup.exe -r and then after copying the .iss file to the same folder as setup.exe, run setup.exe -s within your kix script.
code:
 $RC = MessageBox("Silent install will run now."
+ Chr(13) + "Please be patient!","ShowCase Strategy Install",64,60)
USE L: /DELETE
USE L: "\\FFSMS\SC3"
SHELL("L:\CLIENT\SETUP.EXE -S")


To prevent repeated installs on every logon you may check the registry for uninstall strings.
code:
 ;  check if already installed
$SC3uninstall = ReadValue("HKEY_LOCAL_MACHINE\software\microsoft\windows\currentversion\uninstall\ShowCase STRATEGY 3.0", "uninstallstring")
if $SC3uninstall = ""
goto install
else
goto finish
endif

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#57404 - 2001-07-20 12:16 AM Re: run program silently through logon script
Anonymous
Unregistered


Thanks for the help LL, I'll see what I can do to change my kix. Also, the setup.exe I want to run doesn't provide an option to to be run on dos mode. It just kicks the program then I have to do it manually.
Top
#57405 - 2001-07-20 02:05 AM Re: run program silently through logon script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
What program are you trying to install? Some programs have built-in support to run silent by use of a parameter passed. Sometimes setup.exe /? will show parameters. Other times just open setup.exe in WordPad and start browsing for switches. I have seen -s, /s, /q, /silent etc. Sometimes you need to hack the .inf or similar file. Check the docs or call tech support.

If you can't get a silent install, look to using setfocus() and sendkeys() to move the install along.

I don't understand why you say "doesn't provide an option to to be run on dos mode". Are you referring to shell? Try using the full path or the run command.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#57406 - 2001-07-20 04:45 AM Re: run program silently through logon script
Anonymous
Unregistered


hi LL, I didn't realize you can search for switches while opening it on wordpad. Thanks for the info! I was referring to running it on dos mode to search for switches like: /? /R etc... I tried that and didn't get any input but rather, it ran the program automatically on gui and ask me to click "next" to run the program.

What do you mean by this?

quote:
If you can't get a silent install, look to using setfocus() and sendkeys() to move the install along.

Can you give me more info on how to implement this? because I have a doubtful mind I won't be able to run this setup.exe executable silently/automatically otherwise.

Thanks a bunch for the infos... -Jimmy

Top
#57407 - 2001-07-20 06:48 AM Re: run program silently through logon script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Don't mean to be rude but you gots to RTFM. SetFocus() caan be used to bring a GUI window into focus or to check to see if the windows exists.

If SetFocus ("Untitled - Notepad") = 0 ;Notepad in memory

If SetFocus ("Untitled - Notepad") <> 0 ; Notepad not in memory

SendKeys() will stuff characters to the window you just setfocus to.

Here's a sample from the manual:

code:

Run "notepad.exe"
SetFocus( "Untitled – Notepad" )
$ReturnCode = SendKeys("Hello World")
Sleep( 2 )
$ReturnCode = SendKeys("~{F4}Y")

It's not perfect. Users can break it. Throw up message boxes to let them know what's happening. Here's a sample from one of my scripts:

code:
 
MessageBox("NOTICE!" + Chr(13) + "LANDesk Virus Protect must first be uninstalled." + Chr(13) + "System must REBOOT when complete!" + Chr(13) + "Choose Yes to uninstall and Yes to reboot" + Chr(13) + "on the two options that follow","Norton AntiVirus 7.5 Install",48,60)
RUN "C:\Program Files\LANDesk\VP5\vpremove.exe"
goto finish
endif
RUN "C:\Program Files\LANDesk\VP5\vpremove.exe"
sleep( 1 )
setfocus("Uninstall Message")
sendkeys({ENTER})
sleep( 15 )
setfocus("Uninstall Message")
sendkeys({ENTER})
endif

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#57408 - 2001-07-20 06:54 AM Re: run program silently through logon script
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Another idea.

The step you can do is:
if specified file doesn't exist you will run your script.
by completion of your script it will create specified file and
it will prevent a new installation by next logging on.

Example code:

code:

$specified_file="c:\install400.ok"
IF (Exist($specified_file) = 0)
; - run installation script or procedure
; - possible calls are:
; - shell '%comspec% /c x:\software\setup.exe'
; - shell '%comspec% /c start /w x:\software\setup.exe'
; - shell '%comspec% /c call x:\software\install.bat'
;
; - script completed. result $specified_file will be created.
IF (WriteProfileString($specified,"install",@userid,@date+" "+@time) <> 0)
ENDIF
ELSE
$info=ReadProfileString($specified_file,"install",@userid)
? "Informative INSTALL: software already installed at "+$info
ENDIF


Greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#57409 - 2001-07-20 07:05 AM Re: run program silently through logon script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
MCA,
Using a file as a flag works, but then you need to do some checking to make sure the install took. Then there's always the possibility the file may be deleted. If the install routine writes the uninstall key to the registry why not use it. That way, if the user removes via add/remove, the script will just put it back. You could write your own key to the registry if the install doesn't write something you can use as a flag.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#57410 - 2001-07-20 04:21 PM Re: run program silently through logon script
Anonymous
Unregistered


Hey, I think I will use MCA's uninstall flag because i'm actually doing an upgrade of a software that needs to be installed. I'm not doing a full install. But I'll use LL's registry check on future software installs.

LL, thanks for your input about sendkeys and setfocus. Man, i didn't even know they existed! Thanks a bunch guys! Hope it works... -Jimmy

Top
#57411 - 2001-07-20 05:19 PM Re: run program silently through logon script
Anonymous
Unregistered


One of the best ways to do silent installs is to repackage the application. Windows 2000 comes with Veritas Winstall LE which you can use to port almost any application over to MSI format. Once in MSI format, the application can be installed silently by calling it with msiexec with the /i /q switches. The other nice thing about MSI deployment is on successive runs, you can use other switches to reinstall any changed files, reinstall the whole program if any files have changed... etc etc. Forthermore, if you ever get to a homogenous 2000 network with active directory, you can use the MSI files to publish the application using Group Policy.
Search the MS site for more info on MSI deployment. It is a very elegant way of installing applications and enforcing changes onto machines.

Top
#57412 - 2001-07-20 05:53 PM Re: run program silently through logon script
Anonymous
Unregistered


to, thanks for that advice. I'm sure there are lots of things that can be done out there, I'm just not sure which one will be easier and faster to setup. I'm already doing what MCA and LL suggested. I'll probably research on MSI later. Since we have homogenous networks (9X, NT, 2000) I don't have the time to install an MSI program on each machine yet just to support the MSI platform. I'll probably place the msi executables on kix then once that is done, I could just use MSI to do software updates.

Another question I have is that I can't seem to make the setfocus and sendkeys to work:

Here is my code:

code:

$linxlog="c:\install001.ok"
IF (Exist($linxlog) = 0)
Shell( “setup.exe” )
sleep( 2 )
SetFocus( “Lan” )
SendKeys("{ENTER}” ;)
Sleep( 1 )
SetFocus( "Type of Installation" )
SendKeys("{DOWN}” ;)
Sleep( 1 )
SetFocus( "Lan" )
SendKeys("{ENTER 3}” ;)
Sleep( 10 )
SetFocus( “Telephony” )
SendKeys("~O” ;)
SetFocus( "Lan" )
SendKeys("{ENTER}” ;)
; - script completed. result $linxlog will be created.
IF (WriteProfileString($linxlog,"install",@userid,@date+" "+@time) <> 0)
ENDIF
ELSE
$info=ReadProfileString($linxlog,"install",@userid)
? "Informative INSTALL: software already installed at "+$info
ENDIF

It gives me an error on the second setfocus saying that:

quote:

1407Script error : error in parameter(s) !.
SetFocus( "Type of Installation" )

I hope when this set focus is fixed, I'd like to know if the rest of the code will work. Thanks. -Jimmy

[ 20 July 2001: Message edited by: jvd626 ]

Top
#57413 - 2001-07-20 06:17 PM Re: run program silently through logon script
Anonymous
Unregistered


I think I know what the problem is. My cut and paste wasn't in the right format. I realized it as I was posting the code in my last post. It made smiley faces I changed it to be pure ansi. However, another problem aroused...

It keeps giving me this input on NT/2000:

quote:
Please go to the Control Panel to Install and configure system components.
(OK)

Also after saying (ok), while executing the script, it gives out these numbers four by four from left to right:

quote:

14070 14070 14070...etc.

It doesn't even install the program once its finished, however it creates a install file on C: drive...

Please help!

Top
#57414 - 2001-07-20 09:45 PM Re: run program silently through logon script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Without the benefit of having the program you're trying to install, it's tough. Sounds like you need to test for OS and write separate code for each. Also for NT/2K need to check for permissions. Here's a sample:
code:
 
; check OS WinNT = 1, Win95 = 2
;
if @INWIN = 2 goto OSRightsOK endif
;-----------------------------------------------------------------------------------
;must not be Win95, therefor must be WinNT so more checks are in order
;-----------------------------------------------------------------------------------
; check if logon to Server or Workstation
;PRODUCTTYPE - WinNT = Workstation, ServerNT = Member Server, LanmanNT = Domain Controller
;
$PRODUCTTYPE = READVALUE("HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\CONTROL\PRODUCTOPTIONS","PRODUCTTYPE")
if $PRODUCTTYPE = "WinNT" goto NTwks endif
;
; if logon to server as non-admin, just exit without notice (for WTS users) else nag and exit
;
if INGROUP ("Domain Admins") <> 2 goto finish
beep
$RC = MessageBox("NOTICE!" + Chr(13) + "YOU ARE LOGGED ON TO A SERVER, installation aborting!"
+ Chr(13),"ShowCase Strategy 3 Install",16,60)
goto finish
ENDIF
;-----------------------------------------------------------------------------------
:NTwks
;-----------------------------------------------------------------------------------
; check if NT User has Local Admin rights
;
if INGROUP ("\\" + @WKSTA + "\Administrators") = 2
goto OSRightsOK
else
beep
$RC = MessageBox("NOTICE!" + Chr(13) + "Insufficient rights, installation aborting!"
+ Chr(13) + "Please notify the FF HelpDesk at ext. 1864","ShowCase Strategy 3 PTF O301120 Install",16,60)
goto finish
endif
;-----------------------------------------------------------------------------------
:OSRightsOK


As far as the 14070 I suspect 1407 is error and/or result codes. To suppress the result code you can put a $RC (or $anything) in front of the function like this:
$RC = setfocus (bla-bla-bla)

The stuff between the quotes on setfocus() has to match each window exactly. Close doesn't count. It would also be good practice to use FlushKB to clear the buffer in case your users hit keys before your SendKeys().

Also, with SHELL, the script should wait. If it does, there's nothing to setfocus to. You may need to use RUN instead.

That's the problem with using a file flag to test if installed. If your codes not rock solid, you could have a failed install and a set flag. If the install adds itself to add/remove, I prefer the registry check.

If you're doing an upgrade, another thing you can do is to test the current version to determine if an upgrade is needed. Here's how I do that:

code:
 
if GetFileVersion($syspath + "\SCODBC32.DLL") = "3.01.120.122 (2001-05-10)"
goto finish
endif

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#57415 - 2001-07-21 01:20 AM Re: run program silently through logon script
Anonymous
Unregistered


Ok, it works now on 9X, NT, and 2000 but the problem concerns about their installation speed. Sometimes the sleep() runs out and the install ends up failing. Also, why is the user seeing the install process? Can it be hidden somewhat like running on the background or minimized?
Top
#57416 - 2001-07-21 03:35 AM Re: run program silently through logon script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Instead of arbitrating a time to sleep with the hopes the app will be ready when it wakes up, you can use the SetFocus() in a While Loop. This will cause the script to wait for the window. Use a short sleep to save CPU rather than checking constantly for the window. If you arbitrate the sleep time and its too short, since you aren't testing $RC, the SendKeys() go into space. If you set the sleep too long, the user may think he/she needs to do input and make the wrong choice.
Example:
code:

While
$RC = SetFocus("Untitled - Notepad") <> 0
Sleep (1)
Loop
$RC = SendKeys("Hello World")


You may still need to tweak the sleep time as sometimes a window appears long before the input option you sendkey to is available.
>Also, why is the user seeing the install process?
You can't have it both ways. You need to choose one. Either setup an installer package that does a silent install or use SetFocus() and SendKeys(). You cannot send keys to a hidden window.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#57417 - 2001-07-21 05:28 AM Re: run program silently through logon script
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear LLigetfa,

Of course a registry entry can also be used, but we are using for
each workstation a configuration history file on the server, which
are updated with all kind of kixtart scripts.
The advantages are:

  • the actual information about a workstation has been backupped all
    the time.
  • without any problem we can make any cross-table of important items
    without the need of a restart of analyzing the workstations.
    possible problem with some information are detected in an early stage.

In the future we will implement a more general way of using our registry
as a second configuration database, which information can be retrieved
by runnig a simple script. Normally an user can't enter the registry.
Greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#57418 - 2001-07-21 06:10 PM Re: run program silently through logon script
Anonymous
Unregistered


I'll try it on monday and see what happens. Thanks for the infos. Also, is there anybody who knows anything about MSI? I looked on microsoft website and they recommended not to put it on production because its still on its early stages. Anyway, it would be great to know anything that deals with automatic software installations and updates thats bullet proof.

Also, would anyone show me how to make it so that users will be prompted first and say "ok," so they will know what is going on? Since I can't make it silently install, might as well give the users heads up what is happening first right?

Here is an example:

quote:

Your Phone software will be upgraded. Click [Enter] to continue...

[ 21 July 2001: Message edited by: jvd626 ]

Top
#57419 - 2001-07-22 07:03 AM Re: run program silently through logon script
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Good luck on Monday. Hope it goes well for you. I gave you several examples of popping up a message box. Perhaps something like:
code:

$RC= MessageBox("Your Phone software will be upgraded." + Chr(13) + "Please be patient!","Phone Software Install",64,60)

RTFM for what the numbers mean or search this board for some undocumented ones.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#57420 - 2001-07-23 05:19 PM Re: run program silently through logon script
Anonymous
Unregistered


Regarding MSI deployment. I don't think this board is the place to talk about it since it is not exactly Kix related. Please feel free to ICQ me at 3534815 if you have any questions about MSI.
Top
#57421 - 2001-07-23 07:11 PM Re: run program silently through logon script
Anonymous
Unregistered


hello, it is monday and I am still having difficulties with the script. it gets to the point where its installing the files but then, I think the setfocus runs out and it just doesn't finish the installation. The script doesn't wait for the program to finish. I tried setting a loop as follows:

code:

While
$RC = SetFocus( "Installing" ) <> 0
Sleep( 1 )
Loop
SetFocus( "Telephony LAN-Linx Config" )
SendKeys("~O")
Sleep( 3 )
SetFocus( "Lan-Linx 2000 Installation" )
SendKeys("{ENTER}")

Any ideas? THanks alot.

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 369 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.109 seconds in which 0.06 seconds were spent on a total of 12 queries. Zlib compression enabled.

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