1
votes

I have an issue with sending an input to cmd that looks like this:

SendInput wmic /node:%Target% product where name="%product%" call uninstall

The issue is that after the input has been sent, it looks like this:

C:\Users\username\folder>wmic /node:localhost product where name="Name"

   call uninstall

There is an entire new line, If the %product% is just a string, the new line does not appear, it seems to be an issue with adding a variable, however I am new to Autohotkey and I can't tell what could be causing this.

Thanks in advance

Update:

I manged to get it fixed by using AutoTrim, it took me a while to find a working example for some reason. This is what I ended up doing.

Appname = %Appname%
SendInput wmic /node:%Target% product where name="%Appname%" call uninstall

The Appname is actually an option from the wmic product output, it was as @Jim U suggested an issue with a trailing newline. Thanks for the help guys.

1
where did "/node:%Target%" go?phil294
Edited, the main thing was the new line issue, but I see your point :)Svetlin Yankulov
It seems like you haven't provided actual output. The username, folder, Name, and the indenting suggest you made up output. Now we have to guess at what the actual output is. In particular, a newline and indention after the closing quotation mark and "call" seems impossible. Also, you say the script doesn't work when %product% isn't a string, but don't tell us what product actually is when the script breaks. My best guess is that you have a trailing newline in the value stored in "product" and that product is actually a string.Jim U
@SvetlinYankulov Please provide the Update as an answer to your own question, so this will be marked as resolved and answered, otherwise it keeps appearing in the queues. :)David Metcalfe
@DavidMetcalfe Thanks for the clarification. I do apologize, I was not aware.Svetlin Yankulov

1 Answers

0
votes

The Appname is actually an option from the wmic product output, it was as @Jim U suggested an issue with a trailing newline. Thanks for the help guys.