Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

09 February 2016

How to run an application as a different user

I often have the need to run applications with different credentials. For instance I may need to connect to a website that users Windows integrated authentication, but I need to use my admin account, not my normal logon to access this. Instead of logging off or switching users I simply created a batch script which launches IE with a different set of credentials.

runas /user:[domain]\[user account] "C:\Program Files (x86)\Internet Explorer\iexplore.exe \"[URL]\""

You can use the runas command to run any application you like, just substitute the values above.
Also note that doing as above will prompt you for your password when you run it, so it is best for interactive use. You can store your password in the batch script, but I would not recommend this.

15 October 2015

Restarting Windows XP Mode Virtual Machine via script

Let me give you some background into the problem that I had. I have several users who use an application that does not work on Windows 7, so I had to load Windows XP mode on their machines to allow them to access the software. The software in question uses a trusted connection to connect to a database server so the users have to logon to the Windows XP mode VM with their Active Directory credentials. This works pretty well up until the point that the user has to change their AD password. The Windows XP Mode VM never actually shuts down after the application is used, it goes into hibernate / suspended mode and therefore the users old credentials are still cached on the VM and the connection to the DB server fails.

The way to resolve this is to reboot the VM, but this is a huge pain in the butt when you have to get VNC access to a machine and run through the whole process of launching the VM and restarting it, so I made some scripts to make my life a bit easier.

Please note that you require administrator privileges on the remote system in order to execute these scripts. You could modify them to include username and password if required. The Virtual machine also needs to be running, so ask the user to open the app that is giving them issues and execute the deploy script. The user can then goto C:\scripts and run the resart-vm.bat file to restart the VM on their machine. This saves me a ton of time and I hope you find it useful.


Scripts list:
restart-vm.ps1Powershell script that restarts the Virtual machine.
restart-vm.batBatch script to execute the powershell script.
deploy-restart-vm.batScript copies the files to the remote system C:\Scripts directory. Allows input of host name.

restart-vm.ps1
$vpc = New-Object -ComObject "virtualpc.application" 
$vm = $vpc.FindVirtualMachine("Windows XP Mode") 
$vm.GuestOS.ShutDown("true")

restart-vm.bat:
powershell -ExecutionPolicy ByPass -File C:\Scripts\restart-vm.ps1

deploy-restart-vm.bat:
@echo off
cls
echo.
echo Deploy shutdown-vm script to remote host.
echo -----------------------------------------
echo.
set /p host="Please enter host name: "
cls

echo.
echo Deploy shutdown-vm script to remote host.
echo -----------------------------------------
echo remote host: %host%
echo.
echo.
echo Making directory on remote machine
echo.
md \\%host%\c$\scripts
echo.
echo Copying files to remote host
echo.
xcopy /Y C:\Scripts\Deploy\restart-vm\restart-vm.* \\%host%\c$\scripts
echo.
pause


16 July 2009

AutoRuns

Ever wondered why your computer is taking forever to start up? Well then AutoRuns is for you! This is the most comprehensive application that I have seen for killing automatic processes. I think I am going to be using AutoRuns a lot in future! I love sysinternals!

image

14 July 2009

Sending Emails From CMD

I was recently asked to write a script to check if a file exists and then email someone if the file is found. I found this program called Blat. Blat is a command line email client. basically all I did to get it working was download and copy blat.exe and blat.dll to %SystemRoot%\System32.

Check the code below:

@ECHO OFF
REM ### CONFiGuRE SETTINGS HERE ################
set SMTPServer=127.0.0.1
set ToAddress=email@mydoamin.com
set fromAddress=email@mydomain.com
set Servername=My Server Name
set find="C:\myfile.txt"
REM #####################################
IF EXIST %find% (goto senderror)
goto end

:senderror
set Subject=File Found
set MessageBody=%ServerName% -File Found. (%Date%)
%SystemRoot%\System32\blat.exe -server %SMTPServer% -f %fromAddress% -to %ToAddress% -subject "%ServerName% - %Subject%" -body "%MessageBody%"
goto end

:end
@ECHO ON

11 June 2009

Windows Vista SP2

Today I accidentally found out that Windows Vista SP2 has been released! I was going through my WSUS server and noticed that my machine had a lot of updates outstanding. I then say an entry that said: "Windows Vista Serivce Pack 2 Standalone (KB948465)- English, French, German, Japanse, Spanish"

Well it looks like SP2 was released about 2 weeks ago according to this KB Article.

Anyway I am waiting for my WSUS server to download it so I can install!

04 February 2009

Microsoft Doing it Again with Windows 7?

It looks as though our dear friends at Microsoft are not learning from thier mistakes.
According to this article Windows 7 is expected to come in 7 different flavours! ARG !
I wish these guys would catch a wakeup and stick to the good old days of single desktop and server OS releases instead of making life so confusing with 7 versions!
Come on Microsoft catch the hint, no-one wants 7 choices for something as boring as an operating system. Why do you think Linux has been struggeling for so many years?

03 December 2008

Vista SP2 on its way!

It seems as though Microsoft may be releasing Windows Vista Service Pack 2 in April 2009!
Check out this article:

Lets hope that they don't release it on the 1st of April :P

20 March 2008

Windows Vista SP1

It looks like Windows Vista Service Pack 1 has been released. You can download a standalone installation (x86) from the Microsoft Download centre.
The download weighs in at a pretty heft 434.5 MB. So beware the cap.

The Service Pack does not seem to be available yet via WSUS.
Apparently the Windows Update version of the update will weigh in at only about 65MBfor the x86 version and 125Mb for the x64.
I am waiting to see what the WSUS download is going to do to my cap!
And then there is still Windows XP SP3 which should be out some time soon too!
Ah Telkom, you are going to make some money this month!

26 May 2007

WSUS 3

WSUS (Windows Server Update Services) is a Microsoft tool that allows you to provide Microsoft updates to your computers from a single interface. The new WSUS3 that was recently released provides the administrator with an MMC Console to manage all the updates for your computers. A WSUS Server downloads updates from Microsoft Update or from another WSUS server and then the client machines are forced to download the updates from the server via a Group Policy.

The Benefits of WSUS
  • Save bandwidth, because only one machine downloads your updates and distributes them instead of each computer downloading updates individually.
  • Save Time, because you manage all of your computers from one place instead of going from computer to computer.
  • Better Security, with WSUS your control over the updates will be vastly improved and therefore your network will be more secure.
Improvements from WSUS2 to WSUS3
  • MMC console instead of Web interface
  • Better reporting tools
  • More options and settings
Drawbacks of WSUS3
  • You can't sync a WSUS3 Server with a WSUS2 server
  • The MMC console is terribly slow over a WAN connection.
  • There is no web interface, so you have to install the MMC snap-in and the Microsoft Reporting tool in order to manage your server from another computer.