Software greening dos command path

  
Software greening using bat files, will inevitably involve access to various paths, such as installation paths, system directories and the like. These are mainly through relative paths and environmental variables. For example, the following directory structure SogouInput\\ \\6.6.0.9394\\ \\6.6.0.9394\\SogouPy.ime \\6.6.0.9394\\SogouTSF.dll \\scd\\ 1.reg env.ini scdlist.ini Install .bat to run the installation .bat, due to Do some sensitive operations, so you must run with administrator privileges, otherwise you can not register the DLL, write the registry, copy the file to the system directory, but after running with administrator privileges, the current directory is changed to System32 under the system directory, which is the cmd command. The path, so you need to switch the current path. First switch to the current directory, which is ogouInput\\, use cd /d %~dp0 rem to switch to the current directory. The directory for SogouPy.ime is 6.6.0.9394\\SogouPy.ime, and the directory for SogouTSF.dll is 6.6.0.9394\\SogouTSF. Dll, others and so on SogouPy.ime needs to be copied to the system directory, you must use the environment variable copy 6.6.0.9394\\SogouPy.ime %WINDIR%\\System32\\SogouPy.ime rem Copy the file to the system System32 copy env.ini %UserProfile %\\AppData\\LocalLow\\SogouPY\\env.ini rem Copy to AppData\\LocalLow\\ under the user folder start %WINDIR%\\explorer.exe rem Restart the explorer.exe desktop process in the system directory Complete Sogou input method bat file [plain] cd /d %~dp0 rem Switch to the current directory. Since it runs with administrator privileges, I don't know why. The current directory is changed to System32 under the system directory, not the directory where the bat file is located. taskkill explorer.exe rem End desktop process
Copyright © Windows knowledge All Rights Reserved