github.com/iDigitalFlame/xmt@v0.5.4/device/xy_windows_crypt.go (about) 1 //go:build windows && crypt 2 // +build windows,crypt 3 4 // Copyright (C) 2020 - 2023 iDigitalFlame 5 // 6 // This program is free software: you can redistribute it and/or modify 7 // it under the terms of the GNU General Public License as published by 8 // the Free Software Foundation, either version 3 of the License, or 9 // any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program. If not, see <https://www.gnu.org/licenses/>. 18 // 19 20 package device 21 22 import ( 23 "os" 24 25 "github.com/iDigitalFlame/xmt/util/crypt" 26 ) 27 28 var ( 29 // ShellArgs is the default machine specific command shell arguments to run 30 // commands. 31 ShellArgs = "/c" 32 // PowerShell is the path to the PowerShell binary, which is based on the 33 // underlying OS type. 34 PowerShell = crypt.Get(42) // powershell.exe 35 debugDlls = crypt.Get(43) // hal.dll\nwmi.dll\nwpx.dll\nwdc.dll\nzipfldr.dll\ninput.dll\nspp.dll 36 37 ) 38 39 func shell() string { 40 if s, ok := os.LookupEnv(crypt.Get(44)); ok { // ComSpec 41 return s 42 } 43 if d, ok := os.LookupEnv(crypt.Get(45)); ok { // WinDir 44 p := d + crypt.Get(46) // \system32\cmd.exe 45 if s, err := os.Stat(p); err == nil && !s.IsDir() { 46 return p 47 } 48 } 49 return crypt.Get(47) // %WinDir%\system32\cmd.exe 50 } 51 52 // UserHomeDir returns the current user's home directory. 53 // 54 // On Unix, including macOS, it returns the $HOME environment variable. 55 // On Windows, it returns %USERPROFILE%. 56 // On Plan 9, it returns the $home environment variable. 57 // On JS/WASM it returns and empty string. 58 // 59 // Golang compatibility helper function. 60 func UserHomeDir() string { 61 return os.Getenv(crypt.Get(48)) // USERPROFILE 62 }