Reading user input from powershell through scriptcs - console.readline

Here I have a problem to read user inputs from Command prompt or windows powershell through scriptcs.I tried with Console.ReadLine(),Console.Read() or Console.ReadKey() wrapped it around Convert.ToString() to get user response but none of them gives result.Do I need any special package to handle the user input. Any help is appreciated.

I got the solution I was previously executing through Windows power shell and so I don't get the response as desired while using Console.ReadLine() or Console.Read().It appears as if it got hanged and processing instruction indefinitely. But when I work the scriptcs code in command prompt it reads the input and works as expected.

Related

User input into a script in Powershell GUI

hoping for some help. I've got a dialog box that I want to do a certain action and running into issues getting the user input as a variable in the script. Essentially I want the user to be able to copy down a row in excel (so, for example, copy 4 numbers down a line in row E). I want the user to be able to paste it into the powershell GUI I made, once pasted I want the button to use that user input and put it in to a script I have already made and execute using each of those numbers as a variable and to return the output of the script. I've got the script and button made i'm just not sure what cmdlet or functions I need to do in order to take the user input and place in the script as a variable. Any help is appreciated, thank you!!
I went through Microsoft Docs and tried to find a cmdlet but either I didn't understand it or it didn't seem to work.

Pentaho script invocation not working properly

I'm running a PowerShell script from pentaho, but I encounter the following problem. When it is called, the script step gets as parameter the rows that are processed by the previous step. From the images should be more clear what is the problem.
This is the complete transformation.
This is how the steps are configured.
Here are the parameters of the transformation before the script step.
This is the result after the execution. The string after the ....shell.bat contains the names of the rows that were processed by the previous step. If I do no process any row this string is not present. The problem is that this string should not be passed as parameter to the powershell.exe command, the first parameter should be the path to the script file. In fact in the row below (the output) the command is correct.
The problem is that I looked all the options and controlled all the variables, and seem everything ok. I'm not able to run the command successfully because I cannot remove this passed parameter (which I don't pass, but pentaho pass it by itself).
It is possible that is a bug or something? Can anyone give me some indications on how to solve this. Thank you.

Getting text from the Console

I am trying to access the stdout from the console in a Swift script. For example, if my console looked like this:
I would be able to access the '0'. Is there a way to do that in Swift or not?
The script won't be what is printing the text to console so I can't just access a variable. This should help explain it:
The Running Program gets the output from the Other Program and outputs it to the console. I want to get that output from in the Script.

How to add parameters to a running process or exe by default?

Objective:
I'm trying to use a program called Texmod.exe to start another program (exe) with certain parameters.
Background:
Texmod is program that opens up another exe and extracts/replaces textures that are pulled up in the second program while it is running. I'm trying to start the second exe with the parameters: -AlwaysFocus -ControllerOffset=1 -SaveDataId=2. Starting the second exe with shortcuts/.bat that have these parameters in a command line DOES work. However, I would like to do this in conjunction with Texmod.
Complications:
I'm using Texmod v0.9 b which doesn't support starting an exe with command line parameters. Newer versions, such as the open source reboot known as uMod, does support but it doesn't replace textures as well and crashes often compared to the original version.
Texmod.exe must start the second exe directly. Texmod can't select a shortcut to start the exe. I've tried making Texmod start another exe/.bat that then starts the second desired exe with parameters but this causes Texmod not to function.
Methods I have thought about but not sure if they work or even possible:
Somehow forcing all processes started by Texmod.exe to start with certain parameters
Somehow force the desired exe to always start with certain parameters regardless of start method (via Texmod, shortcuts, .bat, etc)
Add parameters to the process started by the desired exe after it is already running
Obviously I'm open to any ideas. Is what I'm asking even possible? Sorry if it seems unclear or I sound irrational; my knowledge on this is limited.
Edit: #Toby Speight I'm not sure what you mean by an example of the code I'm having trouble with as I'm just wondering if it's possible to perform the scenario I described. This is where I got the Texmod program from (it's the oldest release texmod.zip - Original TexMod 0.9 beta). I've searched the internet for possible solutions but I've found very few so some of the methods I've tried are:
Used Texmod.exe to start a desktop shortcut with target: "directory to exe" -AlwaysFocus -ControllerOffset=1 -SaveDataId=2. The result was Texmod couldn't use the shortcut and just opened the exe without the parameters.
Used Texmod to start an exe named caller.exe which started the exe I desired using the method described here. In command.txt, described by the instructions, I put ""name of exe.exe" -AlwaysFocus -ControllerOffset=1 -SaveDataId=2." The result was the exe started with the parameters but Texmod failed to modify the textures because it was modifying textures pulled up by caller.exe instead.
Used Texmod to open a .bat file with the lines: ""name of exe.exe" -AlwaysFocus -ControllerOffset=1 -SaveDataId=2." The result was the same as attempt described in #2.
Edit2: I also stumbled on this page where someone else claims they managed to achieve what sounds like the objective I desire. However, I do not know enough about code to understand it. If someone could look over this to see if it would work or see if they can modify it to fit the arguments that I desire.
You can use windows registry to force Windows run another app when specific .exe is called. Let me show an example: i'm trying to use TexMod with Remember Me.
Required setup:
Create a copy of game .exe, place it near original with different name, eg RememberMe_copy.exe
Go to windows registry location HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options
create new key named as original .exe, in my case it's RememberMe.exe. Registry key looks like a folder.
In this key, create new string value named Debugger with full path to copy of .exe with required commandline args. For example: "C:\Program Files (x86)\Steam\steamapps\common\Remember Me\Binaries\Win32\RememberMe_copy.exe" -ReadPoolSizeFromIni. Note the path to .exe is quoted, commandline arguments are not. String value has type REG_SZ.
Now when you try to run anything called RememberMe.exe, Windows will instead run the RememberMe_copy.exe with specified parameters (and something else but we don't care). This feature is left in Windows for debugging purposes.
Finally, open TexMod, select RememberMe.exe. It will think it's running original file, but instead Windows will silently run another file with another parameters. As there is nothing else in between, TexMod is happy.
Why can't we use single file? Well, Windows will run original .exe instead of original .exe, then instead of it will run original .exe... causing infinite loop.

output from corFlags.exe and dumpbin.exe disappear when redirected

We are trying to automate some procedures using corFlags.exe and dumpbin.exe. Trying to capture the output from either of these programs has been impossible so far. In detail, executing
corFlags.exe yourfavorite.dll
in cmd.exe or in powershell.exe (with appropriate change of syntax) produces output just fine, but as soon as one attempts to capture the output, either through re-direction or piping, e.g.
corflags.exe yourFavorite.dll >>out.txt
or
$l_result = &corflags yourFavorite.dll | select-string -pattern "32BIT"
and the output of corflags is lost. There is a similar problem with dumpbin.
This is occuring on a Windows 7 sp1 machine (6.1.7601 sp1 build 7601).
I am guessing they suffer from the flaw of not flushing their output streams before exiting. See Output shows up in console, but disappears when redirected to file for example.
We have found no way of working around this problem so far (executing in sub-process/batch process/etc. etc.) Does anyone know of a work-around to this problem? Thanks.
A nice, simple demonstration of the problem is as follows. Open the PowerShell ISE and try to run "corFlags.exe some.dll" within the console window. You will not be able to get any output from it!