?
Solved

Activating Windows 2003-2012 remotely with script

Posted on 2013-10-22
5
Medium Priority
?
377 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 13

Accepted Solution

by:
Alexios earned 2000 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

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

649 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