Product, version and build: 5.2.128
32 or 64 bit version of product: 64
Operating system: windows 7
32 or 64 bit OS: 64
PowerShell Version: 5.0
from PowerShell ISE the following code works:
$pc = "cclab2"
$cmd1 = "cmd"
$Message = Read-Host -Prompt "Enter your message here"
$arg1 = "/c msg /SERVER:$pc * /TIME:200 $Message"
Start-Process $cmd1 $arg1
But when this is place behind a Button it never runs the message on the remote computer. How come? Thanks.
cannot run msg on remote machine
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: cannot run msg on remote machine
Probably because the ISE runs elevated and has access. Try running that script with the form elevated.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: cannot run msg on remote machine
I have "Embed a default manifest for elevation" already selected under the Build options.
Thanks.
Thanks.
Re: cannot run msg on remote machine
I have even tried running this as myself and I have admin rights to all workstations in our environment. It still does not work.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: cannot run msg on remote machine
Admin rights is not the same as elevated because of the split security token. Your original post did not specify that this was running as a packaged executable, so the assumption was that this was run from within PowerShell Studio.
So first thing would be to actually specify what you are running and from where.
Second step is to verify that you have the right bit level. msg.exe exists in %WINDIR%\System32 which is a mapped folder and depends on whether you are running a 32 bit or a 64 bit process.
Since there is no 32 bit MSG.exe on a 64 bit machine, that could be the reason.
Msg.exe is not run on the remote machine, it is used to send a message to a remote machine.
Last but not least, almost nothing on Windows just "does not work". If you run that from a command line you likely get an error message. If cmd.exe cannot find msg.exe you would get an error. If msg.exe cannot sent the message, you would get an error message. So capture the error message and see what that says.
So first thing would be to actually specify what you are running and from where.
Second step is to verify that you have the right bit level. msg.exe exists in %WINDIR%\System32 which is a mapped folder and depends on whether you are running a 32 bit or a 64 bit process.
Since there is no 32 bit MSG.exe on a 64 bit machine, that could be the reason.
Msg.exe is not run on the remote machine, it is used to send a message to a remote machine.
Last but not least, almost nothing on Windows just "does not work". If you run that from a command line you likely get an error message. If cmd.exe cannot find msg.exe you would get an error. If msg.exe cannot sent the message, you would get an error message. So capture the error message and see what that says.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: cannot run msg on remote machine
I tried the following. First, I open up a CMD window and I type in MSG /? I see all command line switches. I then run msg MyUserID TESTING I get a popup that says TESTING. I then created a .CMD file that has the following lines of code
Echo On
msg MyUserID TESTING
Pause
I then call this .CMD file from within my compiled form via a Button. Since I have the Pause statement my CMD window stays open and It has this error:
'msg' is not recognized as an internal or external command,
operable program or batch file.
My question is why? msg is of course on my Windows 7 machine and as I've stated I can run it manually from a CMD window.
Echo On
msg MyUserID TESTING
Pause
I then call this .CMD file from within my compiled form via a Button. Since I have the Pause statement my CMD window stays open and It has this error:
'msg' is not recognized as an internal or external command,
operable program or batch file.
My question is why? msg is of course on my Windows 7 machine and as I've stated I can run it manually from a CMD window.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: cannot run msg on remote machine
Did you package as a 32 bit application?
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: cannot run msg on remote machine
ok, how you package makes a difference. Thank you. a couple more questions: I have this code
$buttonSendMsgToList_Click={
$Message = Read-Host -Prompt "Enter your message here"
$MsgSent = "Message sent to "
foreach ($comp in $msglist.text)
{
msg /SERVER:$comp * /TIME:200 $Message
$richtextbox_Output.SelectionColor = 'Blue'
$richtextbox_Output.Text = $MsgSent + $comp
}
}
I have a list box. If I enter 1 machine name into this list box the msg command works. But if I enter more than 1 machine in the list box no msg get sent to any machines. why?
also, no matter where I place my command $richtextbox_Output.SelectionColor = 'Blue' the text in my richtextbox is never blue. Why?
Thank you again for your help.
$buttonSendMsgToList_Click={
$Message = Read-Host -Prompt "Enter your message here"
$MsgSent = "Message sent to "
foreach ($comp in $msglist.text)
{
msg /SERVER:$comp * /TIME:200 $Message
$richtextbox_Output.SelectionColor = 'Blue'
$richtextbox_Output.Text = $MsgSent + $comp
}
}
I have a list box. If I enter 1 machine name into this list box the msg command works. But if I enter more than 1 machine in the list box no msg get sent to any machines. why?
also, no matter where I place my command $richtextbox_Output.SelectionColor = 'Blue' the text in my richtextbox is never blue. Why?
Thank you again for your help.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: cannot run msg on remote machine
Of course packaging makes a difference, as I initially pointed out, there is no 32 Bit msg.exe in a 64 bit machine and System32 is a mapped folder.
To answer your questions:
Because $msglist.text is not a collection, so foreach will not work the way you think.
Because you set the color for the selection to be blue, not the text color.
These are not really PowerShell Studio support questions though, so please post these in either the general PowerShell or PowerShell GUI section.
Good luck!
To answer your questions:
Because $msglist.text is not a collection, so foreach will not work the way you think.
Because you set the color for the selection to be blue, not the text color.
These are not really PowerShell Studio support questions though, so please post these in either the general PowerShell or PowerShell GUI section.
Good luck!
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.