none
Opening batch file from virtual machine succeeds, opening it remote fails : Failed to create an IPC Port: Access is denied RRS feed

  • Question

  • I want to execute a bat file remotely located on the virtual machine. The batch file exist out of 2 lines  :

    cd c:\Program Files (x86)\PathToExe\Taskbar Utility 
    start /wait Utility.exe -upgrade "C:\Scripts\DM.upgrade"

    When I open the bat file double clicking it on the virtual machine, the batch succesfully runs. When I try to execute the batch using Invoke-Command or either PSSession the commands executes yet batch file doesn't start and no errors are given. Any suggestion on how to make it start remotely? Also using Invoke

    I've tried :
    Invoke-Command -ComputerName myIp -ScriptBlock{cmd.exe /c PathToBatOnVm} -Credentials $cred

    Invoke-Command -ComputerName myIp -ScriptBlock{PathToBat} -Credentials $cred

    Using PSSession also didn't work and also didn't give any error.

    Also tried with scriptblock, because path could get complicated

    PS C:\WINDOWS\system32> $ScriptBlockContent = {          param ($MessageToWrite)       $PathExe= $MessageToWrite ; Start-Process -FilePath $PathExe -ArgumentList '-upgrade "C:\Scripts\upgradeFile.upgrade"'; Write-Host Started;}


    Gives :
    PS C:\WINDOWS\system32> Invoke-Command -ComputerName 10.2.1.34 -ScriptBlock $ScriptBlockContent -ArgumentList $PathExe -Credential $cred
    Started



    • Edited by JeremySky Monday, May 2, 2016 2:35 PM More specific
    Wednesday, April 27, 2016 8:11 AM

Answers

  • Hi Jeremy,

    from all that I can see, this should be a problem with utility.exe, not powershell in general (IPC is used for interprocess communication and cannot be used inbetween two computers). Can you remotely run a regular batch file that just writes something to file?

    Considering that, I can only see you having two options:

    • Contact whoever wrote utility.exe
    • Try setting up a task that runs your script and run that, instead of using PowerShell remoting

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by JeremySky Monday, May 2, 2016 12:06 PM
    Monday, May 2, 2016 11:55 AM
  • Yes, creating the batch as a Task and then starting the Task made it work for me !

    Thanks Fred!

    1) Invoke-Command -Computer "IP" -ScriptBlock{Register-ScheduledTask -Xml (Get-Content 'C:\\Scripts\\ExecuteUpgradeTask.xml' | Out-String) -TaskName "ExecuteUpgradeTask"} -Credential $cred");

    2) Invoke-Command -Computer "IP" -Scriptblock{Start-ScheduledTask -TaskPath "\" -TaskName "ExecuteUpgradeTask"}  -Credential $cred"




    • Marked as answer by JeremySky Monday, May 2, 2016 2:36 PM
    • Edited by JeremySky Monday, May 2, 2016 3:33 PM
    Monday, May 2, 2016 1:24 PM

All replies

  • Hi Jeremy,

    does whatever utility.exe does require network actions using windows authentication (like accessing files on a share)? If it does, you need to use CredSSP authentication due to the second hop.

    This is the usual issue when you can log on manually and it works and remoting fails to execute, even though the connection works.

    Basically, the remote system doesn't have your credentials and thus cannot authenticate further network access. With CredSSP authentication, PowerShell sends your credentials to the remote system, allowing it to authenticate to remote systems.

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Wednesday, April 27, 2016 8:49 AM
  • I want to execute a bat file remotely located on the virtual machine. The batch file exist out of 2 lines  :

    cd c:\Program Files (x86)\PathToExe\Taskbar Utility 
    start /wait Utility.exe -upgrade "C:\Scripts\DM.upgrade"

    When I open the bat file double clicking it on the virtual machine, the batch succesfully runs. When I try to execute the batch using Invoke-Command or either PSSession the commands executes the batch files starts but ends almost after a second.

    It seems like something goes wrong in bat file, is there a way to open and keep the window so the problem can be identified? Or is there a way to keep or store the data generated in this window ?

    Wednesday, April 27, 2016 8:54 AM
  • Indeed it should be, but for the moment I'm using local paths to avoid the CredSS. However I didn't write the upgrade so I will try it out. Tried using : Enable-WSManCredSSP . But i'm guessing its an error executing the batch. Any idea of getting the information given by the process? Because it seems  impossible to open GUI with winRM?

    • Edited by JeremySky Wednesday, April 27, 2016 9:20 AM
    Wednesday, April 27, 2016 9:11 AM
  • Problem was fixed by echoing the problem error after upgrade command.  So status could be analyzed!
    • Edited by JeremySky Wednesday, April 27, 2016 9:57 AM
    Wednesday, April 27, 2016 9:57 AM
  • Seems like I hit enter to fast, indeed same post!
    Wednesday, April 27, 2016 9:58 AM
  • Hi Jeremy,

    Just to be sure about the CredSSP: You did specify the authentication-type to be used when calling Invoke-Command afterwards, right?

    Do I get this right, you resolved your actual issue? In that case a short feedback on what the actual issue was and marking it as answer would be great:

    • Helpful souls will know your problem is solved without reading this entire thread
    • People in similar situations might search for their trouble and find your solution to be useful

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Wednesday, April 27, 2016 10:13 AM
  • Hello Fred,

    The problem has not been fixed. However I found out what the root cause of the problem seems to be.

    Seems this error gets generated when I try to run the script remotely and ignored :Failed to create an IPC Port: Access is denied.

    Any idea to solve this problem?

    Monday, May 2, 2016 11:37 AM
  • Hi Jeremy,

    from all that I can see, this should be a problem with utility.exe, not powershell in general (IPC is used for interprocess communication and cannot be used inbetween two computers). Can you remotely run a regular batch file that just writes something to file?

    Considering that, I can only see you having two options:

    • Contact whoever wrote utility.exe
    • Try setting up a task that runs your script and run that, instead of using PowerShell remoting

    Cheers,
    Fred


    There's no place like 127.0.0.1

    • Marked as answer by JeremySky Monday, May 2, 2016 12:06 PM
    Monday, May 2, 2016 11:55 AM
  • Hello Fred,

    Writing something to a file works like a charm. 

    Running another batch with simple commands also works great.

    Thanks for the tips! I will try setting up a task. Never thought the problem was located in the utility.exe as it runs with no errors when I tried to open the batch on the machine itself(without PSRemote).

    Regards

    Monday, May 2, 2016 12:05 PM
  • Yes, creating the batch as a Task and then starting the Task made it work for me !

    Thanks Fred!

    1) Invoke-Command -Computer "IP" -ScriptBlock{Register-ScheduledTask -Xml (Get-Content 'C:\\Scripts\\ExecuteUpgradeTask.xml' | Out-String) -TaskName "ExecuteUpgradeTask"} -Credential $cred");

    2) Invoke-Command -Computer "IP" -Scriptblock{Start-ScheduledTask -TaskPath "\" -TaskName "ExecuteUpgradeTask"}  -Credential $cred"




    • Marked as answer by JeremySky Monday, May 2, 2016 2:36 PM
    • Edited by JeremySky Monday, May 2, 2016 3:33 PM
    Monday, May 2, 2016 1:24 PM
  • Yes, creating the batch as a Task and then starting the Task made it work for me !

    Thanks Fred!

    Glad to have been of assistance :)

    There's no place like 127.0.0.1

    • Marked as answer by JeremySky Monday, May 2, 2016 2:35 PM
    • Unmarked as answer by JeremySky Monday, May 2, 2016 2:35 PM
    Monday, May 2, 2016 1:38 PM