OS commands

  Knozall AutomationWizard os_commands.htm

Operating System Commands

$GetUserName[server, group, offset ]

$OSName.

OSType.

%OSName.

$ScanENV[index ]

$System[Network, HostAddress, hostname ]

$System[Network, HostName, address ]

%System[Process, Info, AvgUtil]

%System[Process, Info, Util]

$System[WinEventLog, action, spec, options]

$System[WinEventLog, Open, logfile, options]

$System[WinEventLog, Close]

$System[WinEventLog, NumEvents]

$System[WinEventLog, RestartRead, time]

$System[WinEventLog, ReadEvent]

$System[WinEventLog, EventInfo, eventinfo]

$System[WinEventLog, WaitForEvent]

$System[WinEventLog, Clear, savepath]

$System[WinEventLog, Backup, savepath]

$System[WinReg, Option, path, spec]

$System[WinReg, EnumKeys, keypath, position ]

$System[WinReg, EnumValues, keypath, position ]

%System[WinServ, serviceenum, type, servername]

$System[WinServ, ServiceInfo, position, serviceinfo ]

$System[WinShell, action, spec.]

%System[WinSys, action, option]

 

Description

Will retrieve the offset count of a username from the specified server and group.

Syntax

$GetUserName["Server, Group, Offset"]

Returns

String value.

Example

$username = $GetUserName["FSTEST1, DEVELOPMENT, 3"]

Writecon "The third user in group DEVELOPMENT"

Writecon "on FSTEST1 is = ",$username

Description

Returns Windows NetWare Unix as operating system types for the current target agent.

Syntax

$OSName

Returns

$: Returns "Windows", "Netware", or "Unix"

% Returns 0 for windows, 1 for NetWare, or 2 for Unix

Example

writecon "Operating system = ", $osname; “%:”,%osname

Description

Gets the OS Type.

Syntax

$OSType

Returns

If windows: $%: it returns "NT” or 0, "95/98" or 1, or "3.1" or 3

If NetWare: $%: returns "Netware" or 1000

If Unix: $%: returns "Unix" or 2000

        Examples

          $type = $OSType

Description

Gets name of OS.

Syntax

%OSName

Returns

$: returns "Windows", "Netware", or "Unix"

%: returns 0 for windows, 1 for netware, or 2 for unix

Examples

$os = $OSName

Description

Displays environment variables

Syntax

$ScanENV[index]

Example

For x = 0 to 23

$tmp = $scanenv[x]

writecon "scanenv= ", $tmp

next

Returns

Environment variable associated with the index.

Description

Get IP address for host

Syntax

$System["Network, HostAddress, host"]

Where:

hostname: name of host

Returns

$: ip address in "1.2.3.4" format

Example

$ip = $System["Network, HostAddress, quantum"]

Description

Get host name for IP address

Syntax

$system["Network, HostName, address"]

Returns

$: host name for IP address

Example

$host = $System["Network, HostName, 204.23.53.2"]


 

Description

Retrieve the average agent utilization over the last ten minutes for the default Target Agent.

Syntax

%System["Process, Info, AvgUtil"]

Returns

Numeric value.

Remarks

Currently only works on NT4

Unit of measurement = percentage.

Example

Writecon “Average utilization = “, %System["Process, Info, AvgUtil"]

%System[Process, Info, Util]

Description

This identifier retrieves the utilization percentage for the default Target Agent.xe "%ServerUtil"xe "MXIs:%ServerUtil"xe "determining:utilization percentage"xe "utilization percentage"

Syntax

%System["Process, Info, Util"]

Returns

Numeric value.

Remarks

Currently only works on NT4

Unit of measurement = percentage.

Example

Writecon "%Utilization = ",%System["Process, Info, Util"]


 

Action

Spec

Options

Description

Open

Logfile

Servername

File

Backward

Open the specified logfile

Close

N/A

N/A

Closes logfile that was opened with the Open command

NumEvents

N/A

N/A

Returns the number of events in the eventlog

RestartRead

Time

 

