execute( <cmdline>,
<workdir>, <show>, <wait>, <exitcode> )
Starts the program given in <cmdline>, which also can contain parameters and options needed by this program.
If <workdir> is given, it is set as the workding-directory for the started program.
<show> controls, how the started program is shown (0=hidden, 1=default=normal, 2=minimized, 3=maximized). Please note, that there will be no visible window, if HService itself is running invisible as a service, regardless which value you choose for <show>.
If <wait> is set to true (default), execution of the script is paused until the started program has finished.
If the exit-code of the program is needed, it can be saved in the variable <exitcode>.
Returns: Integer (0=no error, <>0=error)
execute( "notepad.exe myfile.cfg" )
IniRead( <filename>,
<section>, <ident>, <default> )
Reads an entry from the .INI-file named <filename>. If no <filename> is given, file "HScripts.ini" is used. If no <section> is given, section "[All]" is used.
If "[<section>]" does not contain an entry named "<ident>=...", the value <default> is returned.
Returns: String
$answer = IniRead( "MyScript.ini", "Answers", "Last", "42") $LastConnected = int( IniRead( "", "", "LastConnected", 0 ) )
IniWrite( <filename>,
<section>, <ident>, <value> )
Writes an entry to the .INI-file named <filename>. If no <filename> is given, file "HScripts.ini" is used. If no <section> is given, section "[All]" is used.
Returns: 0: OK, <>0: Error
IniWrite( "MyScript.ini", "Answers", "Last", $answer ) IniWrite( "", "", "LastConnected", time )
Checks, if the given file exists. <filename> may contain wildcards "?" and "*".
Returns: Integer (1=exists, 0=doesn't exist or invalid filename/path)
if( !fileexists("myfile.cfg" ) )
error( "Missing configuration file!" )
endif
Returns size of file <filename>.
Returns: Integer (-1 if file is missing)
print( FileSize( HamPath + "Hamster.exe" ) )
Returns time of last update of file <filename>.
Returns: Integer (-1 if file is missing)
print( "Your Hamster's age: ", time - FileTime( HamPath + "Hamster.exe" ), " seconds" )
Deletes the file named <filename>.
Returns: 0: OK, <>0: Error
FileDelete( "MyScript.tmp" )
FileRename( <oldname>,
<newname> )
Renames the file named <oldname> to <newname>.
Returns: 0: OK, <>0: Error
FileRename( "MyScript.dat", "MyScript.bak" )
FileCopy( <oldname>,
<newname> )
Copies the file named <oldname> to <newname>.
Returns: 0: OK, <>0: Error
FileCopy( "MyScript.dat", "MyScript.bak" )
Checks, if the given directory exists.
Returns: Integer (1=exists, 0=doesn't exist or invalid path)
if( !direxists( "mydir" ) ) # ... endif
Creates a new directory named <dirname>.
Returns: 0: OK, <>0: Error
DirMake( HamPath + "MyScript" )
Removes the directory named <dirname>, if it is empty.
Returns: 0: OK, <>0: Error
DirRemove( HamPath + "MyScript" )
Makes the directory named <dirname> the current directory.
NOTE: Not suggested, use full qualified filenames instead.
Returns: 0: OK, <>0: Error
DirChange( HamPath + "MyScript" )
Returns the name of the current directory. The name is always returned with a trailing backslash.
Returns: 0: OK, <>0: Error
print( DirCurrent )
Returns the name of the Windows directory. The name is always returned with a trailing backslash.
Returns: 0: OK, <>0: Error
print( DirWindows )
Returns the name of the Windows system directory. The name is always returned with a trailing backslash.
Returns: 0: OK, <>0: Error
print( DirSystem )
DiskInfo( <type>,
<drive-letter> )
DiskInfo( <type> )
Returns information about a disk drive, either free space (<type>=0) or
total size (<type>=1).
If <drive-letter> is omitted, current drive is used.
Note: Due to limitation of script's integer range, returned info is in kilobyte (1 KB = 1024 Byte).
Returns: >=0: Result, <0: Error
print( DiskInfo(0,"C"), " of ",
DiskInfo(1,"C"), " KB free on drive C:" )
See also: ListLoad, ListSave, ListFiles, ListDirs.