command line close instantly

avatar

Hello,

we use a short cmd (winrs) command to connect to a remote server and run a command - but the cmd window close instantly after the command. So it is not possibly to see if the command successfull accomplished or a other message respond.

We tested ALL settings in Execution mode but every time it close the window.

Is it a bug or a favored behavior?

Attached the screenshots from the settings.

PS: Another question to the execution:
At the moment we select a host, press CTRL+H (for copy the hostname from the selected session to the clipboard) and select in tab Macros/Script/Tools the custom Script. Now i had to enter for the $HOST$ variable the hostname from the selected (CTRL+V) host. Is it ppssible to implement a variable that autmatically fill in the computername from the selected connection (host)?

Thanks in advance!

CMD-RDM-2.png

CMD-RDM-1.png

CMD-RDM.png

All Comments (19)

avatar

Could you try to add Cmd.exe /K before your command line to keep Cmd shell opened?

I have added your variable suggestion to our todo list. It's a good idea.

David Hervieux

avatar

Hello David,

Thanks for the fast response!



I already tried this - with the result that the cmd window stay open, but the command (wuauclt...) are ignored - so the cmd is indeed open, but i have to type the complete command again



Thank you ;)

avatar

Does it work with the /K?

David Hervieux

avatar

Not really..

The cmd shell stays opened - but the command itself (wuauclt /reportnow && wuauclt /detectnow) are not append..

so it looks like that the command line only accepted to this: winrs -r:{1} -u:{2} -p:{3} cmd /K and not the fully command line like this: winrs -r:{1} -u:{2} -p:{3} wuauclt /reportnow && wuauclt /detectnow

without the cmd /K the code full cmd line are applied (checked with last report time on wsus)

avatar

Any news regarding this issue?

Thanks

avatar

Could you please try:

cmd /K winrs -r:{1} -u:{2} -p:{3} wuauclt /reportnow && wuauclt /detectnow

Does that work?

Best regards,

Stéfane Lavergne

avatar

Unfortunately not.

if i execute cmd /K winrs -r:{1} -u:{2} -p:{3} wuauclt /reportnow && wuauclt /detectnow the cmd in the RDM Folder opens and a error occur that the command can not be found (attached a screenshot from the cmd)

Thanks!

CMD-RDM-4.png

avatar

I don't have winrm & winrs configured here so I can't easily test it.

I tested with this:
C:\Users\slavergne>cmd /k echo first && echo second
first
C:\Users\slavergne>exit
second
C:\Users\slavergne>See how I had to exit prior to the second echo.

I think this should work for you:
C:\Users\slavergne>cmd /k "echo first && echo second"
first
second
C:\Users\slavergne>exit
C:\Users\slavergne>Both, first and second were echoed in the same cmd session.

So please try the following:
cmd /K "winrs -r:{1} -u:{2} -p:{3} wuauclt /reportnow && wuauclt /detectnow"
Best regards,

Stéfane Lavergne

avatar

You can also try to force 64-bit execution (Execution Mode (tab) -> Im 64-bit-Modus ausführen)

Stéfane Lavergne

avatar

Hello Stefane,

Unfortunately not. :(

Tried with cmd /K "winrs -r:{1} -u:{2} -p:{3} wuauclt /reportnow && wuauclt /detectnow" - no change to previous error (Command could not be found..)

than i activate the option force 64-bit execution - now (it is somewhat difficult to describe) a command prompt opens, i see a fraction of a second that are command was applied and afterwards the cmd are empty and only the path from the cmd was shown, but no input respectively output from the command line - so it is the same as at the very beginning - with the difference that now the cmd stays open, but with no output from the command..

Thanks for your help!

avatar

Ok, sorry I'm going it at this blindly. If both these next two don't work I will ask our support team to reproduce the issue on their lab environment.

First could you try:
cmd /K winrs -r:{1} -u:{2} -p:{3} "wuauclt /reportnow && wuauclt /detectnow"andcmd /K winrs -r:{1} -u:{2} -p:{3} wuauclt /reportnow && cmd /K winrs -r:{1} -u:{2} -p:{3} wuauclt /detectnow
Both in 32-bit and 64-bit modes.

Any luck?

Best regards,

Stéfane Lavergne

avatar

No problem - Im grateful for any help :)

Unfortunately no luck..

Would be great if the support team have a look over this..

Thanks for your Support!

Best Regards

avatar

