Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a linux server with winexe package installed. It's the same as PSExec, and everything works okay when running simple commands, but when I run it with this command below I get a parsing error!

winexe -U user%password //host "powershell -Command (New-Object System.Net.WebClient).DownloadFile("http://host/filename.iso","c:\file.iso")"

Can anyone figure what's wrong with this? Is it's cause a conflict in the quotes around the url and file name, with the quotes around the whole command?

share|improve this question
1  
Can you post the full error message? –  cpast Mar 18 '13 at 22:07

3 Answers 3

up vote 3 down vote accepted

Try using the format: powershell.exe -Command "& {<command>}"

This worked for me, using your example:

powershell.exe -Command "& {(New-Object System.Net.WebClient).DownloadFile('http://google.com/robots.txt','c:\robots.txt')}"

Also, I used single-quotes in DownloadFile

Reference: http://technet.microsoft.com/en-us/library/hh847736.aspx

share|improve this answer

Nested use of double quotes won't work. Try something like this:

winexe -U user%password //host "powershell -Command (New-Object System.Net.WebClient).DownloadFile('http://host/filename.iso','c:\file.iso')"
share|improve this answer

The easiest way is to run the command directly using single quote. For example listing the processes can be done as follows:

winexe -U "Domain\PC-Name" //IP Address 'powershell.exe Get-Process'
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.