-1

I am using raspberry Pi as a webcam server in my windows PC. It is working fine and I am able to use my raspberry Pi camera in Skype, Google meet etc but one thing that I want to improve is simultaneously stopping it or shutting down my Pi when I shut down my Windows PC. I even made a shell script and under Window Settings Scripts(Startup/Shutdown) I added the script inside shutdown but still it didnt work. Although strange thing is that, the command got executed as the below lines

this is in the first line
this is in the second line

got printed in a text file xy.txt inside this folder

C:\WINDOWS\System32\GroupPolicy\Machine\Scripts\Shutdown

This is my script

@echo off
start "C:\Program Files\PuTTY" plink.exe -no-antispoof -ssh pi@192.168.1.30 -pw mypassword sudo shutdown now
(echo this is in the first line) > xy.txt
(echo this is in the second line) >> xy.txt
exit

Is there any other elegant way to get this done.

3

My guess is that your script runs exit before establishing the connection to the Pi. Try

@echo off
start /wait "C:\Program Files\PuTTY" plink.exe -no-antispoof -ssh pi@192.168.1.30 -pw mypassword sudo shutdown now
(echo this is in the first line) > xy.txt
(echo this is in the second line) >> xy.txt
exit
| improve this answer | |
  • 1
    Thanks. I will try this and let you know. – Amit Ray Jul 14 at 21:11
  • 1
    It worked after making those changes. Thanks. – Amit Ray Jul 15 at 6:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.