Resets the read

ReadEvent

 

 

Use with EventInfo to read event information

Returns Yes if there is another event to read, otherwise , NO.

EventInfo

Time

 

 

 

Type

    Error

    Warning

    Information

    Success audit

    Failure audit

Source

Category

Event

Computer

User

 

Number of descriptionlines

Description lines

 

$ returns the date and (local) time the event was generated in the format “MM?DD?YYYY HH:MM:SS”

%returns thee date and (gmt) time the event was generated as the number of seconds that have elapsed since midnight (00:00:00), January 1, 1970.

 

Returns “error” for error

Returns “warning” for warning

Returns “information” for information

Returns “audit_succ”  for success audit

Returns “audit fail” for failure audit

$ Returns returns the name specifying the source of the event.

$ Returns the event category

%$ Returns the event id number

$ Returns the name of the computer that generated the event.

$ Returns the name of the user that generated the event or “Not_Found” if there is no user associated with the event.

%$ Returns the number of description lines followed by the zero based idex of the line $ Returns the specified description line

WaitForEvent

 

 

Waits until an event is written to the event log

Clear

Savepath

 

Clears the specified logfile and optionally backs it up.  If savepath is specified, it is the path of the file to save the logfile to before it is cleared.  If savepath is not specified, logfile is not saved.

Backup

Savepath

 

Backs up specified logfile to path defined by savepath.

Examples

%tmp = %System["WinEventLog, Open, Application"]

 %tmp = %System["WinEventLog, Open, c:\application.bak, file"]

 %tmp = %System["WinEventLog, Close"]

%numevents = %System["WinEventLog, NumEvents"]

%tmp = %System["WinEventLog, RestartRead"]

%tmp = %System["WinEventLog, RestartRead, ", %TimeNow]

%isevent = %System["WinEventLog, ReadEvent"]

$type = $System["WinEventLog, EventInfo, type"]

%tmp = %System["WinEventLog, Clear"]

%tmp = %System["WinEventLog, Clear, c:\application.bak"]

%tmp = %System["WinEventLog, Backup, c:\application.bak"]

Description

Open the specified log file

Syntax

$System[“WinEventLog, Open, logfile, options”]

Where:

logfile: specifies the log file to open, can be "Application", "Security", "System", or the path to a backed up log file if the "file" option is specified.

Options:

"servername:", followed by servername- if specified, name of server to open log file on, if not specified log file is opened on local server

"file"- specifies that logfile is the path of a backed up log file

"backward"- specifies that the log is to be read in reverse chronological order (newest first), default is forward chronological order (oldest first)

This must be called before any other eventlog command is called, and you must call the close command when you are done with this logfile.

Examples:

%tmp = %System["WinEventLog, Open, Application"]

%tmp = %System["WinEventLog, Open, c:\application.bak, file"]

Description

Closes the log file that was opened with the "Open" command.

Syntax

$System["WinEventLog, Close"]

Example

%tmp = %System["WinEventLog, Close"]

Description

Returns the number of events currently in the event log

Returns

%$: number of events currently in the event log

Example

%numevents = %System["WinEventLog, NumEvents"]

Description

Resets the read position.

Syntax

$System["WinEventLog, RestartRead, time"]

Where:

time: if not specified or 0, resets the read position to the beginning, if specified and the read direction is forwards, will exclude all events before the specified time, if backward, will exclude all events after the specified time, the time is expressed as the number of seconds that have elapsed since midnight (00:00:00), January 1, 1970, GMT

Remarks

This command is useful for reading only new events after the WaitForEvent" command has been called.

Examples

%tmp = %System["WinEventLog, RestartRead"]

%tmp = %System["WinEventLog, RestartRead, ", %TimeNow]

Description

Read an event in the event log, the "EventInfo" command is used to retrieve the event's parameters, each successive call to this command will return the next event.

Syntax

$System["WinEventLog, ReadEvent"]

Returns:

$%: returns “Yes” or 1 if there is an event and “No” or 0 if there are no more events.

Example

