I did this during a little experiment when I was trying to do a remote copy on a WMI-enable Win 95 box.
I copied this script to my target PC...
code:
break on
;setconsole("Hide")
If $SRC <> "" and $DST <> ""
$MSG=GUICopy("Copy", "$SRC", "$DST", 1552)
$nul = SENDMESSAGE($REQUESTOR,$MSG)
Else
$nul = SENDMESSAGE($REQUESTOR, "Please specify a source and destination")
EndIf
function GUICopy($CMD, $Source, $Destination, OPTIONAL $Flags)
If not $Flags $Flags=0 Endif
If not exist($Source) $GUICopy = "Source does not exist." Exit (2) Endif
If not exist($Destination) $GUICopy = "Destination does not exist." Exit (3) Endif
If @INWIN=1 $VER=GETFILEVERSION(%WINDIR%+"\System32\Shell32.dll","FileVersion")
Else $VER=GETFILEVERSION("%WINDIR%\System\Shell32.dll","FileVersion") Endif
If $VER<"4.71" $GUICopy = "Cannot create namespace. Incorrect Shell32.dll version." Exit (4) Endif
$objShell=CreateObject("Shell.Application")
$objFolder=$objShell.NameSpace($Destination)
Select
Case $CMD="Copy" $objFolder.CopyHere($Source, $Flags)
Case $CMD="Move" $objFolder.MoveHere($Source, $Flags)
Case 1 $GUICopy = "GUICopy Syntax Incorrect. Use COPY or MOVE." $objShell=0 Exit (5)
EndSelect
$objShell=0
If @error = 0 $GUICopy = "$CMD Successful" else $GUICopy = "$CMD Failed" Endif
Exit @error
endfunction
And this ran it remotely using this script (please forgive the sloppiness of this code, as I have not finished it)...
code:
Break On
$RemoteBox = "TestPC"
$ServerShr = "\\Server\share"
$ID = "Domain\UserID" ; Use any account with local admin rights
$PW = "XXXXXXX" ; Obvious security concerns
$SRC = "\\Server\Share\Adobe.exe"
$DST = "c:\windows\temp"
$CCommand = 'kix32.exe c:\remote_copy.kix $$src="$src" $$dst="$dst" $$requestor="@wksta"'
$RCommand = "c:\windows\temp\adobe.exe"
$Connect = CreateObject("WbemScripting.SWbemLocator")
If @ERROR @serror ? EndIf
$Con2 = $Connect.ConnectServer("$remotebox","root\cimv2","$ID","$PW")
If @ERROR @serror ? EndIf
$Con2.Security_.ImpersonationLevel = 3
If @ERROR @serror ? EndIf
$Con3 = $Con2.Get("Win32_Process")
If @ERROR @serror ? EndIf
$Map = $Con3.Create($CCommand)
If @ERROR @serror ? EndIf
;sleep 10
$Con4 = $Con2.Get("Win32_Process")
If @ERROR @serror ? EndIf
;sleep 5
$Process = $Con4.Create($RCommand)
If @ERROR @serror ? EndIf
If NOT $Process
? "Process executed successfully!"
Else
? "Process failed..."
EndIf
$Connect=""
$Process=""
$Con2=""
$Con3=""