Java modifies the Windows registry to implement the boot-up application.

Source: Internet
Author: User

Using Java to modify the Windows registry, the most basic is the cmd command.

The case and run results are as follows:

 Packageday01;Importjava.io.IOException;/* 1,reg Add a new subkey or item to the registry syntax: REG ADD KeyName [/V entryname|/ve] [/t DataType] [/s Separato R] [/D value] [/f] parameter KeyName Specifies the full path of the subkey. For a remote computer, include the computer name before the subkey path in \\ComputerName\PathToSubkey. Ignoring computername causes the local computer to operate by default. Start the path in the appropriate subtree. Valid subtree is HKLM, HKCU, HKCR, HKU, and HKCC.   Only HKLM and HKU on the remote machine. Value Description hkcr:hkey_classes_root hkcu:hkey_current_user hklm:hkey_local_machine hku:hkey_users hkcc:hkey_current   _config/v EntryName Specifies the name of the item to add to the specified subkey.   /VE specifies that entries added to the registry are null values. /t DataType specifies the data type of the item value. The datatype can be of several types: REG_SZ REG_MULTI_SZ Reg_dword_big_endian REG_DWORD REG_Binary Reg_dword_little_endian REG _link Reg_full_resource_descriptor reg_expand_sz/s separator Specifies the characters used to separate multiple data instances. Use this parameter when REG_MULTI_SZ is specified as a data type and you need to list multiple items.   If not specified, the default delimiter will be used as "\".   /d value Specifies the value of the new registry key.   /F Add a subkey or item directly without asking for information.   /?   Displays help at the command prompt. Note This operation cannot add subtrees.   This version of Reg does not require a request for confirmation when adding subkeys. The following table lists the return values for the REG add operation. Value Description 0 Success 1 Failure */ Public classTest00 {/*** Reg Parameter description */v The value name to be added or removed under the selected */t RegKey data type (REG_SZ string) */d to be assigned to the added registry ValueName data */F forcibly delete without prompting*/        Public Static voidChangestart (BooleanIsstartatlogon)throwsioexception{String RegKey= "Hkey_current_user\\software\\microsoft\\windows\\currentversion\\run"; String Myappname= "Mgtest"; String ExePath= "\" D:\\Program Files (x86) \\love\\HelloWorld.exe\ ""; Runtime.getruntime (). EXEC ("Reg" + (Isstartatlogon? ") Add ":" delete ") +regkey+"/V "+myappname+ (Isstartatlogon?"/t reg_sz/d "+exepath:"/F ")); }               Public Static voidMain (string[] args)throwsIOException {Try{Changestart (true); } Catch(IOException e) {//Changestart (false);E.printstacktrace (); }     }    }

Java modifies the Windows registry to implement the boot-up application.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.