Windows 7 pipes and Symlink - com port - cmd

That's the situation: I've a program that sends data to a text file. Those are just information about lights state of an arcade machine. I need to send this information on a COM port, so I've replaced the txt file with a symbolic link to a pipe. I don't have access to the source code of this main program. The only way I've found to do that in Windows 10 is creating a symbolic link using pipes like this:
mklink SymlinkName \\.\pipe\pipename
Then I've create a program that reads the pipe and sends it to the COM port. It works fine on Windows 10 without any kind of problem and I've worked on that OS for my development.
Today I've tried all this stuff on the arcade machine (windows 7 Ultimate based) but the Symlink doesn't work. I can send data to my COM port simpy using command line, for example
echo foo > COM1
But if I try to do that throught the Symlink, it sais:
echo foo > Symlink
The data present in the reparse point buffer is invalid.
Any suggestion? I've already tried to Google it but no luck!

Related

Lua io.popen() - Accessing Shared Drive on Windows

I am running a Lua program on a Windows 10 machine. This Windows 10 computer is networked to another Windows 10 computer and this other computer is sharing its D: drive with my computer. The shared drive is called the O: drive by my computer.
When I open a cmd window on my computer and type:
type "O:\Data\config\file.xml"
I get the contents of file.xml in my cmd window. However, if I run this same command through Lua:
f = io.popen([["type O:\Data\config\file.xml"]])
output = f:read("*l")
Then output returns as nil.
This behavior is true of any command involving the shared O: drive, not just type. Similarly, I have some bat scripts that reference the O: drive, and I call these using os.execute, but they are not able to accomplish their task (I can see they are actually executing, just not correctly). However, if I run similar commands or scripts with the local D: or C: drives, I do not have this issue.
Any ideas as to what could be different between these two calls? Is there a different way I can call the O: drive?
My Lua application was running as a service, and I determined that when it was running as a service it was running as a 'guest' user, rather than my system user. Therefore, it did not have the appropriate permissions to run.
I modified my Windows service to run as my specific user, and this resolved the issue.

How do I autorun my Python script when I plug in my USB device?

I want to execute my Python script (at root, "autorun.pyw") whenever my USB device is plugged into a port.
I don't want to install any software. I am using Windows 10, and I have tried using an autorun.inf file.
Help would be greatly appreciated.
First Step: Install software
Restore the auto-run function To restore the "auto-run" function, the first thing we will need to do is download APO USB Autorun, a small free program that monitors the USB devices connected to the computer. Once installed, whenever you connect a USB storage device, such as a USB stick, it will check if there is an autorun.inf file inside the device and will run the configured program.
Second Step: Create autorun.inf
Create the autorun.inf file To automatically run a program from the flash drive, it needs to have two things, the program you want to run automatically and a script file that points to the program on the flash drive. Copy the executable file of the program you want to run to the pendrive. Then open the notepad, copy the text below and paste it into the notepad window to create the autorun script. [autorun]; Open = MEUAPP.exe ShellExecute = MEUAPP.exe UseAutoPlay = 1 Once you have pasted the text in the notepad, replace the text “MEUAPP” with the name of the program file you copied to the USB stick that will run automatically, as shown in the example below. Then, save the file to the USB stick named autorun.inf. Important: Make sure to select the option “All files (*. *)” In the “Type” field so that the file is saved with an INF extension and not a TXT extension. The flash drive should now contain the program's executable file and the autorun.inf file you just created. You can use the USB stick to place other files, but be sure to keep both files. Note: If the portable program has multiple files, you can copy its folder to the USB stick, just make sure to enter the path in the ShellExecute field. Ex: ShellExecute = PASTADOAPP \ MEUAPP.exe.
Final Step: Configure and run automatically
Run the program automatically: Once this is done, whenever you connect the pendrive to the computer, APO USB Autorun will detect your autorun.inf file inside the pendrive and will automatically run the program you have configured. Finally, note that you will need to install APO USB Autorun on all computers where you want to use autorun. Still, it can still be useful if you work on the same computers.

Is their a way to synchronise a directory on a raspberry pi to a laptop using WinSCP

