Solved

Activating Windows 2003-2012 remotely with script

Posted on 2013-10-22
5
342 Views
Last Modified: 2013-10-30
I need good examples of activating Windows 2003 up til 2012 remotely by script execution.
0
Comment
Question by:itnifl
  • 3
  • 2
5 Comments
 
LVL 13

Accepted Solution

by:
Alexios earned 500 total points
ID: 39593361
0
 
LVL 2

Author Comment

by:itnifl
ID: 39596476
That looks like a good solution, however RPC calls that are used here need dns or netbios resolution, which is not possible in my scenario. The same thing goes for slmgr.vbs remote.
0
 
LVL 2

Assisted Solution

by:itnifl
itnifl earned 0 total points
ID: 39602235
Since RPC calls where not working, we ended up with the following code in a script in the template for any new VM. It was automatically executed from a scheduled task as soon as the VM booted. When the script finds ban internet connection, it activates the VM and deletes the scheduled task that runs the script.

Option Explicit
'On Error Resume Next
Dim objShell, objExec, strPingResults, boolExitFlag

boolExitFlag = False
Set objShell = CreateObject("WScript.Shell")

Function ExecPing(strTarget)
	Set objExec = objShell.Exec("ping -n 2 -w 1000 " & strTarget)
	strPingResults = LCase(objExec.StdOut.ReadAll)
	If InStr(strPingResults, "reply from") Then 
		WScript.Echo VbCrLf & strTarget & " responded to ping."
		objShell.Run "slmgr.vbs /ato"
		objShell.Run "schtasks /delete /tn ""Activate_Me"" /F"
		ExecPing = True
	Else
		WScript.Echo VbCrLf & strTarget & " did not respond to ping."
		ExecPing = False
	End If
End Function

Do
	boolExitFlag = ExecPing("www.google.no")
Loop while boolExitFlag <> True

Open in new window

0
 
LVL 13

Expert Comment

by:Alexios
ID: 39608026
Glad to help
0
 
LVL 2

Author Closing Comment

by:itnifl
ID: 39611066
Thanks for participating!
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Understanding the various editions available is vital when you decide to purchase Windows Server 2012. You need to have a basic understanding of the features and limitations in each edition in order to make a well-informed decision that best suits y…
The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now