Batch Script: A Few Used With Psexec


I have been using psexec and batch scripts to do some system management jobs remotely. Here are couple examples of frequently used ones.

psexec \\computer_ip_address  -u administrator –p ***** –c xxx.bat (xxx.bat can be any batch scripts you created)

e.g: psexec \\172.29.16.10 –u administrator –p ******** –c disableFW.bat

xxx.bat examples:

1) disableFW.bat: disable the Windows Firewall on remote Windows XP, and set the start type as disabled.

net stop SharedAccess
sc config SharedAccess start= disabled

2) enableRDP.bat: enable the remote desktop connection on remote Windows computers.

reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server” /v fDenyTSConnections /t REG_DWORD /d 0 /f
net start TermService

3) joinDOM.bat: join the computer into the domain remotely.

netdom join %COMPUTERNAME% /Domain:test.domain /UserD:administrator@test.domain /PasswordD:******

4) addREG/ delREG/ queryREG.bat: add/ delete/ query registry keys remotely.

REG ADD/ DELETE “hklm\software\Microsoft\…” /v xxx /f
REG QUERY “hklm\software\Microsoft\…”

5) killPS.bat: kill a process remotely

taskkill /f /im process_name

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s