%isevent = %System["WinEventLog, ReadEvent"]

Description

Retrieves event parameters for the event read by the "ReadEvent" command

Syntax

$System["WinEventLog, EventInfo, eventinfo"]

Where:

eventinfo: specifies which parameter to return, can be:

"time"

$: returns the date and (local) time the event was generated in the format "MM-DD-YYYY HH:MM:SS"

%: returns the date and (gmt) time the event was generated as the number of seconds that have elapsed since midnight (00:00:00), January 1, 1970

"type"

$: returns the type of event, can be "error" for error, "warning" for warning, "information" for information, "audit_succ" for success audit or "audit_fail" for failure audit

%: returns the type of event, can be 0 for error, 1 for warning, 2 for information, 3 for success audit or 4 for failure audit.

"source"

$: returns the name specifying the source of the event.

"category"

$: returns the event category.

"eventid"

%$: returns the event id number.

"computer"

$: returns the name of the computer that generated the event.

"user"

$: returns the name of the user that generated the event or "Not_Found" if there is no user associated with the event.

"numdesclines"

%$: returns the number of description lines

"descline:", followed by the zero based index of the line

$: returns the specified description line.

"numparams" 

%$: returns the number of event parameters

 "param:", followed by the zero based index of the parameter,

$: returns the specified parameter or "Not_Found" if there are no more parameters.

Example

$type = $System["WinEventLog, EventInfo, type"]

See the file Seceventdesc.html on the disk or on www.knozall.com  for detailed information

Description

Waits until an event is written to the event log

Examples:

%tmp = %System["WinEventLog, WaitForEvent"]

Description

Clears the specified log file and optionally backs it up.

Syntax

$System["WinEventLog, Clear, savepath"]

Where:

savepath: if specified, path of the file to save the logfile to before it is cleared, if not specified, logfile is not saved.

Examples

%tmp = %System["WinEventLog, Clear"]

%tmp = %System["WinEventLog, Clear, c:\application.bak"]

Description

Backs up the specified log file.

Syntax

$System["WinEventLog, Backup, savepath"]

Where:

savepath: path of the file where logfile will be saved.

Examples:

%tmp = %System["WinEventLog, Backup, c:\application.bak"]

Description

Gets or sets key parameters.

Syntax

$System[“WinReg, Option, keypath, spec”]

Where:

Path can be keypath or valuepath.

keypath: specifies the path to the registry key, composed of an optional computer name (if the key you are changing is on another computer), followed by the main key name, followed by any sub keys followed by the value name (if the key is a path to a value)

Remarks

A remote key path must be specified by two backslashes, followed by thecomputer name, followed by one backslash followed by the rest of the key path.

Only HKEY_LOCAL_MACHINE and HKEY_USERS can be used remotely.

Examples

local:

HKEY_LOCAL_MACHINE\SOFTWARE\Knozall

HKEY_CLASSES_ROOT\mjbfile

remote:

\\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall

valuepath: same as keypath, but is used to identify a value instead of a key.

examples:

local:

HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\strvalue

remote:

\\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\strvalue

 

Option

Path

Description

CreateKey

Keypath

Creates key specified by keypath.

DeleteKey

Keypath

Deletes key specified by keypath.

SetValue

Valuedata

Sets the value specified by valuepath.

SetValue

Valuepath,Type,  Valuedata

Sets the value specified by the valuepath

Type: specifies the type of the value, can be "number" or "string."

Valuedata: specifies the data to set.

GetValue

Valuepath

$: if the value is a string, the data or "Not_Found" if the value is not found

 %: if the value is a number, the data or -1 if the value is not found

DeleteValue

Valuepath

Deletes the value specified by valuepath.

GetValueType

Valuepath

$: returns "string" if string, "number" if number, "unknown" if unknown, or "Not_Found" if the value is not found.

%: returns 0 if string, 1 if number, 100 if unknown, or -1 if the value is not found

EnumKeys

Keypath, position

Enumerates the registry keys in the key specified by keypath

position: start at 0 for the first key and increment for next key

