Wednesday, August 17, 2016

We can use pstools to connect to remote pc command prompt,, download it from

https://download.sysinternals.com/files/PSTools.zip

extract pstools folder --> hold the shift key --> right click in the folder --> select command prompt
Start a CMD session on the remote machine using psexec by typing below commnad

psexec \\remote-pc cmd

After connecting, list the printers available on the machine:
c:\pstools\>wmic printer get name
printer1

  1. If you want to make printer1above shared:
    > rundll32 printui.dll,PrintUIEntry /Xs /n "printer1" Sharename "Printer1"
    > rundll32 printui.dll,PrintUIEntry /q /Xs /n "printer1" Attributes Shared
  2. Confirm the printer is available by going to \\remote-machine in Windows Explorer; you should see the printer available now.
To get printer shared or not or to know the sharename of the printer with command type the following : 

wmic /node:remote-pc printer get shared,sharename,caption,name,portname


To delete printer according to crieteria 

wmic printer where name='printer1' delete
wmic printer where local='false' delete

Examples
WMIC OS 

WMIC OS LIST BRIEF

WMIC OS GET csname, locale, bootdevice

WMIC OS GET osarchitecture /value

WMIC OS GET localdatetime

WMIC LOGICALDISK where drivetype!=4 get deviceid, description

WMIC LOGICALDISK where description='Local Fixed Disk' get deviceid, volumename

WMIC NTEVENT where LogFile='system'

WMIC NTEVENT where "LogFile='system' and Type>'0'" 

WMIC SERVICE where (state=”running”) GET caption, name, state > services.tsv

WMIC SERVICE where caption='TELNET' CALL STARTSERVICE

WMIC PRINTER LIST STATUS

WMIC PRINTER where PortName="LPT1:" GET PortName, Name, ShareName
 
WMIC /INTERACTIVE:ON PRINTER where PortName="LPT1:" DELETE

WMIC PROCESS where name='evil.exe' delete

WMIC /output:"%computername%.txt" MEMORYCHIP where "memorytype=17" get Capacity

WMIC /node:remote_computer PROCESS call create "netstat.exe -ano > C:\output.txt"

WMIC /node:@workstns.txt /failfast:on PROCESS call create "\\server\share\installer.cmd"

Interactive mode:
C:> WMIC
wmic:root\cli> OS get csname
wmic:root\cli> quit


No comments:

Post a Comment