HTA menu screen

This came about as i had the need to give access to several different HTA's and scripts that i'd written. I'm sure a nicer version could be made but my HTML skills are not that good.

Because the iframe has the application variable set the html files that you point to need to be html rather than hta and they will still work correctly.

The default page of the iframe is called HSS_Welcome.html and it is in the html subfolder of the hta. You'll need to modify that to another file or create your own.

Source Code

This script has not been checked by Spiceworks. Please understand the risks before using it.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Helpdesk Express</title><SCRIPT Language="VBScript">width="1000"height="600"' This moves the window to the middle of the screen Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor WHERE DeviceID='DesktopMonitor1'")ForEachobjIteminColItemsintHorizontal=objItem.ScreenWidthintVertical=objItem.ScreenHeightNextintLeft=(intHorizontal-width)/2intTop=(intVertical-height)/2window.resizeTowidth,heightwindow.moveTointLeft,intTop</script><HTA:APPLICATIONID="objITHelpdesk"APPLICATIONNAME="HSS"BORDER="thin"CONTEXTMENU="no"ICON="images/help.ico"MAXIMIZEBUTTON="no"MINIMIZEBUTTON="yes"RESIZE="no"SCROLL="no"SINGLEINSTANCE="yes"WINDOWSTATE="normal"/><style type="text/css">body{margin:0;padding:0;background-color:#005D8B;color:#000000;}a:link{font:10ptArial,geneva,helvetica;color:white;}}a:visited{font:10ptArial,geneva,helvetica;color:white;}}a:hover{font:10ptArial,geneva,helvetica;color:white;}}p,ul,ol,li{font:10ptArial,geneva,helvetica;}h1{font:bold14ptArial,Helvetica,geneva;}h2{font:bold12ptArial,Helvetica,geneva;}#header{position:fixed;width:100%;height:2%;top:0;right:0;bottom:auto;left:0;border-bottom:0pxsolid#cccccc;}#leftnavigation{position:fixed;height:auto;top:0%;left:0;width:170px;margin:0px0px0px2px;color:#000000;padding:3px;overflow:auto;}#content{position:fixed;top:2%;bottom:2%;margin:0px0px0px175px;width:auto;height:auto;padding-left:5px;padding-right:12px;color:#000000;border-left:0pxsolid#cccccc;overflow:auto;}#contenth1,#contenth2{color:#cc0000;}#footer{display:none;background-color:#0084C7;position:fixed;width:100%;height:70px;top:auto;right:0;bottom:0;margin-left:10px;border-top:2pxsolid#cccccc;}#footerh1{text-align:center;font-size:28.0pt;font-family:PalatinoLinotype,serif;color:#FFFFFF;letter-spacing:6.0pt}/* Menu css */#dhtmlgoodies_menu{font-family:arial;/* Font for main menu items */width:150px;/* Width of main menu */}#dhtmlgoodies_menuli{/* Main menu <li> */list-style-type:none;/* No bullets */margin:0px;/* No margin - needed for Opera */}#dhtmlgoodies_menuul{margin:0px;/* No <ul> air */padding:0px;/* No <ul> air */}#dhtmlgoodies_menuulliul{/* Styling for those who doesn't have javascript enabled */padding-left:10px;}#dhtmlgoodies_menulia{/* Main menu links */text-decoration:none;/* No underline */color:#000;/* Black text color */height:20px;/* 20 pixel height */line-height:20px;/* 20 pixel height */vertical-align:middle;/* Align text in the middle */border:1pxsolid#000;/* Black border */background-color:#FAFAFA;/* Light blue background color */margin:1px;/* A little bit of air */padding:1px;/* Air between border and text inside */display:block;}#dhtmlgoodies_menulia:hover,#dhtmlgoodies_menu.activeMainMenuItem{color:#FFF;background-color:#317082;}.dhtmlgoodies_subMenu{visibility:hidden;position:absolute;overflow:hidden;border:1pxsolid#000;background-color:#FAFAFA;font-family:arial;text-align:left;}.dhtmlgoodies_subMenuul{margin:0px;padding:0px;}.dhtmlgoodies_subMenuulli{list-style-type:none;margin:0px;padding:1px;/* 1px of air between submenu border and sub menu item - (the "white" space you see on mouse over )*/}.dhtmlgoodies_subMenuullia{/* Sub menu items */white-space:nowrap;/* No line break */text-decoration:none;/* No underline */color:#000;/* Black text color */height:16px;/* 16 pixels height */line-height:16px;/* 16 pixels height */padding:1px;/* 1px of "air" inside */display:block;/* Display as block - you shouldn't change this */}.dhtmlgoodies_subMenuullia:hover{/* Sub menu items - mouse over effects */color:#FFF;/* White text */background-color:#317082;/* Blue background */}</style><script type="text/javascript">/**** A huge thanks to Dean Parkinson for the help with this widget*//************************************************************************************************************@fileoverviewSlide out menuCopyright (C) 2007 Dean ParkinsonThis library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USAAlf Magne Kalleland, 2007Owner of DHTMLgoodies.com************************************************************************************************************/varMENUDIV_ID="dhtmlgoodies_menu";varSUBMENU_CLASS='dhtmlgoodies_subMenu';varmenuItems;varslideSpeed_out=50;// Steps to move sub menu at a time ( higher = faster)varslideSpeed_in=50;vardelayMenuClose=100;// Microseconds from mouseout to close of menuvarslideTimeout_out=25;// Microseconds between slide steps ( lower = faster)varslideTimeout_in=10;// Microseconds between slide steps ( lower = faster)varxOffsetSubMenu=0;// Offset x-position of sub menu items - use negative value if you want the sub menu to overlap main menu/* Don't change anything below here */varindeces=newArray();indeces[0]=0;varisMSIE=navigator.userAgent.indexOf('MSIE')>=0?true:false;varbrowserVersion=parseInt(navigator.userAgent.replace(/.*?MSIE ([0-9]+?)[^0-9].*/g,'$1'));if(!browserVersion)browserVersion=1;functionmouseOn(obj){varmi=findNode(getSearchIdFromObj(obj));if(mi)mi.mouseOn();}functionmouseOff(obj){varmi=findNode(getSearchIdFromObj(obj));if(mi)mi.mouseOff();}functiongetSearchIdFromObj(obj){// pull the postfix off the A link or LI tag id and return the menu item IDvarobjId=obj.id;varidx=objId.indexOf('_');if(idx>=0){return"MenuItem"+objId.substring(idx);}returnnull;}functionslideChildMenu(aId){varmi=findNode(aId);if(mi)mi.slideChildMenu();}functionfindNode(searchId){varresult;for(varno=0;no<menuItems.length;no++){result=menuItems[no].findNode(searchId);if(result)returnresult;}returnnull;}functiongetNextIndex(lvl){varresult=0;if(indeces.length<=lvl){indeces[lvl]=1;}else{result=indeces[lvl];indeces[lvl]++;}returnresult;}functionMenuItem(divref,ulref,liref,lvlnum,parentref){this.parent=parentref;this.div=divref;this.ul=ulref;this.width=this.ul.offsetWidth;// this.left = div.style.left.replace(/[^0-9]/g,'');this.li=liref;this.alink=this.li.getElementsByTagName('A')[0];this.lvl=lvlnum;this.idx=getNextIndex(this.lvl);this.children;this.subUL=this.li.getElementsByTagName('UL')[0];this.children;this.isMouseOnMe=false;// note: if !isOpen && !isClosed then I am animating a slidethis.isChildMenuOpen=false;this.isChildMenuClosed=true;// Constructor// if a node does not have an A tag but it's children do then we need// null out this node's alink field...if(this.alink){if(this.alink.parentNode!=this.li)this.alink=null;}if(this.subUL){this.children=newArray();varsubLI=this.subUL.getElementsByTagName('LI')[0];while(subLI){if(subLI.tagName&&subLI.tagName.toLowerCase()=='li'){this.children[this.children.length]=newMenuItem(null,this.subUL,subLI,this.lvl+1,this);}subLI=subLI.nextSibling;}}this.getPostfix=function(){return'_'+this.idx+'_'+this.lvl;}this.getId=function(){return"MenuItem"+this.getPostfix();}this.hasChildren=function(){return(this.children!=null);}this.getTopPos=function(){varorigDisp=this.div.style.display;this.div.style.display="";varobj=this.li;varresult=obj.offsetTop;while((obj=obj.offsetParent)!=null)result+=obj.offsetTop;this.div.style.display=origDisp;returnresult;}this.getLeftPos=function(){varorigDisp=this.div.style.display;this.div.style.display="";varobj=this.li;varresult=obj.offsetLeft;while((obj=obj.offsetParent)!=null)result+=obj.offsetLeft;this.div.style.display=origDisp;returnresult;}this.renderNode=function(){// set node propertiesthis.li.id="menuItemLI"+this.getPostfix();this.ul.style.position="relative";if(this.alink){this.alink.id="menuItemA"+this.getPostfix();this.alink.onmouseover=function(){mouseOn(this);};this.alink.onmouseout=function(){mouseOff(this);};}else{this.li.onmouseover=function(){mouseOn(this);};this.li.onmouseout=function(){mouseOff(this);};}// set sub-menu nodesif(this.hasChildren()){varmi=this.children[0];varsubdiv=document.createElement('DIV');subdiv.className=SUBMENU_CLASS;document.body.appendChild(subdiv);subdiv.id="menuItemDIV"+mi.getPostfix();this.subUL.id="menuItemUL"+mi.getPostfix();subdiv.appendChild(this.subUL);subdiv.style.left=this.getLeftPos()+this.width+xOffsetSubMenu+'px';subdiv.style.top=this.getTopPos()+'px';subdiv.style.visibility="hidden";subdiv.style.display="none";subdiv.style.zindex="1000";for(varno=0;no<this.children.length;no++){varmi=this.children[no];mi.div=subdiv;mi.renderNode();}}returnthis.li;}this.findNode=function(searchId){varresult;if(this.getId()==searchId){result=this;}else{if(this.hasChildren()){for(varno=0;no<this.children.length;no++){varmi=this.children[no];result=mi.findNode(searchId);if(result!=null)break;}}}returnresult;}this.mouseOn=function(){this.isMouseOnMe=true;if(this.hasChildren()&&this.isChildMenuClosed){this.initiateChildMenuOpen();}}this.mouseOff=function(){this.isMouseOnMe=false;if(this.hasChildren()&&!this.isChildMenuClosed){this.initiateChildMenuClose();}elseif(this.parent){this.parent.mouseOff();}}this.isMouseOnChild=function(){if(this.isMouseOnMe)returntrue;if(this.hasChildren()){for(varno=0;no<this.children.length;no++){if(this.children[no].isMouseOnChild())returntrue;}}returnfalse;}this.initiateChildMenuOpen=function(){this.isChildMenuClosed=false;varchildDiv=this.children[0].div;childDiv.style.width="0px";childDiv.style.visibility="visible";childDiv.style.display="";this.slideChildMenu();}this.initiateChildMenuClose=function(){this.isChildMenuOpen=false;// we have to wait to close the menu// allow the mouse to navigate over the child menusetTimeout("slideChildMenu('"+this.getId()+"')",delayMenuClose);}this.slideChildMenu=function(){vardivref=this.children[0].div;varulref=this.children[0].ul;varmaxwidth=this.children[0].width;varnextWidth;if(this.isMouseOnMe||this.isMouseOnChild()){nextWidth=divref.offsetWidth+slideSpeed_out;if(nextWidth>=maxwidth){this.finishOpeningChild(divref,ulref,maxwidth);}else{ulref.style.left=nextWidth-maxwidth+"px";divref.style.width=nextWidth+"px";setTimeout("slideChildMenu('"+this.getId()+"')",slideTimeout_out);}}else{nextWidth=divref.offsetWidth-slideSpeed_in;if(nextWidth<=0){this.finishClosingChild(divref,ulref,maxwidth);}else{ulref.style.left=nextWidth-maxwidth+"px";divref.style.width=nextWidth+"px";setTimeout("slideChildMenu('"+this.getId()+"')",slideTimeout_out);}}}this.finishOpeningChild=function(divref,ulref,maxwidth){this.isChildMenuOpen=true;this.isChildMenuClosed=false;ulref.style.left="0px";divref.style.width=maxwidth+"px";}this.finishClosingChild=function(divref,ulref,maxwidth){this.isChildMenuOpen=false;this.isChildMenuClosed=true;divref.style.visibility="hidden";divref.style.display="none";divref.style.width=maxwidth+"px";if(this.parent)this.parent.mouseOff();}}functioncollectMenuNodes(menuObj){if(!menuObj)returnnull;varresults=newArray();varmenuUL=menuObj.getElementsByTagName('UL')[0];varmenuLI=menuUL.getElementsByTagName('LI')[0];while(menuLI){if(menuLI.tagName&&menuLI.tagName.toLowerCase()=='li'){results[results.length]=newMenuItem(menuObj,menuUL,menuLI,0,null);}menuLI=menuLI.nextSibling;}returnresults;}functioninitMenu(){varmainDiv=document.getElementById(MENUDIV_ID);menuItems=collectMenuNodes(mainDiv);if(menuItems){for(varno=0;no<menuItems.length;no++){varmi=menuItems[no];mi.renderNode();}mainDiv.style.visibility='visible';}// window.onresize = resetPosition;}window.onload=initMenu;</script><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"></head><SCRIPT Language="VBScript"><!--Thisallowsyoutospecifyusernamesthatgetaccesstotheadmintoolssection,invisibletootherusers-->DimAdmins(2)Admins(0)="admin1"Admins(1)="admin2"Admins(2)="admin3"SubWindow_OnLoadstrComputerName="."SetobjWMIService=GetObject("winmgmts:{ImpersonationLevel=impersonate}\\"&strComputerName&"\root\cimv2")SetcolItems=objWMIService.ExecQuery(_"SELECT * FROM Win32_ComputerSystem",,48)ForEachobjItemincolItemsusername=objitem.UserNameFori=0touBound(Admins)IfLCase(right(username,3))=Admins(i)ThenAdminTools.style.display="block"NextNextEndSub</script><bodytopmargin="0"leftmargin="0"><divid="header"></div><divid="leftnavigation"><!--- START MENU HTML --><divid="dhtmlgoodies_menu"style="visibility: hidden;"><ul><li><ahref="html/HSS_Welcome.html"target="contentiframe">Home</a></li><li><ahref="#">Microsoft Office</a><ul><li><ahref="html/HSS_NYI.html"target="contentiframe">Excel</a></li><li><ahref="html/HSS_Outlook.html"target="contentiframe">Outlook</a></li><li><ahref="html/HSS_Word.html"target="contentiframe">Word</a></li></ul></li><li><ahref="#">Windows</a><ul><li><ahref="html/HSS_Printers.html"target="contentiframe">Add Printers</a></li><li><ahref="html/HSS_Drives.html"target="contentiframe">Drive Mapping</a></li><li><ahref="html/HSS_WhoIsLoggedOn.html"target="contentiframe">Who is logged on</a></li></ul></li><li><ahref="#">Other Applications</a><ul><li><ahref="html/HSS_NYI.html"target="contentiframe">AutoCAD</a></li><li><ahref="html/HSS_Netviewer.html"target="contentiframe">Netviewer</a></li></ul></li><li><ahref="html/HSS_SystemInfo.html"target="contentiframe">System Information</a></li><li><ahref="#">Job Services</a><ul><li><ahref="html/BREEAM_SetupCredits.html"target="contentiframe">BREEAM Credits Setup</a></li></ul></li><li><ahref="#"name="AdminTools"id="AdminTools"style="display:none">Admin Tools</a><ul><li><ahref="html/HSS_RSAChecklist.html"target="contentiframe">RSA Remote Checklist</a></li><li><ahref="html/HSS_ADuser.html"target="contentiframe">User Information</a></li></ul></li></ul></div><!-- END MENU HTML--><ahref="mailto:matttilford@pickeverard.co.uk&subject=Helpdesk Express Suggestion&body=%20">Comments/Suggestions</a></div><divid="content"><iframename="contentiframe"id="contentiframe"frameborder="1"APPLICATION="yes"src="html/HSS_Welcome.html"width="780"height="540"><p>Your browser does not support iframes.</p></iframe></div></body></html>