returns:- $: the name of the key or "Not_Found" if there are no more keys.

EnumValues

Keypath, positon

Enumerates the values in the key specified by keypath

position: start at 0 for the first value and increment for next value

returns:: $: the name of the value or "Not_Found" if there are no more values.

Examples

$System[WinReg, CreateKey, keypath ]

examples:

 %tmp = %System["WinReg, CreateKey, HKEY_LOCAL_MACHINE\SOFTWARE\Knozall"]

%tmp = %System["WinReg, CreateKey, \\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall"]

$System[WinReg, DeleteKey, keypath ]

examples:

%tmp = %System["WinReg, DeleteKey, HKEY_LOCAL_MACHINE\SOFTWARE\Knozall"]

%tmp = %System["WinReg, DeleteKey, \\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall"]

$System[WinReg, SetValue, valuepath, string, valuedata ]

examples:

%tmp = %System["WinReg, SetValue, HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\value, string, data"]

%tmp = %System["WinReg, SetValue, HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\value, number, 100"]

%tmp = %System["WinReg, SetValue, \\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\value, string, data"]

 %tmp = %System["WinReg, SetValue, \\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\value, number, 100"]

$System[WinReg, SetValue, keypath, number, valuedata ]

examples:

%tmp = %System["WinReg, SetValue, HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\value, string, data"]

%tmp = %System["WinReg, SetValue, HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\value, number, 100"]

%tmp = %System["WinReg, SetValue, \\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\value, string, data"]

%tmp = %System["WinReg, SetValue, \\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\value, number, 100"]

$System[WinReg, GetValue, keypath ]

examples:

$strval = $System["WinReg, GetValue, HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\strvalue"]

%numval = %System["WinReg, GetValue, HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\numvalue"]

$strval = $System["WinReg, GetValue, \\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\strvalue"]

%numval = %System["WinReg, GetValue, \\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\numvalue"]

$System[WinReg, DeleteValue, keypath ]

examples:

 %tmp = %System["WinReg, DeleteValue, HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\strvalue"]

%tmp = %System["WinReg, DeleteValue, \\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\strvalue"]

$System[WinReg, GetValueType, keypath ]

examples:

$type = $System["WinReg, GetValue, HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\strvalue"]

%type = %System["WinReg, GetValue, HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\strvalue"]

$type = $System["WinReg, GetValue, \\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\strvalue"]

%type = %System["WinReg, GetValue, \\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall\strvalue"]

Description

Enumerates the registry keys in the key specified by keypath.

Syntax

$System["WinReg, EnumKeys, keypath, position"]

Where:

Keypath: keypath: specifies the path to the registry key, composed of an optional computer name (if the key you are changing is on another computer), followed by the main key name, followed by any sub keys followed by the value name (if the key is a path to a value).

position: start at 0 for the first key and increment for next key.

Examples

$key = $System["WinReg, EnumKeys, HKEY_LOCAL_MACHINE\SOFTWARE\Knozall, 0"]

$key = $System["WinReg, EnumKeys, \\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall, 0"]

Description

Enumerates the values in the key specified by keypath.

Syntax

$System["WinReg, EnumValues, keypath, position"]

Where:

Keypath: keypath: specifies the path to the registry key, composed of an optional computer name (if the key you are changing is on another computer), followed by the main key name, followed by any sub keys followed by the value name (if the key is a path to a value).

position: start at 0 for the first key and increment for next key.

Examples

$value = $System["WinReg, EnumValues, HKEY_LOCAL_MACHINE\SOFTWARE\Knozall, 0"]

$value = $System["WinReg, EnumValues, \\computer\HKEY_LOCAL_MACHINE\SOFTWARE\Knozall, 0"]

ServiceEnum, type [, servername]

Description

Enumerates services on specified server.

Syntax

%System["WinServ, serviceenum, type, servername"]

Where:

type: specifies type of services to enum, can be "win32" for win32 (regular) services, "driver" for driver services, or "all" for all services.

