Welcome !

 Wake on LAN VbScript / HTA help

Author Message

  • Total Posts : 47
  • Scores: 0
  • Reward points : 0
  • Joined: 11/20/2008
  • Status: offline
Wake on LAN VbScript / HTA help Friday, January 03, 2014 12:58 AM (permalink)
I have created the following HTML page to run on a Windows 2008 R2 server running IIS 7.5. The vbScript uses a SQL query to get the IP address and MAC address from System Center and then should run edmwake.exe (a wake on lan application). I am used to writing client side vbscript but I am struggling to get this to run on the server using HTA/HTML. The edmwake.exe is on the server, however it does not run. The document.writes output all the way to just before the objShell command. I have been researching for hours but can't see what it wrong.
Is anyone able to offer any advice?
Thank you :-)
<title>Wake On LAN</title> 
<SCRIPT LANGUAGE="VBScript" runat="server"> 
    Sub TestSub 

  'Only variables which are declared will run 
  'Option Explicit 
  'Declare all the variables 
  Dim objConnection 
  Dim objRecordset 
  Dim objSQL 
  Dim objShell 
  Dim strMACAddress 
  Dim strIPAddress 
  Dim strBroadcast 
  Dim strBroadcastAddress 
  Dim strBroadcastAddress2 
  Dim strOfficeIP 
  Dim strOfficeName 
  Dim strComputer 
  Dim strExePath 
  Dim strInput 
  Dim strCommand 
  Dim strOutput 
  Dim strOutput0 
  Dim strOutput2 
  strComputer = (BasicTextbox.Value) 
  'SQL query which gets the IP Address and MAC Address from the NetBIOS name strComputer in the SCCM database 
   objSQL = "Select DISTINCT v_R_System.Netbios_Name0, v_RA_System_IPAddresses.IP_Addresses0, v_RA_System_MACAddresses.MAC_Addresses0 from v_R_System, v_R_System SYS, v_RA_System_MACaddresses, v_RA_System_IPAddresses, v_fullcollectionmembership where v_ra_system_macaddresses.resourceid=v_r_system.resourceid and v_fullcollectionmembership.resourceid=v_ra_system_macaddresses.resourceid and v_fullcollectionmembership.resourceid=v_RA_System_IPAddresses.resourceid and SYS.resourceid=v_r_system.resourceid and v_R_System.Netbios_Name0 = '" & strComputer & "' and v_RA_System_MACAddresses.MAC_Addresses0 NOT LIKE '00%' and v_RA_System_MACAddresses.MAC_Addresses0 NOT LIKE '08%' and v_RA_System_IPAddresses.IP_Addresses0 LIKE '10%'" 
  'Create an instance of the ADO connection and recordset objects 
  Set objConnection = CreateObject("ADODB.Connection") 
  Set objRecordset = CreateObject("ADODB.Recordset") 
  'Open the connection to the SCCM database database using a SQL username and password 
  objConnection.Open "Driver={SQL Server};Server=VM-SQL;Database=SCCM;UID=USERNAME;PWD=PASSWORD;" 
  'Open the recordset object executing the SQL statement and return records 
  objRecordset.Open objSQL,objConnection 
  'Check to see if the computer exists 
  If objRecordset.EOF Then 
  strOutput = "This computer does not exist" 
  'If the computer exists loop through the fields 
  Do While NOT objRecordset.Eof   
  strMACAddress = objRecordset("MAC_Addresses0") 
  strIPAddress = objRecordset("IP_Addresses0") 
  'Create the broadcast address from the IP address x.x.255.255 
  strBroadcast = Split(strIPAddress, ".") 
  strBroadcastAddress = strBroadcast(0) & "." & strBroadcast(1) & ".255" & ".255" 
  strOfficeIP = strBroadcast(1) 
  End If 
  'close the connection and recordset objects to free up resources 
  Set objRecordset=nothing 
  Set objConnection=nothing 
  'Converts the strOfficeIP to the office name 
  Select Case strOfficeIP 
  Case "1" strOfficeName = "Office1" 
  Case "2" strOfficeName = "Office2" 
  Case "3" strOfficeName = "Office3" 
  Case "4" strOfficeName = "Office4" 
   End Select 
  strMacAddress = Replace(strMacAddress,":","") 
  strExePath = "E:\Websites\Wake-On-Lan\edmwake.exe" 
  strCommand = strExePath & " " & strBroadcastAddress & " " & strMacAddress 
  Set objShell = Server.CreateObject("Wscript.Shell") 
  objShell.Run strCommand 
  document.write("command issued") 
 End Sub 
    <input type="text" name="BasicTextbox" size="20"><P> 
    <input id=runbutton  type="button" value="Wake On LAN" name="run_button"  onClick="TestSub"> 
    <font face="Arial" size="3"> 

<message edited by Chris424 on Friday, January 03, 2014 12:59 AM>

    • Total Posts : 3
    • Scores: 0
    • Reward points : 0
    • Joined: 4/20/2015
    • Status: offline
    Re:Wake on LAN VbScript / HTA help Wednesday, April 22, 2015 6:12 AM (permalink)
    edmwake.exe is the old Novadigm Radia module for WOL, and nvdkit.exe is the newer module I use for WOL. I have vbscript executing inside a tclhttpd web server to accomplish the same task from a web page. Sorry I don't use IIS or ASP but I do use TCL and TSP to accpmplish the same thing. You can see it on youtube be searching  
    "Remote Wake-On-Lan, WMI Inventory and Shutdown". I have many videos showing various features of the utility.
     I have over 80 vbscripts running inside the tclhttpd server to automate all kinds of things server side. I also use psexec to deploy scripts.  Here is a complete description of the utility.
    Doge is a Windows based management utility designed to automate routine admin tasks and troubleshoot remote systems from a central web-based console. It was developed specifically for Radia administration where hundreds of Windows Satellite/Proxy servers and thousands of Windows clients may need a repetitive admin task performed like stopping/starting services, collecting system information, verifying/deleting a file, remote shutdown/WOL, and executing scripts.
      The tclhttpd serves up web content where users navigate/select the desired method, enter system credentials and pass variables to the back-end scripts via a pre-configured Access database. Using a text file with a list of systems as input the scripts can be configured and executed sequentially on all remote systems in the list as well as local and single system methods from any web browser enabled device. The output is sent to either excel or the internal Access database. The back-end consists of basic Windows scripts that are widely used including batch, vbscript, psexec for remote file execution and nvdkit.exe for Wake-on-LAN. 

    Doge runs on the same tclhttpd framework as a standard Radia Integration Server and uses the same interpreter so the TCL server pages(tsp) are interchangeable. The TCL server pages are setup to interact with an internal Access database to store user input/script output, execute vbscript, and a database front-end for reporting.
    <message edited by Doge_SIA on Wednesday, April 22, 2015 6:23 AM>
      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2017 ASPPlayground.NET Forum Version 3.9