summaryrefslogtreecommitdiff
path: root/scripts/win_run
diff options
context:
space:
mode:
authorKyren223 <contact@kyren.codes>2025-12-04 17:11:32 +0200
committerKyren223 <contact@kyren.codes>2025-12-04 17:11:32 +0200
commit2f31cec8bf0dada93591b5b072efdde774ec367b (patch)
tree87517d1062c163c3ce9ea0cb5fcf309026867cec /scripts/win_run
parent66d6077b736b6e590b0525e2ff6639ce5f0dc8e4 (diff)
Added stupid winrun, doesn't even work
Diffstat (limited to 'scripts/win_run')
-rwxr-xr-xscripts/win_run33
1 files changed, 33 insertions, 0 deletions
diff --git a/scripts/win_run b/scripts/win_run
new file mode 100755
index 0000000..874c9c8
--- /dev/null
+++ b/scripts/win_run
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 <command>"
+ exit 1
+fi
+
+VM_NAME=win11-dev
+COMMAND=$1
+
+# Execute command in VM
+PID=$(sudo virsh qemu-agent-command "$VM_NAME" --pretty \
+ "{\"execute\":\"guest-exec\", \"arguments\":{\"path\":\"C:\\\\Windows\\\\System32\\\\cmd.exe\", \"arg\":[\"/c\", \"$COMMAND\"], \"capture-output\":true}}" \
+ | jq -r '.return.pid')
+
+if [ -z "$PID" ]; then
+ echo "Error: Failed to execute command"
+ exit 1
+fi
+
+# Check command status and get output
+sleep 1
+OUTPUT=$(sudo virsh qemu-agent-command "$VM_NAME" --pretty \
+ "{\"execute\":\"guest-exec-status\", \"arguments\":{\"pid\":$PID}}" \
+ | jq -r '.return | select(.exited == true) | .["out-data"]')
+
+if [ -z "$OUTPUT" ]; then
+ echo "Error: Command not completed or failed"
+ exit 1
+fi
+
+# Decode base64 output
+echo -n "$OUTPUT" | base64 -d