Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 137ab82

Browse files
committed
Use this to connect to work pc
This loads my checkpoint client, then puttycm and rdp on to desktop pc, all you need to do it set your username and tack your password on
1 parent d6413eb commit 137ab82

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

work_connect.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Script Name : work_connect.py
2+
# Author : Craig Richards
3+
# Created : 11th May 2012
4+
# Last Modified : 31st October 2012
5+
# Version : 1.1
6+
7+
# Modifications : 1.1 - CR - Added some extra code, to check an argument is passed to the script first of all, then check it's a valid input
8+
9+
# Description : This simple script loads everything I need to connect to work etc
10+
11+
import subprocess # Load the Library Module
12+
import sys # Load the Library Module
13+
import os # Load the Library Module
14+
import time # Load the Library Module
15+
16+
dropbox = os.getenv("dropbox") # Set the variable dropbox, by getting the values of the environment setting for dropbox
17+
rdpfile = ("remote\\workpc.rdp") # Set the variable logfile, using the arguments passed to create the logfile
18+
conffilename=os.path.join(dropbox, rdpfile) # Set the variable conffilename by joining confdir and conffile together
19+
remote = (r"c:\windows\system32\mstsc.exe ") # Set the variable remote with the path to mstsc
20+
21+
text = '''You need to pass an argument
22+
-c Followed by login password to connect
23+
-d to disconnect''' # Text to display if there is no argument passed or it's an invalid option - 1.2
24+
25+
if len(sys.argv) < 2: # Check there is at least one option passed to the script - 1.2
26+
print text # If not print the text above - 1.2
27+
sys.exit() # Exit the program - 1.2
28+
29+
if '-h' in sys.argv or '--h' in sys.argv or '-help' in sys.argv or '--help' in sys.argv: # Help Menu if called
30+
print text # Print the text, stored in the text variable - 1.2
31+
sys.exit(0) # Exit the program
32+
else:
33+
if sys.argv[1].lower().startswith('-c'): # If the first argument is -c then
34+
passwd = sys.argv[2] # Set the variable passwd as the second argument passed, in this case my login password
35+
subprocess.Popen((r"c:\Program Files\Checkpoint\Endpoint Connect\trac.exe connect -u username -p "+passwd))
36+
subprocess.Popen((r"c:\geektools\puttycm.exe"))
37+
time.sleep(15) # Sleep for 15 seconds, so the checkpoint software can connect before opening mstsc
38+
subprocess.Popen([remote, conffilename])
39+
elif sys.argv[1].lower().startswith('-d'): # If the first argument is -d then disconnect my checkpoint session.
40+
subprocess.Popen((r"c:\Program Files\Checkpoint\Endpoint Connect\trac.exe disconnect "))
41+
else:
42+
print 'Unknown option - ' + text # If any other option is passed, then print Unknown option and the text from above - 1.2

0 commit comments

Comments
 (0)