%% options copyright owner = Dirk Krause copyright year = 2011-2014 license = bsd %% module #include "dk3all.h" #include "dkt-version.h" #include "dkt.h" #include "dkwt.h" $!trace-include /** File name for string table file. */ static dkChar const dkwt_string_table_file_name[] = { dkT("dkwt.str") }; /** Version number string. */ static dkChar const dkwt_version[] = { dkT("dkwt ") DKT_VERSION }; /** License terms. */ static dkChar const * const dkwt_license[] = { $!text macro=dkT Copyright (c) 2011-2013, Dirk Krause All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder(s) nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $!end }; /** Message texts used by the program, localized. */ static dkChar const * const dkwt_message_texts[] = { $!string-table file=dkwt.str,macro=dkT # # 0: Attribute label: FUll user name # Full name: # # 1: Attribute label: Comment for user # Comment: # # 2: Attribute label: User comment # User comment: # # 3: Attribute label: HOme directory # Home directory: # # 4: Attribute label: User profile directory # User profile: # # 5: Attribute label: User SID # SID: # # 6: Attribute label: User type # Type: # # 7: User type: guest # Guest # # 8: User type: Normal user # User # # 9: User type: Administrator # Administrator # # 10: Attribute label: User flags. # Flags: # # 11: Account attribute: Login script executed # Login script executed. # # 12: Account attribute: Account disabled # Account disabled. # # 13: Account attribute: Home directory required # Home directory required. # # 14: Account attribute: No password required # No password required. # # 15: Account attribute: Password can not be changed # Password can not be changed. # # 16: Account attribute: Locked out # Account locked out. # # 17: Account attribute: Password does not expire # Password does not expire. # # 18: Account attribute: Encrypted text password allowd # Encrypted text password allowed. # # 19: Account attribute: Account is sensitive, no delegation # Sensitive account, no delegation. # # 20: Account attribute: Smartcard required # Smartcard required. # # 21: Account attribute: DES keys are allowed only # DES keys only. # # 22: Account attribute: No Kerberos pre-auth required # No Kerberos pre-authentication required. # # 23: Account attribute: Account is trusted for delegation # Trusted for delegation. # # 24: Account attribute: Password is expired # Password expired. # # 25: Account attribute: Trusted to authenticate for delegation # Trusted to authenticate for delegation. # # 26: Account type: Normal user account # Normal user account. # # 27: Account type: Duplicated account for user from other domain # Duplicated account for user from another domain. # # 28: Account type: Workstation trust account # Workstation trust account. # # 29: Account type: Server trust account # Server trust account. # # 30: Account type: Interdomain trust account # Interdomain trust account. # # 31: Empty string # # # 32: Operator privileges label # Operator: # # 33: Operator type: Accounts operator # Accounts operator. # # 34: Operator type: Server operator # Server operator. # # 35: Operator type: Communications operator # Communications operator. # # 36: Operator type: Print operator # Print operator. # # 37: Attribute label: Country code # Country code: # # 38: Attribute label: Code page number # Code page no.: # # 39: Attribute label: Source # Source: # # 40: Attribute label: Comment # Comment: # # 41: Source type: Net # Net # # 42: Source type: Local # Local # # 43: Attribute label: SID # SID: # # 44: Attribute label: Comment # Comment: # # 45: Attribute label: Description # Description: # # 46: Attribute label: Location # Location: # # 47: Attribute label: Server # Server: # # 48: Attribute label: Share name # Share name: # # 49: Attribute label: Port # Port: # # 50: Attribute label: Driver # Driver: # # 51: Attribute label: Device # Device: # # 52: Attribute label: Separator file # Separator file: # # 53: Attribute label: Print processor # Print processor: # # 54: Attribute label: Data type # Data type: # # 55: Attribute label: Parameters # Parameters: # # 56/57: Error message: Failed to create print file "..."! # Failed to create print file " "! # # 58: Error message: Failed to schedule print job! # Failed to schedule print job! # # 59: Error message: Failed to add print job! # Failed to add print job! # # 60/61: Error message: Failed to open printer "..."! # Failed to open printer " "! # # 62: Error message: Printer name too long! # Printer name too long! # # 63/64: Error message: No printer found for device "..."! # No printer found for device " "! # # 65: Error message: Failed to find default printer! # Failed to find default printer! # # 66: Error message: Redefinition of profile base directory! # Redefinition of profile base directory! # # 67: Error message: No profile base directory specified! # No profile base directory specified! # # 68: Error message: Syntax - Unknown section type! # Syntax error - Unknown section type! # # 69: Error message: Syntax - Incomplete section header! # Syntax error - Incomplete section header! # # 70: Error message: Syntax - Missing section header! # Syntax error - Missing section header! # # 71: Error message: Syntax - Redefinition of system user! # Syntax error - Redefinition of system user! # # 72: Error message: Syntax - Redefinition of everyone user! # Syntax error - Redefinition of everyone user! # # 73: Error message: Syntax - Unknown option! # Syntax error - Unknown option! # # 74: Error message: Syntax - Not a key/value pair! # Syntax error - Not a key/value pair! # # 75: Error message: Options -l and -s are exclusive! # Options -l and -s are exclusive! # # 76: Error message: Arguments are ignored! # Arguments are ignored! # # 77: Error message: Failed to set keep-data flag. # FAILED TO SET KEEP-DATA FLAG! # # 78: Notice: Keep-data flag was set successfully. # Keep-data flag was set successfully. # # 79/80: Execution of "..." indicated an error! # Exit status code indicates an error, program:\n" # # 81/82: Error: Failed to find name for SID "..."! # Failed to find name for SID " "! # # 83/84: Progress: Cleaning up local print queue ... . # Cleaning up local print queue " ". # # 85/86/87: Progress: Successfully deleted job ...: "...". # Successfully deleted job : " ". # # 88: Unnamed print job # Unnamed print job # # 89/90/91: Error: Failed to delete job ...: "..."! # Failed to delete job : " "! # # 92/93: Error: Failed to open printer ...! # Failed to open printer " "! # # 94: Error: Failed to enumerate local printers! # Failed to enumerate local printers! # # 95: Error: Missing user name! # Missing user name! # # 96: Progress: Print queue cleaned up successfully. # Print queue cleaned up successfully. # # 97: ERROR: Failed to send request! # Failed to send request! # # 98: ERROR: Failed to connect to remote host! # Failed to connect to remote host! # # 99: ERROR: Failed to create network socket! # Failed to create network socket! # # 100: ERROR: Failed to find IP address! # Failed to find IP address for remote host! # # 101/102: Progress: Cleaning up remote print queue ... # Cleaning up remote print queue " ". # # 103: ERROR: Request too long for buffer! # Request too long for buffer! # # 104/105: ERROR: Empty queue name in "..."! # Empty queue name in " "! # # 106/107: ERROR: Empty host name in "..."! # Empty host name in " "! # # 108/109: ERROR: Not a queue@host name: "..."! # Not a queue@host name: " "! # # 110/111: ERROR: Queue name "..." too long! # Queue name " " too long! # # 112: ERROR: Failed to initialize Windows sockets! # Failed to initialize Windows sockets! # # 113/114: Error: Error code: ... # Error code: . # # 115/116: IP address: ... # IP address: . # # 117: Warning: User profile cleanup is disabled on Windows Vista and above! # User profile cleanup is disabled on Windows Vista and above! # # 118/119: Progress: Executing command: ... # Executing command:\n # # 120/121: Progress: Remove directory: ... # Remove directory:\n # # 122/123: Progress: Remove file: ... # Remove file:\n # # 124/125/126: Progress: Delete Registry key ... # Delete registry key:\n \\ # # 127/128: DEBUG: Registry key "..." deleted. # Registry key " " deleted. # # 129/130/131: ERROR: Failed to remove registry key: # Failed to remove registry key:\n \\ # # 132/133 # Failed to open registry key:\n # # 134 # Cleaning up profiles (start). # # 135 # Internal error while retrieving directory entry name! # # 136/137 # Failed to expand string\n" ",\nresult would become too long for buffer! # # 138/139 # Subkey name too long:\n # # 140 # Skipping profile cleanup due to previous errors! # # 141 # Cleaning up profiles (finished). # # 142 # Options -u, -i, -a, and -d are mutually exlusive! # # 143 # At least one argument required! # # 144 # Missing file/directory name! $!end }; /** Keywords used by the program, not localized. */ static dkChar const * const dkwt_no_loc[] = { $!string-table macro=dkT # # 0 # # # 1 # dkwt.conf # # 2 # System # # 3 # Jeder # # 4 # RD /S /Q " # # 5 # " # # 6 # DEL /Q /F " # # 7 # CACLS.EXE " # # 8 # " /T /E /C /G # # 9 # :F # # 10 # ICACLS.EXE " # # 11 # " /grant # # 12 # :F /T /C /Q # # 13 # :F /C /Q # # 14 # " /E /C /G # # 15: Registry key name # SOFTWARE\\DKrause\\Shared\\dkwt # # 16: Registry value name: keep (for keep-directories flag) # keep # # 17: Text SID for Everyone user/group # S-1-1-0 # # 18: Text SID for SYSTEM user/group # S-1-5-18 # # 19: Registry key for profile list. # SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList # # 20: Backslash as separator. # \\ # # 21: Registry enty name. # ProfileImagePath $!end }; /** Subcommand names. */ static dkChar const * const dkwt_commands[] = { /* 0 */ dkT("boot"), /* 1 */ dkT("shutdown"), /* 2 */ dkT("login"), /* 3 */ dkT("logout"), /* 4 */ dkT("users"), /* 5 */ dkT("groups"), /* 6 */ dkT("printers"), /* 7 */ dkT("print"), /* 8 */ dkT("help"), /* 9 */ dkT("version"), /* 10 */ dkT("license-terms"), /* 11 */ dkT("keep"), /* 12 */ dkT("unkeep"), /* 13 */ dkT("--help"), /* 14 */ dkT("--version"), /* 15 */ dkT("--license-terms"), /* 16 */ dkT("--license"), /* 17 */ dkT("license"), /* 18 */ dkT("-h"), /* 19 */ dkT("-v"), /* 20 */ dkT("-L"), /* 21 */ dkT("cleanup-profiles"), /* 22 */ dkT("clp"), /* 23 */ dkT("env"), /* 24 */ dkT("environment"), NULL }; /** Help file names. */ static dkChar const * const dkwt_help_file_names[] = { /* 0 */ dkT("dkwt-boot.txt"), /* 1 */ dkT("dkwt-shutdown.txt"), /* 2 */ dkT("dkwt-login.txt"), /* 3 */ dkT("dkwt-logout.txt"), /* 4 */ dkT("dkwt-users.txt"), /* 5 */ dkT("dkwt-groups.txt"), /* 6 */ dkT("dkwt-printers.txt"), /* 7 */ dkT("dkwt-print.txt"), /* 8 */ dkT("dkwt-help.txt"), /* 9 */ dkT(""), /* unused */ /* 10 */ dkT(""), /* unused */ /* 11 */ dkT("dkwt-keep.txt"), /* 12 */ dkT("dkwt-unkeep.txt"), /* 13 */ dkT("dkwt-clp.txt"), /* 14 */ dkT("dkwt-env.txt"), NULL }; /** Help text for the boot command. */ static dkChar const * const dkwt_help_boot[] = { $!text file=dkwt-boot.txt,macro=dkT NAME dkwt boot - Boot cleanup SYNOPSIS dkwt boot [-t] DESCRIPTION The "dkwt boot" program should be run from the system boot script to do cleanup at boot time in PC classrooms. OPTIONS -t runs in test mode. The program does not perform cleanup, it only writes messages about files and directories to delete. RETURN VALUE The exit status code is always 0, regardless of any error occured. FILES dkwt.conf Configuration file for cleanup operations. Run dkwt -h to view detailed information about the dkwt.conf file. NOTES After changing the dkwt.conf file you should run dkwt boot -t to test the dkwt.conf file. AUTHOR Dirk Krause COPYRIGHT AND LICENSE Run dkwt --license-terms to see the license conditions. SEE ALSO http://dktools.sourceforge.net $!end }; /** Help text for the shutdown command. */ static dkChar const * const dkwt_help_shutdown[] = { $!text file=dkwt-shutdown.txt,macro=dkT NAME dkwt shutdown - Shutdown cleanup SYNOPSIS dkwt shutdown [-t] DESCRIPTION The "dkwt shutdown" program should be run from the system shutdown script to do cleanup at shutdown time in PC classrooms. OPTIONS -t runs in test mode. The program does not perform cleanup, it only writes messages about files and directories to delete. RETURN VALUE The exit status code is always 0, regardless of any error occured. FILES dkwt.conf Configuration file for cleanup operations. Run dkwt -h to view detailed information about the dkwt.conf file. NOTES After changing the dkwt.conf file you should run dkwt shutdown -t to test the dkwt.conf file. AUTHOR Dirk Krause COPYRIGHT AND LICENSE Run dkwt --license-terms to see the license conditions. SEE ALSO http://dktools.sourceforge.net $!end }; /** Help text for the login command. */ static dkChar const * const dkwt_help_login[] = { $!text file=dkwt-login.txt,macro=dkT NAME dkwt login - Login cleanup SYNOPSIS dkwt login [-t] DESCRIPTION The "dkwt login" program should be run from the user login script to do cleanup at login time in PC classrooms. OPTIONS -t runs in test mode. The program does not perform cleanup, it only writes messages about files and directories to delete. RETURN VALUE The exit status code is always 0, regardless of any error occured. FILES dkwt.conf Configuration file for cleanup operations. Run dkwt -h to view detailed information about the dkwt.conf file. NOTES After changing the dkwt.conf file you should run dkwt login -t to test the dkwt.conf file. AUTHOR Dirk Krause COPYRIGHT AND LICENSE Run dkwt --license-terms to see the license conditions. SEE ALSO http://dktools.sourceforge.net $!end }; /** Help text for the logout command. */ static dkChar const * const dkwt_help_logout[] = { $!text file=dkwt-logout.txt,macro=dkT NAME dkwt logout - Logout cleanup SYNOPSIS dkwt logout [-t] DESCRIPTION The "dkwt logout" program should be run from the user logout script to do cleanup at logout time in PC classrooms. OPTIONS -t runs in test mode. The program does not perform cleanup, it only writes messages about files and directories to delete. RETURN VALUE The exit status code is always 0, regardless of any error occured. FILES dkwt.conf Configuration file for cleanup operations. Run dkwt -h to view detailed information about the dkwt.conf file. NOTES After changing the dkwt.conf file you should run dkwt logout -t to test the dkwt.conf file. AUTHOR Dirk Krause COPYRIGHT AND LICENSE Run dkwt --license-terms to see the license conditions. SEE ALSO http://dktools.sourceforge.net $!end }; /** Help text for the keep command. */ static dkChar const * const dkwt_help_keep[] = { $!text file=dkwt-keep.txt,macro=dkT NAME dkwt keep - Temporarily disable automatic cleanup SYNOPSIS dkwt keep DESCRIPTION Use this program to disable automatic cleanup until (including) the next user login. You should use this command in lectures about system programming before starting to test self-made system software, drivers... Use the dkwt unkeep command to restore normal automatic cleanup when you are done with the tests. RETURN VALUE The program returns exit status code 0 on success, all other status codes indicate an error. REGISTRY The HKEY_LOCAL_MACHINE\SOFTWARE\DKrause\Shared\dkwt must exist, full access must be possible for "Everyone" or "INTERACTIVE". AUTHOR Dirk Krause COPYRIGHT AND LICENSE Run dkwt --license-terms to see the license conditions. SEE ALSO http://dktools.sourceforge.net $!end }; /** Help text for the keep command. */ static dkChar const * const dkwt_help_unkeep[] = { $!text file=dkwt-unkeep.txt,macro=dkT NAME dkwt unkeep - Restore automatic cleanup SYNOPSIS dkwt unkeep DESCRIPTION After disabling automatic cleanup temporarily using "dkwt keep" you can use this command to restore normal automatic cleanup. RETURN VALUE The program returns exit status code 0 on success, all other status codes indicate an error. REGISTRY The HKEY_LOCAL_MACHINE\SOFTWARE\DKrause\Shared\dkwt must exist, full access must be possible for "Everyone" or "INTERACTIVE". AUTHOR Dirk Krause HISTORY COPYRIGHT AND LICENSE Run dkwt --license-terms to see the license conditions. SEE ALSO http://dktools.sourceforge.net $!end }; /** Help text for the cleanup-profiles command. */ static dkChar const * const dkwt_help_clp[] = { $!text file=dkwt-clp.txt,macro=dkT NAME dkwt cleanup-profiles - Clean up profiles directories. SYNOPSIS dkwt cleanup-profiles dkwt clp DESCRIPTION On Windows Vista and above we can not clean up profile directories from boot/shutdown/logon/logoff scripts as these scripts are run from a user account with insufficient permissions. User profiles cleanup is skipped in "dkwt boot", "dkwt login", "dkwt logout", and "dkwt shutdown". You can start a command prompt *as administrator* instead and run "dkwt cleanup-profiles" from there. The program first attempts to use system functions to delete directories, additionally it uses the "RD" command. Alternatively run "dkwtadm cleanup-profiles", this variant of dkwt uses the UAC to obtain administrative permissions. RETURN VALUE The program returns exit status code 0 on success, all other status codes indicate an error. AUTHOR Dirk Krause HISTORY COPYRIGHT AND LICENSE Run dkwt --license-terms to see the license conditions. SEE ALSO http://dktools.sourceforge.net $!end }; /** Help text for dkwt env. */ static dkChar const * const dkwt_help_env[] = { $!text file=dkwt-env.txt,macro=dkT NAME dkwt env - Modify environment variables SYNOPSIS dkwt env [] [] dkwt environment [] [] DESCRIPTION This function can modify environment variables, both system and user variables. This function is mainly intended for environment variables storing names of directories or files (i.e. the PATH variable). You can make sure a directory is listed in a variable by inserting or appending the directory only if it is not yet present. OPTIONS -s Process system environment variables. Without this option the program processes the user environment. -e When creating a new registry value, use type REG_EXPAND_SZ instead of default REG_SZ. This option is ignored when processing existing registry values. -u Delete registry value completely, unset variable. -i Ensure the variable lists the specified directory or file, insert at start if not present. -a Ensure the variable lists the specified directory or file, append at end if not present. -d Remove a directory or file from a variable listing one or multiple directories or files. If the variable value is empty after removal, the registry value is deleted. RETURN VALUE The program returns exit status code 0 on success, all other status codes indicate an error. EXAMPLES Show value of user environment variable TEMP: dkwt env TEMP Show value of system environment variable PATH: dkwt env -s PATH Completely delete user environment variable FOO: dkwt env -u FOO Completely delete system environment variable BAR: dkwt env -s -u BAR Set user environment variable FOO: dkwt env FOO All text after variable name goes into value Set system environment variable BAR: dkwt env -s BAR Same procedure for system variables Make sure system PATH contains ``C:\Program Files\Nice Program'' (insert at start if not present): dkwt env -s -i Path C:\Program Files\Nice Program Make sure system PATH contains ``C:\Program Files\Other Program'' (append at end if not present): dkwt env -s -a Path C:\Program Files\Other Program Remove ``C:\Program Files\Nice Program'' from system PATH: dkwt env -s -d Path C:\Program Files\Nice Program NOTES ``dkwt env'' does not change environment variables in cmd.exe windows already opened. AUTHOR Dirk Krause HISTORY COPYRIGHT AND LICENSE Run dkwt --license-terms to see the license conditions. SEE ALSO http://dktools.sourceforge.net $!end }; /** Help text for the users command. */ static dkChar const * const dkwt_help_users[] = { $!text file=dkwt-users.txt,macro=dkT NAME dkwt users - List users SYNOPSIS dkwt users [