servername: if specified, name of server to enum services on, if not specified, services are enumerated on local server.

Returns

%$: number of services enumerated

Remarks

Each call to this function destroys the previous ServiceEnum results.

Example

%numservices = %System["WinServ, ServiceEnum, win32"]

%numservices = %System["WinServ, ServiceEnum, support, all"]

Description

Gets service parameters retrieved by "ServiceEnum" command.

Syntax

$System["WinServ, ServiceInfo, position, serviceinfo"]

Where:

Position: start at 0, incremement for next service

serviceinfo: specifies which service parameter to return, can be:

"Does_Exist"  $%: returns “Yes” or 1 if there is a service at the specified position and “No” or 0 if there isn't a service at the specified position.

"servicename"  $: returns name of service.

"displayname"  $: returns display name of service.

"Is_Win32"  $%: returns “Yes” or 1 if service is a win32 (regular) service and “No” or 0 if it is  a driver service.

"State"  $: returns "Stopped" if service is not running, "Started" if the service is running, "Paused" if the service is paused, or "Unknown" if unknown

Returns

Depends on serviceinfo, always returns "Not_Found" for $ or -1 for % if no more services left.

Example

$servicename = $System["WinServ, ServiceInfo, 0, servicename"]

Description

Syntax

$System[“WinShell, Action, spec”]

Where:

parameters:

maingroup: one of the following: "Desktop", "NetHood", "Programs", "Start Menu", "Startup", "Common Programs",“Common Desktop", "Common Start Menu", "Common Startup"

groupname: name of group, can include backslashes for hierarchical groups.

itemname: name of item

grouppath: maingroup\groupname

itempath: grouppath\itemname

Action

Parameter

Description

CreateGroup

Location\Groupname

Creates program group in specified location named Groupname.

CreateGroup

Common Desktop\Groupname

 

CreateGroup

Common StartMenu\Groupname

 

CreateGroup

Common Startup\Groupname

 

CreateGroup

Desktop\Groupname

 

CreateGroup

Nethood\Groupname

 

CreateGroup

Start Menu\Groupname

 

CreateGroup

Startup\Groupname

 

CreateGroup

Programs\Groupname

 

ShowGropu

Maingroup\Groupname

 

DeleteGroup

Maingroup\Groupname

 

DeleteItem

Maingroup\Groupname\Itemname

 

AddItem

Maingroup\Groupname\Itemname, Args:args

args:args (command-line arguments, default is no args)

notes: group must already exist

AddItem

Maingroup\Groupname\Itemname, Iconpath:iconpath

iconpath:iconpath (path of file that contains icon, default is target)

AddItem

Maingroup\Groupname\Itemname, IconIndex:index

iconindex:iconindex   (index of icon in icon file, default is 0)

AddItem

Maingroup\Groupname\Itemname, Workdir:workdir

workdir:workdir   (working directory, default is no working directory)

AddItem

Maingroup\Groupname\Itemname, ShowCmd:Normal|Minimized|Maximized

showcmd:showcmd   (show command, default is "normal")- can be "normal", "minimized", or "maximized"

Examples

$System[WinShell, CreateGroup, location \groupname ]

name of group can include backslashes for hierarchical groups

examples:

$System["WinShell, CreateGroup, Programs\knozall"]

$System["WinShell, CreateGroup, Common Programs\knozall"]

$System[WinShell, CreateGroup, Common Desktop\Groupname ]

name of group can include backslashes for hierarchical groups

$System[WinShell, CreateGroup, Common Start Menu\Groupname ]

name of group can include backslashes for hierarchical groups

$System[WinShell, CreateGroup, Common Startup\Groupname ]

name of group can include backslashes for hierarchical groups

$System[WinShell, CreateGroup, Desktop\Groupname ]

name of group can include backslashes for hierarchical groups

$System[WinShell, CreateGroup, Nethood\Groupname ]

name of group can include backslashes for hierarchical groups

$System[WinShell, CreateGroup, Start Menu\Groupname ]

name of group can include backslashes for hierarchical groups

