SoFunction
Updated on 2025-03-10

[Remote Cmd with wmi]Remote script


On Error Resume Next
Set outstreem=
If (LCase(Right(,11))="") Then
Set objShell=("")
(" /k cscript //nologo "&Chr(34)&&Chr(34))

End If
If <4 Then
usage()
"Not enough Parameters."

End If

ip=(0)
username=(1)
password=(2)
CmdStr=(3)
EchoStr=(4)
foldername="c:\\windows\\temp\\"

"Conneting "&ip&" ...."
Set objlocator=CreateObject("")
Set objswbemservices=(ip,"root/cimv2",username,password)
showerror()
Set Win_Process=("Win32_ProcessStartup")
Set Hide_Windows=Win_Process.SpawnInstance_
Hide_Windows.ShowWindow=12
Set Rcmd=("Win32_Process")
Set colFiles = _
("Select * from CIM_Datafile Where Name = '"&foldername&"'")
If = 0 Then
"Not found ! Create Now!"
Create_read()
End If


If EchoStr = "0" Then
msg=("cmd /c "&CmdStr,Null,Hide_Windows,intProcessID)
Else
msg=("cmd /c cscript %windir%\temp\ """&CmdStr&"""",Null,Hide_Windows,intProcessID)
End If

If msg = 0 Then
"Command success..."
Else
showerror()
End If

"Please Wait 3 Second ...."
(3000)
Set StdOut =
Set oReg=(ip,"root/default",username,password).Get("stdregprov")
&H80000002,"SOFTWARE\Clients","cmd" ,arrValues
String(79,"*")
cmdstr&Chr(13)&Chr(10)
' arrvalues
For Each strValue In arrValues
strValue
Next
&H80000002,"SOFTWARE\Clients","cmd"

Sub Create_read()
RunYN =("cmd /c echo set ws=(^""^"")> %windir%\temp\"_
&"&&echo str=(^""cmd /c ^""^&(0)).:set ws=nothing>> %windir%\temp\"_
&"&&echo Set oReg=GetObject(^""winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv^"")>> %windir%\temp\"_
&"&&echo ^&H80000002,^""SOFTWARE\Clients^"",^""cmd^"",Array(str) >> %windir%\temp\",Null,Hide_Windows,intProcessID)
If RunYN = 0 Then
" Created!!!"
Else
showerror()
End If

End Sub

Function showerroronly(errornumber)
If errornumber Then
"Error 0x"&CStr(Hex())&" ."
If <> "" Then
"Error Description: "&&"."
End If

Else
"."
End If
End Function


Sub usage()
string(79,"*")
"Rcmd v1.01 by NetPatch"
"Usage:"
"cscript "&&" targetIP username password Command"
"cscript "&&" targetIP username password Command 0 //No echo"
string(79,"*")&vbcrlf
end Sub