nightytidy 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/agent/service.js +4 -2
- package/src/agent/setup-flow.js +16 -6
package/package.json
CHANGED
package/src/agent/service.js
CHANGED
|
@@ -100,8 +100,10 @@ const STARTUP_VBS = path.join(STARTUP_DIR, 'NightyTidy Agent.vbs');
|
|
|
100
100
|
function _registerWindows(cmd) {
|
|
101
101
|
// Primary: Startup folder (no admin required)
|
|
102
102
|
try {
|
|
103
|
-
// VBS wrapper runs the agent without showing a console window
|
|
104
|
-
|
|
103
|
+
// VBS wrapper runs the agent without showing a console window.
|
|
104
|
+
// In VBS, quotes inside strings are doubled: "" not \"
|
|
105
|
+
const vbsCmd = cmd.replace(/"/g, '""');
|
|
106
|
+
const vbs = `' NightyTidy Agent - auto-start on login\r\nSet ws = CreateObject("WScript.Shell")\r\nws.Run "${vbsCmd}", 0, False\r\n`;
|
|
105
107
|
fs.mkdirSync(STARTUP_DIR, { recursive: true });
|
|
106
108
|
fs.writeFileSync(STARTUP_VBS, vbs, 'utf-8');
|
|
107
109
|
debug('Registered via Windows Startup folder');
|
package/src/agent/setup-flow.js
CHANGED
|
@@ -12,6 +12,7 @@ import { createServer } from 'node:http';
|
|
|
12
12
|
import { spawn } from 'node:child_process';
|
|
13
13
|
import { fileURLToPath } from 'node:url';
|
|
14
14
|
import path from 'node:path';
|
|
15
|
+
import os from 'node:os';
|
|
15
16
|
import chalk from 'chalk';
|
|
16
17
|
import { getConfigDir, ensureConfigDir } from './config.js';
|
|
17
18
|
import { registerService } from './service.js';
|
|
@@ -176,12 +177,21 @@ export async function setupAgent() {
|
|
|
176
177
|
|
|
177
178
|
console.log(chalk.bold('\nStep 4: Start agent'));
|
|
178
179
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
if (process.platform === 'win32' && serviceResult.success) {
|
|
181
|
+
// On Windows, launch via the VBS script we just registered — this is the
|
|
182
|
+
// only way to start a Node.js process with NO visible console window.
|
|
183
|
+
const vbsPath = path.join(
|
|
184
|
+
os.homedir(), 'AppData', 'Roaming', 'Microsoft', 'Windows',
|
|
185
|
+
'Start Menu', 'Programs', 'Startup', 'NightyTidy Agent.vbs',
|
|
186
|
+
);
|
|
187
|
+
spawn('wscript', [vbsPath], { detached: true, stdio: 'ignore' }).unref();
|
|
188
|
+
} else {
|
|
189
|
+
// Unix or fallback: spawn directly (no console window issue on Unix)
|
|
190
|
+
spawn(process.execPath, [BIN_PATH, 'agent'], {
|
|
191
|
+
detached: true,
|
|
192
|
+
stdio: 'ignore',
|
|
193
|
+
}).unref();
|
|
194
|
+
}
|
|
185
195
|
console.log(chalk.green(' Agent started'));
|
|
186
196
|
|
|
187
197
|
// ── Done ──────────────────────────────────────────────────────────────────
|