Access office computer from anywhere without a VPN connection

You can run any one-line command in your office PC from anywhere just by sending the command through mail.


You can get to know the ipconfig with this.


Requirements:
  • Office computer should be running some windows version
  • MS Outlook should be the mail client.
Steps:


  • Open Outlook and press Alt+F11. This will open VB script editor.
    • Alternatively you can open this through menu Tools > Macro > Visual Basic Editor.
  • Copy paste the below code in the window appears.

' Author : Stalin Gino S

Sub RunCommand(Item As Outlook.mailItem)
    'Open mail, adress, attach report
    Dim strMsg
    Const olMailItem = 0
    
    Dim comm As String
    Dim sFileName As String
    Dim iFileNum As Integer
    Dim sBuf As String
    sFileName = "D:\RunCommandOut.txt"
    
    Set objShell = CreateObject("WScript.Shell")
    comm = Split(Item.Subject, ":")(1)
    i = objShell.Run("cmd /c " & comm & " > " & sFileName, 0, True)
    
    Dim objMail As Outlook.mailItem
    Set objMail = Application.CreateItem(olMailItem)
    objMail.To = Item.SenderEmailAddress
    objMail.Subject = "OUTPUT:" & comm & " " & CStr(Month(Now)) & "/" & CStr(Day(Now)) & "/" & CStr(Year(Now))
    strMsg = ">" & comm & vbCrLf & vbCrLf

    iFileNum = FreeFile()
    Open sFileName For Input As iFileNum
    Do While Not EOF(iFileNum)
        Line Input #iFileNum, sBuf
        strMsg = strMsg & sBuf & vbCrLf
    Loop
    Close iFileNum
    
    objMail.Body = strMsg
    'objMail.attachments.add("C:\MyAttachmentFile.txt")
    'objMail.Display
    objMail.Send
    'Clean up
    Set objMail = Nothing
    Set objOutlk = Nothing
End Sub
  • Save the project and close it.
  • Open Rules editor. Menu Tools > Rules Wizard > Client Side Rules...
    • click on "New Rules..."
    • Click on "Check message when they arrive" and click "Next".
    • Choose the mail ID(very important -  xxxx@gmail.com) and subject as "CMD:" and click "Next".
    • Choose to delete the mail, if you prefer, and run a script, choose the script, then click "Finish".
    • Click "OK".
  • You are done.
  • Try sending a mail from the given mail ID (xxxx@gmail.com) to your office mail. Subject should be "CMD:<your command>"
    • eg:-   CMD:ipconfig
    • You will get a reply with subject as "OUTPUT:ipconfig"


Comments

Popular posts from this blog

NatGeo - Download a month's photos

Xolo Play - Android ROM flashing for Dummies

Android "fastboot" driver installation