$System[WinShell, CreateGroup, Startup\Groupname ]

name of group can include backslashes for hierarchical groups

$System[WinShell, CreateGroup, Programs\Groupname ]

name of group can include backslashes for hierarchical groups

$System[WinShell, ShowGroup, Maingroup\Groupname ]

$System[WinShell, DeleteGroup, Maingroup\Groupname ]

examples:

$System["WinShell, DeleteGroup, Programs\knozall"]

$System["WinShell, DeleteGroup, Common Programs\knozall"]

$System[WinShell, DeleteItem, Maingroup\Groupname\Itemname ]

examples:

$System["WinShell, DeleteItem, Programs\knozall\File Wizard V"]

$System["WinShell, DeleteItem, Common Programs\knozall\File Wizard V"]

$System[WinShell, AddItem, Maingroup\Groupname\Itemname, Args:args, ]

command-line arguments, default is no args

$System[WinShell, AddItem, Maingroup\Groupname\Itemname, Iconpath:iconpath, ]

path of file that contains icon, default is target

examples:

 $System["WinShell, AddItem, Programs\knozall\File Wizard V, c:\program files\file wizard\filewiz.exe"]

 $System["WinShell, AddItem, Common Programs\knozall\File Wizard V, c:\program files\file wizard\filewiz.exe"]

$System[WinShell, AddItem, Maingroup\Groupname\Itemname, IconIndex:index,]

Index of icon in icon file, default is 0

$System[WinShell, AddItem, Maingroup\Groupname\Itemname, Workdir:workdir]

Working directory, default is no working directory

$System[WinShell, AddItem, Maingroup\Groupname\Itemname, ShowCmd: Normal | Minimized | Maximized]

Show command, default is normal”, can be normal”, minimized”, or maximized”.

Description

Windows system functions commands. Can be used to exit windows, or shut down the system with various options.

Syntax

%System[“WinSys, Action, Option”]

Action

Option

Description

ExitWindows

 

Exits Windows

Poweroff

Shut down the system and turn off the power.

Logoff

Logoff the current user.

Reboot

Shut down the system then reboot.

Shutdown

Shut down the system to a point where it is safe to turn off the power.

ShutdownSystem NT Only

 

Initiates a shut down of the specified system and displays a dialog box with a timeout to the user.

Servername:servername

"servername:", followed by server name, specifies which server to shutdown, default is local system

Message:message

"message:", followed by message specifies the message that is shown to the user, default is no message

Timeout:nn

"timeout:", followed by number of seconds before timing out. specifies number of seconds that the shutdown dialog box should be displayed, if 0, the dialog box is not displayed and the shutdown cannot be aborted, default is 300 seconds (5 minutes)

Force_Close

"force_close" forces applications that have unsaved changes to close (this is not recommended), default will prompt the user to close the applications

Reboot

"reboot" reboots the system after shutting down, default is shut down and displays a message indicating that it is safe to power down

AbortShutdown NT Only

 

Aborts the shutdown started by the “ShutdownSystem" command

servername

servername: if specified, name of server to abort shutdown on, if not specified, shutdown is aborted on local server

Examples

Examples: ExitWindows

%tmp = %System["WinSys, ExitWindows, poweroff"]

%tmp = %System["WinSys, ExitWindows, reboot"]

Examples: ShutdownSystem

%tmp = %System["WinSys, ShutdownSystem"]

%tmp = %System["WinSys, ShutdownSystem, servername:quantum"]

%tmp = %System["WinSys, ShutdownSystem, servername:quantum, reboot"]

Remarks

This shutdown cannot be aborted by the user (unless they have some other program that will abort it such as shutdown.exe that comes with the NT resource kit), it must be aborted by the "AbortShutdown" command

Example: AbortShutdown

%tmp = %System[“WinSys, Abortshutdown, servername:quantum”]

 


 

 


Last updated 11/11/2009
©2009 Knozall Software, Inc.,  (800) 333 8698   (520) 426-3859
9386 N. Linnet Road, Casa Grande, Arizona 85294