{"_id":"@astronautlabs/windows","_rev":"1-68bd1f0d24ae0ef6c45f51dfd5c7ebe3","name":"@astronautlabs/windows","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@astronautlabs/windows","version":"0.0.1","description":"Windows services, event logging, UAC, and utilities","publishConfig":{"access":"public"},"keywords":["windows","service","daemon","logging","event","event viewer","event logging","uac"],"author":{"name":"Astronaut Labs, LLC, Corey Butler","email":"corey@coreybutler.com"},"main":"dist/index.js","dependencies":{"@alterior/command-line":"^3.2.0","rxjs":"^7.8.1","xml":"1.0.1"},"devDependencies":{"@types/node":"^20.11.25","@types/xml":"^1.0.11","@types/yargs":"^17.0.32","typescript":"^5.4.2"},"scripts":{"build":"tsc -b","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git://github.com/astronautlabs/windows.git"},"license":"MIT","os":["win32"],"_id":"@astronautlabs/windows@0.0.1","gitHead":"5eb0cc8e0dae34cc1ce78718ce385330f0f96a1a","bugs":{"url":"https://github.com/astronautlabs/windows/issues"},"homepage":"https://github.com/astronautlabs/windows#readme","_nodeVersion":"18.19.0","_npmVersion":"9.9.2","dist":{"integrity":"sha512-09GJTeRH2JlEiDpgItv/oPhAUgYIzIJk5LSB6qMEDbyfz1dkbSCFls/5JFAcj1hlztr1rvLg/pDq03ESEZ+5Ww==","shasum":"93e8c837a5513cfff44990c733587659096a1401","tarball":"https://registry.npmjs.org/@astronautlabs/windows/-/windows-0.0.1.tgz","fileCount":33,"unpackedSize":132837,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHs8791gSNCysAd6IKpTMp6Za/+4sOUq+XvyDSeS5EydAiEAiveedV0Eb5FwBIxIgjj+i0EsPON0euedEb3W/05CZ+s="}]},"_npmUser":{"name":"rezonant","email":"wilahti@gmail.com"},"directories":{},"maintainers":[{"name":"rezonant","email":"wilahti@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/windows_0.0.1_1710105218745_0.8985804601047813"},"_hasShrinkwrap":false},"0.0.2":{"name":"@astronautlabs/windows","version":"0.0.2","description":"Windows services, event logging, UAC, and utilities","publishConfig":{"access":"public"},"keywords":["windows","service","daemon","logging","event","event viewer","event logging","uac"],"author":{"name":"Astronaut Labs, LLC, Corey Butler","email":"corey@coreybutler.com"},"main":"dist/index.js","dependencies":{"@alterior/command-line":"^3.2.0","rxjs":"^7.8.1","xml":"1.0.1"},"devDependencies":{"@types/node":"^20.11.25","@types/xml":"^1.0.11","@types/yargs":"^17.0.32","typescript":"^5.4.2"},"scripts":{"build":"tsc -b","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git://github.com/astronautlabs/windows.git"},"license":"MIT","os":["win32"],"_id":"@astronautlabs/windows@0.0.2","gitHead":"1ca6b3eae87dd459bc68129cbf9d5d4e0c3fdf79","types":"./dist/index.d.ts","bugs":{"url":"https://github.com/astronautlabs/windows/issues"},"homepage":"https://github.com/astronautlabs/windows#readme","_nodeVersion":"18.19.0","_npmVersion":"9.9.2","dist":{"integrity":"sha512-AVPbPx5Q484WUkxFnfcPR+U3UgBRadZgoVTfBnd8rVI837xRf1U94aUUtQTRREJDJglcEaLDb8VnlpEByC1TfA==","shasum":"c7d2b53c196eb8658a2eeb290b6170e968f8c0a7","tarball":"https://registry.npmjs.org/@astronautlabs/windows/-/windows-0.0.2.tgz","fileCount":57,"unpackedSize":168275,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD9EgcsE+pbGyuBsRF8gdchiDvDrePzt5jh6wj6273W6AIhAIiPn1TC21bEgghGDN4gcCiLrAPPzDVavxGOZ6d9VBfR"}]},"_npmUser":{"name":"rezonant","email":"wilahti@gmail.com"},"directories":{},"maintainers":[{"name":"rezonant","email":"wilahti@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/windows_0.0.2_1710105384442_0.1430567075218958"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-10T21:13:38.639Z","0.0.1":"2024-03-10T21:13:38.930Z","modified":"2024-03-10T21:16:25.250Z","0.0.2":"2024-03-10T21:16:24.620Z"},"maintainers":[{"name":"rezonant","email":"wilahti@gmail.com"}],"description":"Windows services, event logging, UAC, and utilities","homepage":"https://github.com/astronautlabs/windows#readme","keywords":["windows","service","daemon","logging","event","event viewer","event logging","uac"],"repository":{"type":"git","url":"git://github.com/astronautlabs/windows.git"},"author":{"name":"Astronaut Labs, LLC, Corey Butler","email":"corey@coreybutler.com"},"bugs":{"url":"https://github.com/astronautlabs/windows/issues"},"license":"MIT","readme":"# @/windows\r\n\r\n[![npm](https://img.shields.io/npm/v/@astronautlabs/windows)](https://npmjs.com/package/@astronautlabs/windows)\r\n\r\nWindows related utilities for Node.js\r\n- Manage Windows services written using Node.js\r\n- Use UAC to elevate permissions\r\n- Send events to Windows' built-in Event Viewer logging system\r\n- Manage Windows processes\r\n\r\n# Windows Services\r\n\r\n```typescript\r\nimport { Service } from '@astronautlabs/windows';\r\n\r\nconst service = new Service({\r\n  id: 'myservice',\r\n  name: 'My Service',\r\n  description: 'A description for my service',\r\n  script: 'C:\\\\path\\\\to\\\\script.js'\r\n});\r\n\r\nawait service.install();\r\nawait service.start();\r\n```\r\n\r\n## How it works\r\n\r\nThe [winsw](https://github.com/kohsuke/winsw) utility is used to create a unique `.exe` for each Node.js script \r\ndeployed as a service. A directory called `winservice` is created and populated with `myappname.exe` and `myappname.xml`. \r\nThe XML file is a configuration for the executable. `winsw` will also create logs for itself in this directory.\r\nThe `winsw` executable will run a wrapper script provided by this library, which calls the script you've defined. The \r\nwrapper provides monitoring and automatic restarting of your script since Windows own functionality is somewhat limited.\r\n\r\n# Event Logging\r\n\r\nThis library provides the ability to write into the Windows event log (as seen in Event Viewer).\r\n\r\n```typescript\r\nimport { EventLogger } from '@astronautlabs/windows');\r\n\r\nconst log = new EventLogger('Hello World');\r\n\r\nlog.info('Basic information.');\r\nlog.warn('Watch out!');\r\nlog.error('Something went wrong.');\r\nlog.auditSuccess('AUser Login Success');\r\nlog.auditFailure('AUser Login Failure');\r\n```\r\n\r\nEach log type (info, warn, error, auditSuccess, and auditFailure) can also accept an event code. By default, the event \r\ncode is `1000`. To provide a custom event code with a log message and write that message to the console, the following code could\r\nbe used:\r\n\r\n```js\r\nlog.info('Something different happened!', 700, function(){\r\n  console.log('Something different happened!');\r\n});\r\n```\r\n\r\nThe value of `code` can be between 0 and 1000.\r\n\r\nBy default, event logs are sent to the `APPLICATION` log. You can also send to the `SYSTEM` log.\r\n\r\n```typescript\r\nimport { EventLogger } from '@astronautlabs/windows';\r\nconst log = new EventLogger({\r\n  source: 'My Event Log',\r\n  eventLog: 'SYSTEM'\r\n});\r\n```\r\n\r\n# Additional Utilities\r\n\r\nIncludes a number of Windows-specific utilities as well.\r\n\r\n## `elevate(cmd, ...)`\r\n\r\nRun a command as the administrator user (will show a UAC prompt if process is not already\r\nrunning as an administrator and the current user has permission to perform UAC).\r\n\r\n## `isAdminUser()`\r\n\r\nDetermine whether the current user has administrative privileges.\r\n\r\n```typescript\r\nimport { isAdminUser } from '@astronautlabs/windows';\r\nlet isAdmin = await isAdminUser();\r\n```\r\n\r\n## `taskList()`\r\n\r\nList currently running processes.\r\n\r\n```typescript\r\nimport { taskList } from '@astronautlabs/windows';\r\n\r\nconsole.dir(await taskList());\r\n\r\n/*\r\n[\r\n  {\r\n    imageName: 'cmd.exe',\r\n    pid: '12440',\r\n    sessionName: 'Console',\r\n    sessionNumber: '1',\r\n    memUsage: '1,736 K'\r\n  }\r\n]\r\n*/\r\n```\r\n\r\n## `taskKill()`\r\n\r\nKill a process by `PID`.\r\n\r\n```typescript\r\nimport { taskKill } from '@astronautlabs/windows';\r\nawait taskKill(12345);\r\n```\r\n\r\n# Provenance\r\n\r\nThis library is based on the [`node-windows`](https://github.com/coreybutler/node-windows) package authored by \r\n[Corey Butler](https://github.com/coreybutler).","readmeFilename":"README.md"}