Batch Scripts

Active X Batch Script

Posted by robd on August 16, 2012
Batch Scripts / No Comments

Some stupid software needs Active X controls to work, here’s a basic script for that to work:

The following batch file can be configured as a computer startup script to install the components:

Tags: , ,

Install an EXE remotely with PSTOOLS

Posted by robd on May 15, 2012
Batch Scripts, pstools / No Comments

Recently I needed to install some software on a bunch of machines but being the lazy git that I am I decided I couldn’t be bothered to walk upstairs, run the installer as me and install the software…so instead I created three convoluted batch scripts to do it:

Few things to note: I’m using PS Tools to run the scripts with my domain admin account, this is the same as shift right clicking the software as running as me!

I’m also using PS Tools to specify a list of PC’s!

Script one:

Copies an installation exe file from a server to a PC:

Script two:

Looks at a list of PC’s and runs the above script for each PC in the list:

 

Script three:

Looks at a list of PC’s then remotely installs the file LOnline.exe that you just copied to the pc remotely, I’m running the exe interactively when it’s done it pops a message to tell the user its done!!:

I’m sure there is a much easier way of doing the above in one script but this was a very quick solution I put together!!

Exchange 2010 Distribution Groups

Posted by robd on January 12, 2012
Batch Scripts / 1 Comment
Recently I needed to re-create some distribution groups in a new Exchange 2010 environment from an Exchange 2003 environment
 
Here’s how I did it:
 
Firstly extracted the groups from Active Directory by modifying a script taken the good people over at Migration Wiz (Their Script http://migrationwiz.zendesk.com/entries/20046721-export-active-directory-distribution-lists-to-csv)

 

My Script (basically less information in the csv file) :



You should now have a csv file containing all your information!!

 

Next create a PowerShell command to import the csv file, here’s one I made earlier:


 

Basically the headers from the csv file need to match the sections in the powershell command that start with $_.

 

Once that runs in powershell without issue then you should be good to import users into the groups….which I also have a script for!!

Batch Script to Exe‏

Posted by robd on January 12, 2012
Batch Scripts / No Comments
Recently a user came to me wanting to become an admin on their machine, after the initial “No chance” they explained they “needed” to update some software for a project they were working on…..which got me thinking!!

 

How could I allow a user to run some software with giving them admin …..so after a while I came up with this:

 

Make a batch file that uses PS Tools then wrap the batch file up into an exe so the user can’t get to the admin password!!

 

Here’s how:

 

Download and extract PS Tools from Microsoft http://technet.microsoft.com/en-us/sysinternals/bb896649

 

I normally delete all the tools I don’t use i.e. keep PSEXEC.exe (also it may be an idea to run psexec.exe prior to the script to get rid of the annoying disclaimer screen!

 

Create an administrator for the machine and remember the username and password.

 

In the folder with PS Tools create a batch file to run your desired software as an administrator, could look similar to this:

 

http://technet.microsoft.com/en-us/sysinternals/bb896649

 

@Excho off psexec.exe -u DOMAIN\ADMIN_USER -p ADMIN_PASSWORD -i -d “C:\Program Files\Internet Explorer\iexplore.exe” Exit

 

Save the script and give it a test.  I tested the script with IE as normal users don’t have access to the tools menu whereas Admins do.

 

Now to wrap the batch file:

 

Download this brilliant batch to exe application:
http://www.f2ko.de/programs.php?lang=en&pid=b2e

 

Run it in either 32 bit or 64 bit, here are the options I used
Notice I chose Invisible application, this simply means the user won’t see the script run!
The working directory refers to where ever the exe is placed, for the end user place it somewhere where they have permissions to create and delete files such as “My Documents” etc otherwise once the program has run it wont be able to delete its temporary files (also specified below)!

 

Notice I added PsExec.exe – You must do this or batch script won’t run!

 

I used a logo just to make it look nicer for the end user:

 

Default Options:

Done, give it a test and let me know how you got on!!!!

Copy Protected by Chetan's WP-Copyprotect.