I want to be able to synchronize a directory between my Windows laptop and raspberry pi using WinSCP. By "synchronize" I mean if a file is created in the directory by my raspberry pi, it is automatically placed in predefined directory on my laptop.
I have already set up a WinSCP connection between these two devices.
I was following along using this tutorial https://www.youtube.com/watch?v=ndvEYOQLc4c however I reliazed that this was for an FTP server and I also could not save the .bat file or code file into the appropriate directory as it has it has an administrator lock, so I assume that the method is only for FTB servers.
Edit
I have given myself permissions to save the code files in the appropriate places, however I now receive the error
Host "lynn-vs2.cloudapp.net" does not exist.
Whenever I run the bat file:
winscp.com /script=SyncToLocalScript.txt
pause
Which in turn runs the txt file:
option batch abort
option confirm off
open sftp://sftpuser04:password123!#lynn-vs2.cloudapp.net -hostkey="ssh-ed25519 256 00:69:55:c8:a8:84:01:6d:7c:ff:9f:8c:89:b3:7d:67"
synchronize local C:\Users\****\OneDrive\Desktop\RaspPCAP /home/pi/Desktop/PCapFiles
exit
I am not sure what "lynn-vs2.cloudapp.net" is.

Re-directing standard error to console and file [duplicate]

This question already has answers here:
Displaying Windows command prompt output and redirecting it to a file
(32 answers)
Closed 8 years ago.
I am trying to redirect both the standard out and standard error in a Windows batch file to the same file.
However I would like the standard error and user input prompts to be displayed in the console as well.
I tried the following:
Process_SVN_Repos.bat > Process_SVN_Repos.log 2>&1
However this causes the STD ERROR to go to
the file (which I want), but does not show up in console and hence I can not input any user required inputs because I don't see any user prompt.
So basically I am trying to:
Redirect all std out to a file.
Redirect all STD ERROR to the same file.
Also show the same STD ERROR on the console.
See the user prompt the application needs in the console and be able to input the user prompt.
You need a tee command for Windows. Here are few options:
Rob van der woude pure batch solution / ....
Dave Benham's jscript/bat hybrid
Tee by Microsoft - it's part of Unix services for Windows (after installation it's available in the BIN folder and has no exe extension) - For XP/Windows Server 2003 for Windows Vista, Windows 7, Windows 8, Windows Server 2008, and Windows Server 2012.
Command line co uk
UnixUtls
Windows doesn't have a tee command, so you can't. As Windows includes Unix you could use one of those shells. I don't know if it has tee, but it has 350 utilities.
If you are using a Unix environment then you can easily use the tee command. But since you are on Windows, it doesn't support you directly. But there are alternatives that you can use.
I have used Wintee for a similar task like yours. I suggest you use that small utility called wtee.exe. If that can't help your task there are other alternatives as well.

Bash: Getting standard program for file type

the background is a shell script to open the .m3u file of a web radio station. Therefore I want to know inside the script, what's the user's program to open such files. At the moment, he has to set the environment variable $PLAYER, but obviously that is not a good way to go.
Alternative: Is there a command that takes a filename and searches itself for an appropriate program to handle that file? Like file, e.g.,
open-file my_playlist.m3u
The script should be portable, it will run at least on Ubuntu, Debian and Windows/Cygwin machines.
Cheers,
This will have to be done differently on each platform. On Mac OS X the "open" command will do what you want.
In Linux it gets murky, since the desktop environment (GNOME or KDE) keeps its own list of applications to run for each file type.
There are two files you can look for in Ubuntu / GNOME that hold this info:
~/.local/share/applications/defaults.list and
~/.local/share/applications/mimeinfo.cache
Someone else hopefully knows how to do this in Windows and can chime in.
Edit: Stealing from the other answers:
Linux:
xdg-open [filename]
Cygwin:
cygstart [filename]
And for completeness, here's a link to a previous question about how to detect which operating system you are running on: Detect OS from bash Script
I'd like if there were a different answer to this but I think you'll have to check the file association configs for every desktop environment and file manager out there (so, nautilus, konqueror, thunar, mc... all in different places and in different formats AFAIK), as well as ascertaining which one of these the user is actually using...
If someone has a different idea I'm keen to hear it.

Resources