Screenshots

16 Comments

Thank you so much for sharing this Matt. You have given me a nice format to work from and also giving me some pointers.. This is very timely because I have been reorganizing our script library and spent time colorizing all my hta scripts. Now I can embed some of them into this master as well as some other features I want to make available to my help desk analysts.
Thanks again

Just to let you all know the version of this used in our office has now changed the menu to a nicer accordion style from here: http://www.dynamicdrive.com/dynamicindex1/slashdot.htm
I won't paste the updated code as the terms don't allow that, but it's simple enough to change yourself over to it (or any other menu system for that matter).
Hopefully seeing this as a basic framework has at least given you all a starting block for your own ideas.

This is very cool. I am working on customizing this to work with our company, and have already implemented the printer HTA you posted. I also have it showing the portal, but when you try to log in, a spiceworks error comes up regarding cookies. Not sure if you can think of a way to resolve that as having the portal open up within the app would be pretty cool. But other than those two things, I am having a hard time trying to figure out what other tools to put in there. All of our apps are deployed through SCCM, and I am still trying to figure out a way to call the "run advertised programs" module from HTTP with not much luck. Maybe some user guides, but most of our stuff is in PDF format. Any and all suggestions would be helpful if possible. Thanks for your great contribution.

Glad to hear that it is proving useful for you. I initially had very items in there but i am adding extra bits and bobs to it every month or two, the last one being a page to show licence usage for a program that uses file stubs that users were translating the hard way (e.g CompName_UserName_#####). Some of the tools on there have only been used maybe once or twice, i just like that they are available if i need them.
On the subject of putting the portal in there i have tested that this morning and it seemed to work fine (creating tickets, viewing old ones and visiting some links). I've not looked into how cookies work with HTA's because i don't use them so i cant commnet on your issue.
As for SCCM we don't have that here so i'm not able to test it. I found some possible examples such as http://blogs.technet.com/b/pauljones/archive/2009/02/24/sccm-scripts.aspx and http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=22552 (the SCCM SDK). By the sounds of it you are already on the way to developing your solution but are just mising the final piece of the puzzle... and i know how frustrating that can be!
Good luck with your continued development.

Hey Matt,
Thanks for your response. I got the application running quite well along with displaying very nicely on both XP and win 7 boxes.
I was able to get the SCCM application to run on both 64 bit and 32 bit machines and everything is working great.
I had stepped away from this project for a few months but once I showed this to my boss, he was so impressed with it that he wanted it deployed asap. So now I am revisiting this project and will be looking for more functionality to add to it. Thanks again for your great contribution.

The error on line 545 is because on line 532 the code is "Dim Admins(2)", but when the loop runs and checks the admin accounts, it's checking the array 5 times ( For i = 0 to 4) when the array only has 3 items. Changing the loop to 2 instead of 4 fixes the issue.
The subscript is out of range when it runs:
For i = 0 to 4
If LCase(right(username,3)) = Admins(i) Then AdminTools.style.display = "block"
Next
because Admins(3) and Admins(4) don't exist.

So if i wanted to make it an all inclusive HTA file, I would make it like a website but have the first file be this one, and then all the others will be what ever tasks I want them to be... like one page for printers (add remove network printers), another page (Install different programs)

Hi Matt, and thank you for this excellent little hta.
I have used this as a basis for a project I have started for work and have managed to add almost all the functionality I need.
However ... :)
I am struggling to the restricted menu to work - I just cannot see what version of the username the program looks at and I have tried all the versions I can see and still the menu wont display - I know it works, because if I change the '=', I can get it to come up.
We log onto domains - is this the problem?
Any pointers would be greatly appreciated and I can put the finishing touches to it.
Thanks again.
Jon

Jon the line that you might want to change is this one:
If LCase(right(username,3)) = Admins(i) Then AdminTools.style.display = "block"
If you change that to
If LCase(username) = Admins(i) Then AdminTools.style.display = "block"
you can then fill in the admins list with your domain login (i think in the pre-2000 format of Domain\Username)