RaggieScript
›
Windows, MSI SQL & Native FFI
7 min read
Module: raggiesoft.raggiescript
F1: IDH_RSSC_NS_PROC_FFI (0x200B)
proc.*, ffi.*, rm.*, shortcut.*, shell.*, env.*, arp.*, svc.*, task.*, firewall.* & acl.*
This chapter documents every Windows process, 64-bit native DLL FFI, Restart Manager, shell integration, environment PATH, Installed apps (ARP), Windows Service, Scheduled Task, Defender Firewall, and NTFS ACL API in RaggieScript v1.0.
proc.* & rm.* — Process Execution, Explorer De-Elevation & Restart Manager (14 Methods)
Important
Why token: Token.Desktop Matters on Finish Screens : When an elevated Setup.exe (High integrity Admin token) launches a user desktop app directly via CreateProcessW, the app inherits the Admin token—breaking Windows Explorer drag-and-drop (UIPI) and writing %LOCALAPPDATA% configs owned by Administrators! Passing token: Token.Desktop duplicates the interactive explorer.exe shell's medium-integrity token (CreateProcessWithTokenW), launching the app cleanly as the signed-in desktop user!
Method Signature Return Mutating? Description
proc.isRunningproc.isRunning(exeName: string)boolRead-Only Snapshots running processes (CreateToolhelp32Snapshot) to check if exeName is active.
proc.listRunningproc.listRunning(filterSubstr?: string)arrayRead-Only Returns array of { pid, name } maps for active processes.
proc.runproc.run(exe: path, args?: string, wait?: bool, hidden?: bool, token?: string, workDir?: path, timeoutMs?: int)intHost Launches exe under Token.Current, Token.Elevated, or Token.Desktop; returns exit code when wait: true (or 0 when wait: false).
proc.execproc.exec(exe: path, ...)intHost Alias for proc.run(...).
proc.openproc.open(urlOrDoc: string, args?: string)boolHost Opens an https:// URL, custom URI (raggiesoft-books://...), or document via ShellExecuteExW.
proc.shellOpenproc.shellOpen(urlOrDoc: string, args?: string)boolHost Alias for proc.open(...).
proc.terminateproc.terminate(exeName: string, exitCode?: int)boolMutating (RSW701) Force-terminates matching processes (prefer proc.restartManagerShutdown first!).
proc.callDllIntproc.callDllInt(dllName: string, exportName: string, ...intArgs)intHost Calls a native 64-bit C ABI DLL export with integer arguments and returns int64.
proc.getLockingProcessesproc.getLockingProcesses(filePaths: array)arrayRead-Only Queries Windows Restart Manager (Rstrtmgr.dll!RmGetList) and returns { pid, appName, serviceShortName }[] locking filePaths.
proc.restartManagerShutdownproc.restartManagerShutdown(filePaths: array, forceUnresponsive?: bool)boolMutating (RSW701) Gracefully closes applications/services holding locks on filePaths via RmShutdown (saving WM_QUERYENDSESSION state!).
proc.restartManagerRestartproc.restartManagerRestart()boolMutating (RSW701) Restarts applications closed during the active Restart Manager session (RmRestart).
rm.getLockingProcessesrm.getLockingProcesses(filePaths: array)arrayRead-Only Clean alias for proc.getLockingProcesses(filePaths).
rm.shutdownrm.shutdown(filePaths: array, force?: bool)boolMutating (RSW701) Clean alias for proc.restartManagerShutdown(filePaths, force).
rm.restartrm.restart()boolMutating (RSW701) Clean alias for proc.restartManagerRestart().
ffi.* — Native 64-Bit DLL Foreign Function Interface (1 Method)
ffi.call loads any native 64-bit (x64 or ARM64 matching host) DLL and marshals int/uint/ptr, UTF-8 str, and UTF-16 wstr arguments over the platform ABI (Microsoft x64 or AAPCS64 on ARM64):
Method Signature Return Description
ffi.callffi.call(dllName: string, funcName: string, returnType: string, args: array)anyreturnType: "int", "uint", "bool", "ptr", "str", "wstr", or "void". Strings inside args marshal automatically as wide UTF-16 pointers (LPCWSTR) when funcName ends with 'W', or UTF-8 (LPCSTR) otherwise!
shortcut.* & shell.* — .lnk Shortcuts, File Types & URI Protocols (6 Methods)
Method Signature Return Mutating? Description
shortcut.createshortcut.create(location: any, name: string, target: path, args?: string, description?: string, iconPath?: path, workDir?: path)pathMutating (RSW701) Creates a COM IShellLinkW .lnk file in "Desktop", "StartMenu", "PublicDesktop", "CommonStartMenu", or an explicit folder path (rollback-tracked!).
shortcut.removeshortcut.remove(lnkPath: path)boolMutating (RSW701) Removes a .lnk shortcut file.
shell.registerFileTypeshell.registerFileType(ext: string, progId: string, description: string, target: path, iconPath?: path, verbArgs?: string)boolMutating (RSW701) Registers .ext + ProgID cleanly under Software\Classes (HKCU for Scope.User, HKLM for Scope.Machine—zero legacy pipe-delimited parsing bugs!).
shell.unregisterFileTypeshell.unregisterFileType(ext: string, progId: string)boolMutating (RSW701) Removes .ext and ProgID registration keys.
shell.registerProtocolshell.registerProtocol(scheme: string, description: string, targetExe: path)boolMutating (RSW701) Registers a custom scheme:// URL protocol (URL Protocol = "", shell\open\command).
shell.refreshshell.refresh()boolSafe Notify Broadcasts SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST) so Explorer icons update immediately.
env.* & arp.* — Non-Clobbering PATH & Windows Installed Apps (7 Methods)
Method Signature Return Mutating? Description
env.getenv.get(name: string, scope?: string)stringRead-Only Reads process, "user", or "machine" environment variable.
env.setenv.set(name: string, value: string, scope?: string)boolMutating (RSW701) Writes "user" or "machine" environment variable and broadcasts WM_SETTINGCHANGE("Environment") with timeout (SendMessageTimeoutW).
env.removeenv.remove(name: string, scope?: string)boolMutating (RSW701) Deletes environment variable (restored on rollback).
env.appendPathenv.appendPath(dirToAdd: path, scope?: string)boolMutating (RSW701) Reads raw REG_EXPAND_SZ Path, checks case-insensitively if dirToAdd is already present, appends only the new segment (preserving %SystemRoot%!), and records surgical single-entry removal for uninstall/rollback!
arp.registerarp.register(options?: map)boolMutating (RSW701) Writes CurrentVersion\Uninstall\<id>, generates <installDir>\Uninstall.exe + Uninstall.rswm, and computes EstimatedSize KB.
arp.setSystemComponentarp.setSystemComponent(productId: string, hidden: bool, scope?: string)boolMutating (RSW701) Sets SystemComponent = 1 (adopted by a Suite) or 0 (standalone visible in Installed apps ).
arp.unregisterarp.unregister(productId: string, scope?: string)boolMutating (RSW701) Removes the CurrentVersion\Uninstall\<productId> entry.
svc.*, task.*, firewall.* & acl.* — Services, Tasks, Firewall & NTFS ACLs (13 Methods)
Method Signature Return Mutating? Description
svc.existssvc.exists(serviceName: string)boolRead-Only Checks SCM (OpenServiceW) for serviceName.
svc.statussvc.status(serviceName: string)stringRead-Only Returns "running", "stopped", "paused", or "missing".
svc.installsvc.install(serviceName: string, binPath: path, displayName?: string, startType?: string, description?: string)boolMutating (RSW701) Creates or updates a Win32 Service (CreateServiceW, rolled back automatically on install failure).
svc.configureFailureResetsvc.configureFailureReset(serviceName: string, restartDelayMs?: int, resetPeriodSec?: int)boolMutating (RSW701) Configures SERVICE_CONFIG_FAILURE_ACTIONS automatic recovery restart.
svc.startsvc.start(serviceName: string)boolMutating (RSW701) Starts serviceName and waits for SERVICE_RUNNING.
svc.stopsvc.stop(serviceName: string)boolMutating (RSW701) Sends SERVICE_CONTROL_STOP and waits cleanly.
svc.removesvc.remove(serviceName: string)boolMutating (RSW701) Stops and deletes serviceName (DeleteService).
task.existstask.exists(taskName: string)boolRead-Only Checks Windows Task Scheduler for taskName.
task.createWeeklytask.createWeekly(taskName: string, exePath: path, args?: string, dayOfWeek?: string, startTime?: string)boolMutating (RSW701) Registers an opt-in weekly Scheduled Task (rollback-tracked).
task.removetask.remove(taskName: string)boolMutating (RSW701) Deletes Scheduled Task taskName.
firewall.allowProgramfirewall.allowProgram(ruleName: string, exePath: path, direction?: string)boolMutating (RSW701) Adds a Windows Defender Firewall program rule via COM INetFwPolicy2 (removed automatically on rollback/uninstall).
firewall.removeRulefirewall.removeRule(ruleName: string)boolMutating (RSW701) Removes Defender Firewall rule ruleName.
acl.grantModifyacl.grantModify(targetDir: path, trusteeSidOrWellKnown?: string)boolMutating (RSW701) Grants NTFS FILE_GENERIC_MODIFY (`OI CI) via SetNamedSecurityInfoW (defaults to "Users" / S-1-5-32-545`).
Tip
Zero-HKCR Reg-Free COM Isolation for Classic VB6 & ActiveX Apps : Instead of polluting global HKCR\CLSID keys (which causes "DLL Hell" across side-by-side versions of classic Visual Basic 6.0 / .ocx utilities like early StoreTrainer ), com.generateRegFreeManifest inspects each .dll/.ocx via oleaut32.dll!LoadTypeLibEx(..., REGKIND_NONE) and emits a deterministic Windows Side-by-Side .exe.manifest XML file!
Method Signature Return Mutating? Description
com.inspectTypeLibcom.inspectTypeLib(dllOrOcx: path)mapWizard-Safe Reads COM ITypeLib metadata via REGKIND_NONE ({ found, libId, version, libraryName, coclasses }) without touching the Registry.
com.generateRegFreeManifestcom.generateRegFreeManifest(exePath: path, comFiles: array, outManifest: path)boolMutating (RSW701) Generates a Side-by-Side .exe.manifest (<file>, <typelib>, <comClass>) for zero-Registry ActiveX/VB6 isolation (rollback-tracked).
com.registerInproccom.registerInproc(dllOrOcx: path)boolMutating (RSW701) Invokes DllRegisterServer on an in-process COM server when global registration is explicitly required.
com.unregisterInproccom.unregisterInproc(dllOrOcx: path)boolMutating (RSW701) Invokes DllUnregisterServer on an in-process COM server.
font.isInstalledfont.isInstalled(fontFileName: path, scope?: string)boolWizard-Safe Checks %LOCALAPPDATA%\Microsoft\Windows\Fonts ("user") or C:\Windows\Fonts ("machine").
font.installfont.install(fontFile: path, scope?: string, displayName?: string)pathMutating (RSW701) Copies .ttf/.otf, registers CurrentVersion\Fonts, calls AddFontResourceExW, and broadcasts WM_FONTCHANGE with zero reboot!
font.uninstallfont.uninstall(fontFileName: path, scope?: string, displayName?: string)boolMutating (RSW701) Calls RemoveFontResourceExW, deletes font entry, and broadcasts WM_FONTCHANGE.
sign.inspectsign.inspect(peFile: path)mapWizard-Safe Extracts X.509 / PKCS#7 Authenticode details via crypt32.dll ({ signed, trusted, subject, issuer, thumbprintSha1 }).
cert.isInstalledcert.isInstalled(thumbprintSha1: string, store?: string, scope?: string)boolWizard-Safe Checks CertStore.TrustedPublisher / CertStore.Root for a matching SHA-1 certificate thumbprint.
cert.importTrustedPublishercert.importTrustedPublisher(cerFile: path, scope?: string)boolMutating (RSW701) Imports a DER or Base64 PEM .cer certificate into TrustedPublisher.
cert.removecert.remove(thumbprintSha1: string, store?: string, scope?: string)boolMutating (RSW701) Deletes a certificate by SHA-1 thumbprint from the target Windows certificate store.
mutex.isHeldmutex.isHeld(mutexName: string)boolWizard-Safe Probes OpenMutexW(SYNCHRONIZE) for "Global\\..." or "Local\\..." single-instance application locks.
mutex.waitReleasemutex.waitRelease(mutexName: string, timeoutMs?: int)boolWizard-Safe Waits up to timeoutMs (default 5000) for a running application mutex to close cleanly.
activesetup.isRegisteredactivesetup.isRegistered(componentId: string)boolWizard-Safe Checks Active Setup\Installed Components\<componentId>.
activesetup.registeractivesetup.register(id: string, stubPath: string, version?: string, title?: string)boolMutating (RSW701) Registers per-machine Active Setup StubPath so every Windows user profile hydrates per-user settings on next sign-in!
activesetup.unregisteractivesetup.unregister(componentId: string)boolMutating (RSW701) Removes Active Setup Installed Components registration.
Indexed API Calls & Symbols on This Page (23):
Token.DesktopEnum
proc.isRunning(exeName)Read-Only
proc.run(exe, args?, wait?, hidden?, token?, workDir?)Host
proc.getLockingProcesses(filePaths)Read-Only
proc.restartManagerShutdown(filePaths, force?)Mutating
proc.restartManagerRestart()Mutating
ffi.call(dllName, funcName, returnType, args)Native FFI
shortcut.create(location, name, target, ...)Mutating
shell.registerFileType(ext, progId, description, target, ...)Mutating
shell.registerProtocol(scheme, description, targetExe)Mutating
env.appendPath(dirToAdd, scope?)Mutating
arp.register(options?)Mutating
arp.setSystemComponent(productId, hidden, scope?)Mutating
svc.install(serviceName, binPath, displayName?, startType?)Mutating
task.createWeekly(taskName, exePath, args?, day?, time?)Mutating
firewall.allowProgram(ruleName, exePath, direction?)Mutating
acl.grantModify(targetDir, trusteeSid?)Mutating
com.generateRegFreeManifest(exe, comFiles, outManifest)Mutating
com.inspectTypeLib / registerInproc / unregisterInprocPackaging
font.isInstalled / font.install / font.uninstallPackaging
sign.inspect / cert.isInstalled / cert.importTrustedPublisher / cert.removePackaging
mutex.isHeld / mutex.waitReleaseWizard-Safe
activesetup.isRegistered / activesetup.register / activesetup.unregisterPackaging