I agree with Doc, prefer Jochen way/code.

However I got some other problem .

Using WriteLine I added "Del Test.bat" to the end of successfully generated batch file. Normaly the batch file should remove it self when executed! But guess what! Nothing happens!.

I tested and moved the batch file from "All Users\Desktop" to a local user id "User\Desktop"
And it worked!!!

This cannot be permission or file attribute issue, User has local admin rights on remote client as well as source client, and the only attrib option on file is set to "A"

Actually I should skip the ALLUSERSPROFILE\desktop and find a way to point to USERPROFILE\desktop instead.

But i cannot find any reg key which i could use to define the path to "current user" USERPROFILE\desktop.

The "Shell Folders" contains only "Common Desktop", and that means "ALLUSERSPROFILE\desktop"

Any ideas?

Break on
$rc=SetOption('NoVarsInStrings','on')
$pc="10.198.10.4"
$AllUsersDesktop = '\\' + $pc + '\' + Join(Split(ReadValue('\\'+$pc+'\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders','Common Desktop'),':'),'$')

$ = Open(1,$AllUsersDesktop + "\Test.bat",5)
$ = WriteLine(1,"@Echo Testing" + @CRLF)
$ = WriteLine(1,"Del Test.bat" + @CRLF)
_________________________
"... Great minds talk about idea' s, average minds talk about events and samll minds talks about people...!"