#191446 - 2008-12-28 02:37 AM
Create a file
|
chipped
Fresh Scripter
Registered: 2008-12-09
Posts: 40
|
Hi all,
how do I create a file in kix?
thanks
|
|
Top
|
|
|
|
#191453 - 2008-12-28 07:17 AM
Re: Create a file
[Re: Sealeopard]
|
chipped
Fresh Scripter
Registered: 2008-12-09
Posts: 40
|
Damn, so you cant create one?
|
|
Top
|
|
|
|
#191454 - 2008-12-28 10:28 AM
Re: Create a file
[Re: chipped]
|
Gargoyle
MM club member
   
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
Reread the OPEN function.
Action
Opens a text file.
Syntax
OPEN (file handle, "file name", mode)
Parameters
File handle
A numeric expression indicating the file handle of the file to open. Possible values range from 1 to 10.
File name
A string expression indicating the path and name of the ASCII file to open.
Mode
Optional parameter that indicates what should happen if the file does not exist. This parameter can have the following values:
0 If the file does not exist, OPEN fails with return code 2 (default). 1 If the file does not exist, OPEN will create a new file. 2 Opens the file for read access (default). 4 Opens the file for write access.
Note
These values are cumulative. So if you want to open a file for write access, and create it if it does not yet exist, you should specify 5. Notice however that a file can not be opened for read and write access at the same time.
Remarks
OPEN opens the ASCII file specified by file name, for the internal buffer indicated by file handle. KiXtart supports a maximum of ten open files, so file handle must be within the range of 1 to 10.
Returns
-3 File handle already in use -2 Invalid file handle specified -1 Invalid file name specified 0 File opened successfully >0 System error
Example
IF Open(3, @LDRIVE + "\CONFIG\SETTINGS.INI") = 0
$x = ReadLine(3)
WHILE @ERROR = 0
? "Line read: [" + $x + "]"
$x = ReadLine(3)
LOOP
ENDIF
_________________________
Today is the tomorrow you worried about yesterday.
|
|
Top
|
|
|
|
#191458 - 2008-12-29 01:55 AM
Re: Create a file
[Re: Mart]
|
chipped
Fresh Scripter
Registered: 2008-12-09
Posts: 40
|
Genius!! I so missed that, thanks.
This is what I have so far
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;Checking to see if Install folder exists, if it dosent then it is created.
IF 0=EXIST("C:\install")
MD "C:\install"
ENDIF
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;Installing Programs, the name of each program is writen to a folder as a text file, if the file does not esxist then the program will be installed, if the file exists then the program will not be installed. You can include version numbers in the file name of each program so if you need to you can upgrade.
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;Installing Adobe Reader 9.0
IF 0=EXIST("C:\install\AdobeReader9.0.txt")
Open(1, "C:\install\AdobeReader9.0.txt", 1)
RUN "\\stingray\share\AdbeRdr90_en_US.exe /update-no /sAll /rs /l /msi"/qb-! /norestart ALLUSERS=1 EULA_ACCEPT=YES SUPPRESS_APP_LAUNCH=YES""
ENDIF
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Unfortunately using RUN wont let me use install switches, is there another method that will let me use switches?
Edited by chipped (2008-12-29 01:56 AM)
|
|
Top
|
|
|
|
#191460 - 2008-12-29 10:24 AM
Re: Create a file
[Re: Mart]
|
chipped
Fresh Scripter
Registered: 2008-12-09
Posts: 40
|
No it will be used to roll out programs to about 300 pc's, the script actually has 9 programs in it. So far.
This way I can add programs to the script, chuck it on the logon file and boot all the pc's before everyone comes in, easy peesy.
|
|
Top
|
|
|
|
#191467 - 2008-12-29 01:45 PM
Re: Create a file
[Re: Mart]
|
chipped
Fresh Scripter
Registered: 2008-12-09
Posts: 40
|
Thanks, did that and its a lot easier to read now.
|
|
Top
|
|
|
|
#191470 - 2008-12-29 02:00 PM
Re: Create a file
[Re: chipped]
|
chipped
Fresh Scripter
Registered: 2008-12-09
Posts: 40
|
Ah, got it working, my syntax was wrong. The RUN command target has to be in brackets like this
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;Checking to see if Install folder exists, if it dosent then it is created.
IF NOT EXIST("C:\install")
MD "C:\install"
ENDIF
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;Installing Programs, the name of each program is writen to a folder as a text file, if the file does not esxist then the program will be installed, if the file exists then the program will not be installed. You can include version numbers in the file name of each program so if you need to you can upgrade.
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;Installing Adobe Reader 9.0
IF NOT EXIST("C:\install\AdobeReader9.0.txt")
Open(1, "C:\install\AdobeReader9.0.txt", 1)
RUN ("\\stingray\share\AdbeRdr90_en_US.exe /update-no /sAll /rs /l /msi"/qb-! /norestart ALLUSERS=1 EULA_ACCEPT=YES SUPPRESS_APP_LAUNCH=YES"" )
ENDIF
;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Edited by chipped (2008-12-29 02:01 PM)
|
|
Top
|
|
|
|
#191485 - 2008-12-30 04:38 AM
Re: Create a file
[Re: NTDOC]
|
chipped
Fresh Scripter
Registered: 2008-12-09
Posts: 40
|
I'm going to edit the logon script to automatically launch the script if only the admin is logging in.
I have been extensively testing it on a test machine.
Thanks for your input
|
|
Top
|
|
|
|
#191487 - 2008-12-30 07:36 AM
Re: Create a file
[Re: Sealeopard]
|
chipped
Fresh Scripter
Registered: 2008-12-09
Posts: 40
|
Push the installs/updates remotely? Thats pretty vague, please elaborate 
I have looked at Windows AD integrated solutions but the free ones are only for MSI packages.
I like using scripts because I know whats going on in the background, its free and when it all works it gives you most satisfaction.
|
|
Top
|
|
|
|
#191532 - 2008-12-31 01:30 PM
Re: Create a file
[Re: Gargoyle]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
|
This is what our SWDIST product does - you can sit at your desk and run the Deploy command to push an install process to a list of computers. It uses the task scheduler on the target comptuer to initiate the install command with admin rights - no need to physically touch any of the systems. I'm using it at my current project to push software to 3000+ desktops at over 300 locations.
Point is if you create an unattended install package and put it on a share, you can use Kix to push out a scheduled task to remote systems to run with specific credentials at a specified time. Staggering the time prevents saturating the network, and using a network share with OTN install process - especially for many concurrent product installs - eliminates any issues with limited disk space on the client. Using push technology requires enough space for the install package and the installed product. OTN installs only require the space for the installed product, and there's no cleanup. SWDIST is a hybrid, since it pushes a small batch file (no software dependencies on the client using BAT files) to the client, and defines a pull install. The intelligence comes from the Deploy process, which determines the target system's IP address, identifies the closest deployment server, and creates a scheduled task with the server name, product, and any arguments.
Your complex arguments would be in the install.bat file on the server and not passed to the task. Speaking of "your complex arguments"... your problem is really mismatched quotes. Shell/Run are commands, not functions, and do not require "()". When you use these commands, you should use single quotes for Kix and double quotes for the internal commands. I also prefer building command strings instead of using a monolithic statement, similar to:
$Cmd = '%COMSPEC% /c '
$Cmd = $Cmd + 'some_prog.exe '
$Cmd = $Cmd + 'Arg="argument 1" /switchA'
'About to run: ' $Cmd ? ; for debugging
Shell $Cmd This is easier to troubleshoot, as it breaks the command into managable segments.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#191538 - 2009-01-01 10:51 AM
Re: Create a file
[Re: Glenn Barnas]
|
chipped
Fresh Scripter
Registered: 2008-12-09
Posts: 40
|
Does that leave behind a log so that when I run the script again it dosent try install everything all over?
|
|
Top
|
|
|
|
#191539 - 2009-01-01 02:04 PM
Re: Create a file
[Re: chipped]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
|
The SWDIST tools log every action with a complete audit trail, but the logs are not used to prevent reinstallation. The task UDFs don't do any logging.
Generally, you'd define a custom registry key, like "ABC_Co" under HKLM\Software. You'd create a value for each app you install, which could be a simple "1" value indicating the install is done, or a datestamp, indicating when it was done. Thus, using either BAT or KIX scripts, you can read that registry key, and if an error 2 occurs (not found), you perform the install.
Using log (or tag) files to indicate an install or action is generally unreliable as users, AV software, and other cleanup processes can remove the files.
Glenn
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 774 anonymous users online.
|
|
|