Fixed lost formating
<html>
<head>
<title>RemoteTool</title>
<SCRIPT LANGUAGE="VBScript">
'# -----------------------------------------------------------------------------
'# RemoteTool CutDown Version 0.01
'# Copyright (C) 2008 Painterinfo
'# Script by MJP
'#
'# You have a royalty-free right to use, modify, reproduce and distribute
'# this script (and/or any modified version) in any way you find useful,
'# provided that you agree that Painterinfo or MJP has no
'# warranty, obligations or liability for the script. If you modify
'# the script, you must retain this copyright notice. ThankYou
'# -----------------------------------------------------------------------------
</SCRIPT>
<HTA:APPLICATION
ID="objRemoteTool"
APPLICATIONNAME="RemoteTool"
SCROLL="no"
SINGLEINSTANCE="no"
SHOWINTASKBAR="yes"
CAPTION="yes"
CONTEXTMENU="no"
Version="0.01"
>
<!-- Some style code : coloured hyperlinks, Size 12 fonts, Blue headings etc -->
<style>
body,td a {font-family:Tahoma, Veranda, Arial; font-size:16px; text-decoration:none; color:black;}
H1 { font-family:Tahoma, Veranda, Arial; font-size:20px; color : blue; }
a:link { color : yellow; background : transparent ; text-decoration: underline ; font-size:12px;}
a:visited { color : yellow; background : transparent ; text-decoration: none ; font-size:12px;}
a:Hover { color : red; background : transparent ; text-decoration: none ; font-size:12px;}
</style>
<SCRIPT Language="VBScript">
'------------------------------------------------------------
Dim strINI, BarCode, DellSerial, DellModel, DellRam, DellUser, DellOn, DellIP, DellSubnet, DellMAC, DellPhLoc
Dim XIP, SNM, SMSCheck
Dim strTempDir
Dim FullNameClean
Const ForReading = 1
Const ForWriting = 2
'------------------------------------------------------------
Sub Window_Onload
window.resizeto 860,508
messages.value=""
'get Temp folder and build ini file name
Set objShell = CreateObject("WScript.Shell")
strTempDir = objShell.ExpandEnvironmentStrings("%temp%")
strINI=strTempDir&"\LastMachine.ini"
'Read ini file for last machine accessed
INIRead
MachineName.value=BarCode
'Show About splashscreen
ShowSplash
'Query properties, location etc for loaded machine
QueryIt
'ping set machine name every 15 seconds, updating script.
iTimerID = window.setInterval("QueryIt", 15000)
messages.value="CutDown Version "&objRemoteTool.Version&vbcrlf&messages.value
MachineName.Focus
End Sub
'------------------------------------------------------------
Sub QueryButton
MachineName.value=UCase(MachineName.value)
Barcode=MachineName.value
Barcode =Replace(Barcode," ","")
if barcode="" then
barcode="Enter Barcode"
MachineName.value=barcode
end if
QueryIt
End Sub
'------------------------------------------------------------
Sub QueryIt
'Run individual subs and display results on page
BarcodeSpan.innerhtml="<b>"&Barcode&"</B>"
reachable Barcode
if DellOn= "on" then
INISet Barcode
SrvTag BarCode
ServiceTagSpan.innerhtml= DellSerial
Model Barcode
ModelSpan.innerhtml=DellModel
MyUser Barcode
UserSpan.innerhtml=DellUser
else
ServiceTagSpan.innerhtml= "Off-Line"
ModelSpan.innerhtml= "Off-Line"
UserSpan.innerhtml= "Off-Line"
End if
End Sub
'------------------------------------------------------------
sub reachable(xxx)
'ping set machine and modify script based on results.
Dim wmiQuery : wmiQuery = "Select * From Win32_PingStatus Where Address = '" & _
xxx & "'"
Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Dim objPing : Set objPing = objWMIService.ExecQuery(wmiQuery)
Dim objStatus
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) Or objStatus.Statuscode<>0 Then
DellOn = "off"
runbutton2.disabled = true
runbutton3.disabled = true
runbutton4.disabled = true
runbutton5.disabled = true
runbutton50.disabled = true
runbutton6.disabled = true
runbutton7.disabled = true
runbutton9.disabled = true
runbutton11.disabled = true
OnOff.innerhtml="<font color=red face=arial size=4>█</font>"
Else
DellOn = "on"
runbutton2.disabled = true
runbutton3.disabled = true
runbutton4.disabled = false
runbutton5.disabled = false
runbutton50.disabled = true
runbutton6.disabled = false
runbutton7.disabled = false
runbutton9.disabled = false
runbutton11.disabled = true
OnOff.innerhtml="<font color=lime face=arial size=4>█</font>"
End If
Next
end sub
'------------------------------------------------------------
Sub BrowseC
'Code to Browse C: of loaded machine
QueryIt
Set objShell = CreateObject("WScript.Shell")
return=objShell.Run ("explorer \\"& Barcode & "\c$", 1, false)
End Sub
'------------------------------------------------------------
Sub SrvTag(xxx)
'Display ServiceTag
DellSerial = ""
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & xxx & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
For Each objItem In colItems
DellSerial = "<b>"&objItem.SerialNumber&"</b>"
Next
if err.number <> 0 then
DellSerial = "Error Reading WMI"
end if
on error goto 0
end sub
'------------------------------------------------------------
Sub Model(xxx)
'Display Make and Model
DellModel = ""
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & xxx & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
DellModel = "<b>"&objItem.Vendor&" "&objItem.Name&"</b>"
Next
if err.number <> 0 then
DellModel = "Error Reading WMI"
end if
End Sub
'------------------------------------------------------------
Sub MyUser(xxx)
'Display logged on user
DellUser = ""
on error resume next
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& xxx & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'explorer.exe'")
For Each objProcess in colProcessList
objProcess.GetOwner strUserName, strUserDomain
DellUser= "<b>"&strUserDomain & "\" & strUserName & "</b> "
Next
End Sub
'------------------------------------------------------------
Sub RemoteMMC
'Launch Remote computer management console
QueryIt
Set objShell = CreateObject("WScript.Shell")
objShell.Run "compmgmt.msc /computer=" & Barcode
End Sub
'------------------------------------------------------------
Sub ShowSplash
' Show the splash screen and open the HTA on the Main page
Main.Style.Display = "none"
Splash.Style.Display = "inline"
' wait 1 seconds
sleep 3
Main.Style.Display = "inline"
Splash.Style.Display = "none"
End Sub
'------------------------------------------------------------
Sub Sleep(strSeconds)
' sub to make the script pause for x seconds
strCmd = "%COMSPEC% /c ping -n " & strSeconds & " 127.0.0.1>nul"
Set objShell=CreateObject("Wscript.shell")
objShell.Run strCmd,0,1
End Sub
'------------------------------------------------------------
sub RD
'launch Remote Desktop session
QueryIt
sLinkFile = Barcode&"_"&timer&".lnk"
'Create temporary shortcut
Set oWS = CreateObject("WScript.Shell")
Set oLink = oWS.CreateShortcut(sLinkFile)
oLink.TargetPath = "%SystemRoot%\system32\mstsc.exe"
oLink.Arguments = "/v: "&Barcode
oLink.Description = "My RDP Connection"
oLink.WorkingDirectory = "%SystemRoot%\system32\"
oLink.Save
runner sLinkFile
end sub
sub runner(sLinkFile)
'Run Program
set WshShell = CreateObject("WScript.Shell")
WshShell.Run sLinkFile
'delete file
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
fso.deletefile sLinkFile
On Error GoTo 0
end sub
'------------------------------------------------------------
Function INIRead
' The ini file code to give the script a memory of last machine accessed
Set objFSO=CreateObject("Scripting.FileSystemObject")
if objFSO.FileExists(strINI) then
Set objFile = objFSO.OpenTextFile(strINI, ForReading)
BarCode = objFile.ReadLine
else
ComputerName
end if
End Function
'------------------------------------------------------------
Function INISet(Contents)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(strINI)
objFile.WriteLine(Contents)
objFile.Close
End Function
'------------------------------------------------------------
Sub ComputerName
'Your computer's name
On Error Resume Next
Set objNet = CreateObject("WScript.NetWork")
If Err.Number <> 0 Then
BarCode = "Error"
End if
BarCode = objNet.ComputerName
end sub
'------------------------------------------------------------
sub CloseTSTools
' when the close button is pressed this code runs and closes the HTA
'display my splash screen
main.Style.Display = "none"
Splash.Style.Display = "inline"
' wait 2 seconds
sleep 2
' close HTA
self.close
end sub
'------------------------------------------------------------
sub reboot
QueryIt
'Force Reboot
'The following code will force a system to reboot, regardless of any applications open at the time.
Warning = MsgBox ("Are You Sure You Want to Reboot "&Barcode&" ?", 276, "Warning")
if Warning = 6 then
messages.value="Remote Reboot of "&Barcode&" Initiated"&vbcrlf&messages.value
Const Force_Reboot = 6
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//"&Barcode&"/root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
For Each OpSys In OpSysSet
OpSys.Win32Shutdown(Force_Reboot)
Next
end if
end sub
'------------------------------------------------------------
sub Shutdown
QueryIt
'Force Shutdown
'The following code will force a system to shutdown, regardless of any applications open at the time.
Warning = MsgBox ("Are You Sure You Want to Shutdown "&Barcode&" ?", 276, "Warning")
if Warning = 6 then
messages.value="Remote Shutdown of "&Barcode&" Initiated"&vbcrlf&messages.value
Const Force_Shutdown = 5
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//"&Barcode&"/root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
For Each OpSys In OpSysSet
OpSys.Win32Shutdown(Force_Shutdown)
Next
end if
end sub
'------------------------------------------------------------
Sub EnterPressed()
If window.event.Keycode = 13 Then
QueryButton
End If
end sub
'------------------------------------------------------------
</SCRIPT>
</head>
<body bgcolor=white onkeypress="EnterPressed">
<!--This DIV block is displayed only when the code Splash.Style.Display = "inline" is run above-->
<DIV id="Splash" STYLE="Background-color:184a5a;Background-image: url(c:\windows\Prairie Wind.bmp);Height:200;Width:400;Border:0.4mm solid black;position:relative;top:90;left:200;">
<br><br>
<center>
<font face="arial" color=White size=5><b><i> RemoteTool </i></b></font>
<br>
<a href="By">
http://www.painterinfo.co...orum.php?f=17%22>By MJP 2007</a><br><br>
<font color=white>Cut Down Version </font>
</center>
</DIV>
<DIV id="Main" STYLE="display:none;position:absolute">
<table border=1 cellpadding=5 bgcolor=silver>
<tr>
<td>
<table border=0>
<tr>
<td width=300 Align=left valign="center"><span id=OnOff></span><input type="text" name="MachineName" size="20" value="Enter Machine Name"> <input id=runbutton1 class="button" type="button" value="LOAD" name="run_button1" onClick="QueryButton"></td>
<td width=400 valign="center"><font face="arial" color=Red size=5><b><i> Remote Tool </font></b> <font color="black" size="2"></font></i></td>
<td width=100 valign="center"align="right"><input id=runbutton8 class="button" type="button" value="CLOSE" name="run_button8" onClick="CloseTSTools"></td>
</tr>
</table>
<br><br>
<table border=0 cellspacing=1>
<tr>
<td width="190" valign="top"><input id=runbutton5 class="button" type="button" value="" name="run_button5" onClick="RemoteMMC"> Manage</td>
<td width="100" bgcolor="d9d9d9" align="right" valign="top">Machine: </td>
<td width="510" bgcolor="d9d9d9" valign="top"><span id=BarcodeSpan></span></td>
</tr>
<tr>
<td width="190" valign="top"><input id=runbutton50 class="button" type="button" value="" name="run_button50" onClick=""> <font color="f3f3f3"><i>Software Profile</i></font></td>
<td width="100" bgcolor="f3f3f3"align="right" valign="top">Network: </td>
<td width="510" bgcolor="f3f3f3"valign="top"><span id=LocationSpan><font color=silver><i>Physical Location of machine based on subnet</i></font></span></td>
</tr>
<tr>
<td width="190" valign="top"><input id=runbutton2 class="button" type="button" value="" name="run_button2" onClick=""> <font color="f3f3f3"><i>SMS Remote Tools</i></font></td>
<td width="100" bgcolor="d9d9d9" align="right" valign="top">Service Tag: </td>
<td width="510" bgcolor="d9d9d9" valign="top"><span id=ServiceTagSpan></span></td>
</tr>
<tr>
<td width="190" valign="top"><input id=runbutton3 class="button" type="button" value="" name="run_button3" onClick=""> <font color="f3f3f3"><i>SMS Remote Assist</i></font></td>
<td width="100" bgcolor="f3f3f3"align="right" valign="top">Model: </td>
<td width="510" bgcolor="f3f3f3"valign="top"><span id=ModelSpan></span></td>
</tr>
<tr>
<td width="190" valign="top"><input id=runbutton4 class="button" type="button" value="" name="run_button4" onClick="RD"> Remote Desktop</td>
<td width="100" bgcolor="d9d9d9" align="right" valign="top">User: </td>
<td width="510" bgcolor="d9d9d9" valign="top"><span id=UserSpan></span></td>
</tr>
<tr>
<td width="190" valign="top"><input id=runbutton6 class="button" type="button" value="" name="run_button6" onClick="BrowseC"> Browse C:</td>
<td width="100" bgcolor="f3f3f3"align="right" valign="top">Ram: </td>
<td width="510" bgcolor="f3f3f3"valign="top"><span id=RamSpan><font color=silver><i>Not implemented in this free version</i></font></span></td>
</tr>
<tr>
<td width="190" valign="top"><input id=runbutton7 class="button" type="button" value="" name="run_button7" onClick="Reboot"> Reboot <input id=runbutton9 class="button" type="button" value="" name="run_button9" onClick="Shutdown"> Shutdown</td>
<td width="100" bgcolor="d9d9d9" align="right" valign="top">Address: </td>
<td width="510" bgcolor="d9d9d9" valign="top"><span id=IPSpan><font color=silver><i>Not implemented in this free version</i></font></span></td>
</tr>
<tr>
<td width="190" valign="top"><input id=runbutton11 class="button" type="button" value="" name="run_button11" onClick=""> <font color="f3f3f3"><i>Wakeup</i> </font></td>
<td width="100" bgcolor="f3f3f3" align="right" valign="top">Mac: </td>
<td width="510" bgcolor="f3f3f3" valign="top"><span id=MacSpan><font color=silver><i>Not implemented in this free version</i></font></span></td>
</tr>
</table>
<br><br>
Log:
<br>
<textarea name="Messages" rows="5" cols="98"></textarea>
</td>
</tr>
</table>
</DIV>
</body>
</html>