yeaaah, windows updates... You are bringing us in the dark smelly pits of Windows, the documentation on wuauclt is just the worse I've seen.

Before doing anything remote, I like to test how they run locally, and it this case I have no output at all. I have tried

wuauclt /detectnow
wuauclt /resetauthorization /detectnow
Both commands result in nothing being displayed.

Being on Windows 10, I've had to use the Get-WindowsUpdateLog cmdlet to dump the Windows Update Client activity,

1600-12-31 19:00:00.0000000 252 5504 Unknown( 120): GUID=2a5e63c3-d28e-fe39-34ce-8f0e2f830b16 (No Format Information found).
1600-12-31 19:00:00.0000000 252 5504 Unknown( 51): GUID=2a5e63c3-d28e-fe39-34ce-8f0e2f830b16 (No Format Information found).
2016-03-24 14:35:00.4252903 252 3272 ComApi *RESUMED* Download ClientId = UpdateOrchestrator
2016-03-24 14:35:00.4252910 252 3272 ComApi Download call complete (succeeded = 1, succeeded with errors = 0, failed = 0, unaccounted = 0)
2016-03-24 14:35:00.4252930 252 3272 ComApi * END * Download ClientId = UpdateOrchestrator
2016-03-24 14:35:00.4256333 252 4524 ComApi ISusInternal:: DisconnectCall failed, hr=8024000C
Do you get any output when you run it in your environment?

Maurice

avatar

you are right - but unfortunately necessary - but the script could it make much easier :)

you are right - wuauclt brings no output - this is ok - the last report time could be checked in the WSUS Console - this is not the issue..
The issue is linked wirh the winrs command - this brings a output if a computer is unavailable etc.. so a local test with only the wuauclt command is not really meaningful.
For example: If the winrs command succeed the following screen appeard (tested it in a local cmd without RDM) - the cmd should be opened, the winrs command applied and the cmd shoul be stayed open (that would be the desired behavior if you run it from RDM)


If the command doesnt run succesfull the error from the winrs command returns - not from the wuauclt command:

For example the server ist not available or the account does not have the permission etc..
hope you know what i try to describe ;)

Thanks anyway for your support! :)

avatar

Hello,

Your && operator is not joining the two wuauclt commands, but rather the winrs and the last wuauclt, if you replace it with just a plain CD you should see that it displays your local directory rather then the remote user's home folder.

what happened when you tested

winrs -r:XXX -u:XXX -p:XXX "wuauclt /reportnow && wuauclt /detectnow"

Maurice

avatar

here's the session that works as far as I understand your scenario


When successful



where inputting wrong credentials



Just import the session and have a look at it.


Best regards,

Maurice

wuauclt.rdm

winrs_error.png

winrs_success.png

avatar

Hello Maurice,

ive tested your command line and also imported the .rdm session and adapt it with valid credentials - but unfortunately with unsuccessful..
the command line closes automatically..

think its a issue on the basis of RDM and winrs in connection with the wuauclt command..
for my opinion this command script line could make some admin taks easier and faster - but it is by far not essential..
if it not work with the stayed open cmd shell - is it not a doomsday ;)

=================================================================================

Update:

It works with hard coded Username / Password !
Like: winrs -r:$HOST$ -u:YourUsername -p:YourPassword "wuauclt /reportnow && wuauclt /detectnow"

It works not with the additional parameters (like username and password as parameter) !
Like: winrs -r:$HOST$ -u:{1} -p:{2} "wuauclt /reportnow && wuauclt /detectnow"


PS: the command line tite includes the whole command (with password in cleartext) - a small workaround for this i set a title for the cmd and fill in some empty character ore something like that.. The password is only shown if you change the cmd width..)
Like: title Custom Patch Script~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&& winrs -r:$HOST$ -u:YourUsername -p:YourPassword "wuauclt /reportnow && wuauclt /detectnow"

Best Regards,
Min

avatar

Hello Min,

I'm getting back to you about your first post in regard to the variable. Unfortunately I'm not sure we can do much with resolving the $HOST$ in the parameter section. It should work if you set it directly in the "General" section in your command directly, though. Can you try this out?

As for the other issue I'll let Maurice continue the discussion ;)

Regards,

Hubert Mireault

avatar

Hello Hubert,

you are right - if the $HOST$ variable is in the command line and NOT in the Paramter section it will work with the hostname from the server that are the focus on.

Thank you!