?
Solved

Easy Access Toolbar

Posted on 2009-04-19
14
Medium Priority
?
1,043 Views
Last Modified: 2013-11-25
Hi All,

I am working on a VBScript project called 'Easy Access Toolbar'. Which is a mixture of HTA and VBScript. I am althrough with it and having some problem at two of the places. First let me let u know what it is exactly.
There is a HTA file, once double clicked on it, it will ask for username and password (i will enter my domain admin credtianls). Once entered and clicked ok, it will open a another HTA, which will look like a Toolbar. I will have all the required applications on it. Once clicked on the buttons it will open a associated application.

Now what i need is:
1) Once click on one button it should open another HTA ---> How to do that?
2) Once clicked on one more button how to open MMC using my domain crediantials as we have blocked MMC in our environment and will open only with our domain crediatials.

<html>
 
<head>
    <title>Easy Access Toolbar</title>
	<HTA:APPLICATION 
     APPLICATIONNAME="Easy Access Toolbar"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
     Icon="./Images/icon.ico"
     Maximizebutton="no"
     ContextMenu="no"
>
</head>
 
<Script Language="VBScript">
    Sub Window_Onload
	  intWidth = 500
      intHeight = 100
      Me.ResizeTo intWidth, intHeight
      Me.MoveTo ((Screen.Width) - (intWidth)),((Screen.Height / 11) - (intHeight))
        DellButton.Width = 64
        DellButton.Height = 64
        DellButton.Picture = LoadPicture("c:\dell.bmp")
    End Sub
   
    Sub DellButton_Click()
		'Second HTA Code Here
		
    End Sub
</Script>
 
<body topmargin="0" rightmargin="0" leftmargin="0">
 
<table width="100%" border="1" width="100%" bordercolorlight="buttonface" 
bordercolordark="buttonface" style="border-collapse:collapse">
   <tr>
        <td width="100%" bgcolor="buttonface">
            <object classid="clsid:D7053240-CE69-11CD-A777-00DD01143C57" id="DellButton"></object>
       </td>
    </tr>
<table>
 
<p>&nbsp;<p>
<blockquote>
 
<span id=DataArea></span>
 
</blockquote>
</body>
</html>

Open in new window

0
Comment
Question by:Dhiraj Mutha
  • 7
  • 7
14 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 24189521
Hi there, try this.

For point 1, we use the executable MSHTA.exe to run another HTA.

For point 2, we use PSExec to run "MMC C:\windows\system32\compmgmt.msc"

You need to change
strHTAPath = "\\server\share\OtherHTA.hta"

to point to the second HTA you want to run, and you need to change
strPSExecPath = "\\server\share\psexec.exe"

to point to where you  have PSExec.exe

Regards,

Rob.
<html>
 
<head>
    <title>Easy Access Toolbar</title>
	<HTA:APPLICATION 
     APPLICATIONNAME="Easy Access Toolbar"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
     Icon="./Images/icon.ico"
     Maximizebutton="no"
     ContextMenu="no"
>
</head>
 
<Script Language="VBScript">
    Sub Window_Onload
	  intWidth = 500
      intHeight = 100
      Me.ResizeTo intWidth, intHeight
      Me.MoveTo ((Screen.Width) - (intWidth)),((Screen.Height / 11) - (intHeight))
        DellButton.Width = 64
        DellButton.Height = 64
        DellButton.Picture = LoadPicture("c:\dell.bmp")
    End Sub
   
    Sub DellButton_Click()
		'Second HTA Code Here
		
    End Sub
    
    Sub Run_HTA
		Set objShell = CreateObject("WScript.Shell")
		strHTAPath = "\\server\share\OtherHTA.hta"
		strCommand = "mshta.exe """ & strHTAPath & """"
		objShell.Run strCommand, 1, False
    End Sub
    
    Sub Run_MMC
    	Set objFSO = CreateObject("Scripting.FileSystemObject")
    	Set objNetwork = CreateObject("WScript.Network")
    	Set objShell = CreateObject("WScript.Shell")
    	strPSExecPath = "\\server\share\psexec.exe"
    	strPSExecPath = objFSO.GetFile(strPSExecPath).ShortPath
    	strUser = InputBox("Enter user name (eg. DOMAIN\User):", "Username")
    	strPass = InputBox("Enter password:", "Password")
    	strComputer = objNetwork.ComputerName
    	strCommand = "cmd /c " & strPSExecPath & " -accepteula -i -d -u " & strUser & " -p " & strPass & " \\" & strComputer & " mmc c:\windows\system32\compmgmt.msc"
    	objShell.Run strCommand, 0, False
    End Sub
</Script>
 
<body topmargin="0" rightmargin="0" leftmargin="0">
 
<table width="100%" border="1" width="100%" bordercolorlight="buttonface" 
bordercolordark="buttonface" style="border-collapse:collapse">
   <tr>
        <td width="100%" bgcolor="buttonface">
            <object classid="clsid:D7053240-CE69-11CD-A777-00DD01143C57" id="DellButton"></object>
       </td>
       <td width="100%" bgcolor="buttonface" align="center">
            <input type="button" value="Run HTA" name="btn_runhta"  onClick="vbs:Run_HTA" style="font-size: 16px;">
       </td>
       <td width="100%" bgcolor="buttonface" align="center">
            <input type="button" value="Run MMC" name="btn_runmmc"  onClick="vbs:Run_MMC" style="font-size: 16px;">
       </td>
    </tr>
<table>
 
<p>&nbsp;<p>
<blockquote>
 
<span id=DataArea></span>
 
</blockquote>
</body>
</html>

Open in new window

0
 
LVL 14

Author Comment

by:Dhiraj Mutha
ID: 24190900
You are a STAR Rob.... Thanks for the support.
The other HTA part is working super cool... even MMC is working. My only concern is that it is asking for username and password.
I am using one more HTA (this HTA only has a usrename & password field, once entered my Domain Admin Credentials it will open the Easy Access Toolbar).
Can we use the same username and password for MMC to open.
I have pasted the code of the other HTA. (This is your code Rob, what i am using)

<html>
<head>
<title>Run Program With Alternate Credentials</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Run Program With Alternate Credentials"
     BORDER="thin"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
 
<script language="VBScript">
 
Dim strPSExecPath
Dim strComputer
Dim strSecondHTAPath
 
Sub Window_onLoad
	intWidth = 600
	intHeight = 480
	Me.ResizeTo intWidth, intHeight
    Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If Mid(document.location, 6, 3) = "///" Then
    	strHTAPath = Mid(Replace(Replace(document.location, "%20", " "), "/", "\"), 9)
    Else
    	strHTAPath = Mid(Replace(Replace(document.location, "%20", " "), "/", "\"), 6)
    End If
    strPSExecPath = Left(strHTAPath, InStrRev(strHTAPath, "\")) & "psexec.exe"
    strSecondHTAPath = Left(strHTAPath, InStrRev(strHTAPath, "\")) & "TestHTA2.hta"
    'strSecondHTAPath = "C:\cit.hta"
    If objFSO.FileExists(strPSExecPath) Then
    	strPSExecPath = objFSO.GetFile(strPSExecPath).ShortPath
    Else
    	MsgBox "Could not find PSExec at:" & VbCrLf & strPSExecPath
    	Window.Close
    End If
    Set objNetwork = CreateObject("WScript.Network")
    strComputer = objNetwork.ComputerName
    
    txt_username.Focus
End Sub
 
Sub Default_Buttons
	If Window.Event.KeyCode = 13 Then
		btn_submit.Click
	End If
End Sub
 
Sub Run_Second_HTA
	If txt_username.Value = "" Then
		MsgBox "Please enter a user name."
		txt_username.Focus
	ElseIf txt_password.Value = "" Then
		MsgBox "Please enter a password."
		txt_password.Focus
	Else
		Set objShell = CreateObject("WScript.Shell")
		strUser = txt_username.Value
		strPass = txt_password.Value
		If Right(LCase(strSecondHTAPath), 4) = ".hta" Then
			strCommand = strPSExecPath & " -accepteula -i -d -u " & strUser & " -p " & strPass & " \\" & strComputer & " mshta.exe """ & strSecondHTAPath & """"
		Else
			strCommand = strPSExecPath & " -accepteula -i -d -u " & strUser & " -p " & strPass & " \\" & strComputer & " """ & strSecondHTAPath & """"
		End If
		' MsgBox strCommand
		' Exit Code 1326 is invalid password from PSExec 1.85
		strExitCode = objShell.Run(strCommand, 0, True)
		If strExitCode = 1326 Then
			MsgBox "Username or Password invalid. Please verify your credentials."
			txt_password.Value = ""
			txt_password.Focus
		Else
			window.close
		End If
	End If
End Sub
 
</script>
</head>
<body style="background-color:#B0C4DE" onkeypress='vbs:Default_Buttons'>
	<table width='90%' height='100%' align='center' border='0'>
		<tr>
			<td align="center" style="font-family: arial; font-size: 24px; font-weight: bold;">
				Run Program With Alternate Credentials
			</td>
		</tr>
		<tr>
			<td align='center' style="font-family: arial; font-size: 16px; font-weight: bold;">
				Enter username: <input type="text" maxlength="30" size="40" id="txt_username" name="txt_username" style="font-size: 14px;"><BR><BR>
				Enter password: <input type="password" maxlength="30" size="40" id="txt_password" name="txt_password" style="font-size: 14px;"><BR>
				<br>Note: Username must be DOMAIN\UserName
			</td>
		</tr>
		<tr>
			<td align='center'>
				<input type="button" value="Go!" name="btn_submit"  onClick="vbs:Run_Second_HTA" style="font-size: 16px;"><br><br>
			</td>
		</tr>
	</table>
</body>
</html>

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 24191803
OK sure, if you want to use the HTA you just posted, I've just added another button for the MMC.

Regards,

Rob.
<html>
<head>
<title>Run Program With Alternate Credentials</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Run Program With Alternate Credentials"
     BORDER="thin"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
 
<script language="VBScript">
 
Dim strPSExecPath
Dim strComputer
Dim strSecondHTAPath
 
Sub Window_onLoad
	intWidth = 600
	intHeight = 480
	Me.ResizeTo intWidth, intHeight
    Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If Mid(document.location, 6, 3) = "///" Then
    	strHTAPath = Mid(Replace(Replace(document.location, "%20", " "), "/", "\"), 9)
    Else
    	strHTAPath = Mid(Replace(Replace(document.location, "%20", " "), "/", "\"), 6)
    End If
    strPSExecPath = Left(strHTAPath, InStrRev(strHTAPath, "\")) & "psexec.exe"
    strSecondHTAPath = Left(strHTAPath, InStrRev(strHTAPath, "\")) & "TestHTA2.hta"
    'strSecondHTAPath = "C:\cit.hta"
    If objFSO.FileExists(strPSExecPath) Then
    	strPSExecPath = objFSO.GetFile(strPSExecPath).ShortPath
    Else
    	MsgBox "Could not find PSExec at:" & VbCrLf & strPSExecPath
    	Window.Close
    End If
    Set objNetwork = CreateObject("WScript.Network")
    strComputer = objNetwork.ComputerName
    
    txt_username.Focus
End Sub
 
Sub Default_Buttons
	If Window.Event.KeyCode = 13 Then
		btn_submit.Click
	End If
End Sub
 
Sub Run_Second_HTA
	If txt_username.Value = "" Then
		MsgBox "Please enter a user name."
		txt_username.Focus
	ElseIf txt_password.Value = "" Then
		MsgBox "Please enter a password."
		txt_password.Focus
	Else
		Set objShell = CreateObject("WScript.Shell")
		strUser = txt_username.Value
		strPass = txt_password.Value
		If Right(LCase(strSecondHTAPath), 4) = ".hta" Then
			strCommand = strPSExecPath & " -accepteula -i -d -u " & strUser & " -p " & strPass & " \\" & strComputer & " mshta.exe """ & strSecondHTAPath & """"
		Else
			strCommand = strPSExecPath & " -accepteula -i -d -u " & strUser & " -p " & strPass & " \\" & strComputer & " """ & strSecondHTAPath & """"
		End If
		' MsgBox strCommand
		' Exit Code 1326 is invalid password from PSExec 1.85
		strExitCode = objShell.Run(strCommand, 0, True)
		If strExitCode = 1326 Then
			MsgBox "Username or Password invalid. Please verify your credentials."
			txt_password.Value = ""
			txt_password.Focus
		Else
			window.close
		End If
	End If
 
    Sub Run_MMC
		If txt_username.Value = "" Then
			MsgBox "Please enter a user name."
			txt_username.Focus
		ElseIf txt_password.Value = "" Then
			MsgBox "Please enter a password."
			txt_password.Focus
		Else
	    	Set objFSO = CreateObject("Scripting.FileSystemObject")
	    	Set objNetwork = CreateObject("WScript.Network")
	    	Set objShell = CreateObject("WScript.Shell")
	    	strPSExecPath = "\\server\share\psexec.exe"
	    	strPSExecPath = objFSO.GetFile(strPSExecPath).ShortPath
	    	strUser = txt_username.Value
	    	strPass = txt_password.Value
	    	strComputer = objNetwork.ComputerName
	    	strCommand = "cmd /c " & strPSExecPath & " -accepteula -i -d -u " & strUser & " -p " & strPass & " \\" & strComputer & " mmc c:\windows\system32\compmgmt.msc"
	    	objShell.Run strCommand, 0, False
	    End If
    End Sub
 
End Sub
 
</script>
</head>
<body style="background-color:#B0C4DE" onkeypress='vbs:Default_Buttons'>
	<table width='90%' height='100%' align='center' border='0'>
		<tr>
			<td align="center" style="font-family: arial; font-size: 24px; font-weight: bold;">
				Run Program With Alternate Credentials
			</td>
		</tr>
		<tr>
			<td align='center' style="font-family: arial; font-size: 16px; font-weight: bold;">
				Enter username: <input type="text" maxlength="30" size="40" id="txt_username" name="txt_username" style="font-size: 14px;"><BR><BR>
				Enter password: <input type="password" maxlength="30" size="40" id="txt_password" name="txt_password" style="font-size: 14px;"><BR>
				<br>Note: Username must be DOMAIN\UserName
			</td>
		</tr>
		<tr>
			<td align='center'>
				<input type="button" value="Run HTA" name="btn_submit"  onClick="vbs:Run_Second_HTA" style="font-size: 16px;"><br><br>
				<input type="button" value="Run MMC" name="btn_runmmc"  onClick="vbs:Run_MMC" style="font-size: 16px;"><br><br>
			</td>
		</tr>
	</table>
</body>
</html>

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 14

Author Comment

by:Dhiraj Mutha
ID: 24192999
No Rob... i understand what you are saying... but will require to run MMC from the other HTA. is that possible?
0
 
LVL 14

Author Comment

by:Dhiraj Mutha
ID: 24198086
Also one more thing... after closing the Toolbar PSEXEC process in taskmanager is still running.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 24202022
OK, try this....I added a username and password to your original HTA.

Regards,

Rob.
<html>
 
<head>
    <title>Easy Access Toolbar</title>
	<HTA:APPLICATION 
     APPLICATIONNAME="Easy Access Toolbar"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
     Icon="./Images/icon.ico"
     Maximizebutton="no"
     ContextMenu="no"
>
</head>
 
<Script Language="VBScript">
    Sub Window_Onload
	  intWidth = 700
      intHeight = 110
      Me.ResizeTo intWidth, intHeight
      'Me.MoveTo ((Screen.Width) - (intWidth)),((Screen.Height / 11) - (intHeight))
      Me.MoveTo ((Screen.Width) - (intWidth)),(0)
        DellButton.Width = 64
        DellButton.Height = 64
        DellButton.Picture = LoadPicture("c:\dell.bmp")
    End Sub
   
    Sub DellButton_Click()
		'Second HTA Code Here
		
    End Sub
    
    Sub Run_HTA
		Set objShell = CreateObject("WScript.Shell")
		strHTAPath = "\\server\share\OtherHTA.hta"
		strCommand = "mshta.exe """ & strHTAPath & """"
		objShell.Run strCommand, 1, False
    End Sub
    
    Sub Run_MMC
    	Set objFSO = CreateObject("Scripting.FileSystemObject")
    	Set objNetwork = CreateObject("WScript.Network")
    	Set objShell = CreateObject("WScript.Shell")
    	strPSExecPath = "\\server\share\psexec.exe"
    	strPSExecPath = objFSO.GetFile(strPSExecPath).ShortPath
    	strUser = txt_username.Value
    	strPass = txt_password.Value
    	strComputer = objNetwork.ComputerName
    	strCommand = strPSExecPath & " -accepteula -i -d -u " & strUser & " -p " & strPass & " \\" & strComputer & " mmc c:\windows\system32\compmgmt.msc"
    	objShell.Run strCommand, 0, False
    End Sub
</Script>
 
<body topmargin="0" rightmargin="0" leftmargin="0">
 
<table border="1" width="100%" bordercolorlight="buttonface" 
bordercolordark="buttonface" style="border-collapse:collapse">
   <tr>
        <td width="10%" bgcolor="buttonface">
            <object classid="clsid:D7053240-CE69-11CD-A777-00DD01143C57" id="DellButton"></object>
       </td>
		<td align='center' bgcolor="buttonface" width="70%">
			Enter username: <input type="text" maxlength="30" size="40" id="txt_username" name="txt_username" style="font-size: 14px;"><BR>
			Enter password: <input type="password" maxlength="30" size="40" id="txt_password" name="txt_password" style="font-size: 14px;"><BR>
			Note: Username must be DOMAIN\UserName
		</td>
 
       <td bgcolor="buttonface" align="center">
            <input type="button" value="Run HTA" name="btn_runhta"  onClick="vbs:Run_HTA" style="font-size: 16px;">
       </td>
       <td width="100%" bgcolor="buttonface" align="center">
            <input type="button" value="Run MMC" name="btn_runmmc"  onClick="vbs:Run_MMC" style="font-size: 16px;">
       </td>
    </tr>
<table>
 
<p>&nbsp;<p>
<blockquote>
 
<span id=DataArea></span>
 
</blockquote>
</body>
</html>

Open in new window

0
 
LVL 14

Author Comment

by:Dhiraj Mutha
ID: 24203777
I will check and let you know. but it would have been great if you would have done something for my exact request.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 24210003
Sorry I'm not sure exactly what you mean....I have added the ability to enter username and password into the original HTA that you posted.  If that was incorrect, can you please let me the post id that has the code here, that you want the MCC to run from?

Are you saying that you have your HTA (the original code) with a button to run the other HTA, then *on the other HTA* you want the button to run the MMC instead?  Sorry if I do not understand...

Regards,

Rob.
0
 
LVL 14

Author Comment

by:Dhiraj Mutha
ID: 24211771
Yes you are right... I have the HTA with a option to enter user id and password with a button (my second post with the code - your code) which will open other HTA and i want the button on the that (the orginal post - the code which i posted first) to run mmc.
 
Open a HTA > That will ask username and password > Click on Run > That will close the first HTA and open other HTA (Easy Access Toolbar) > With all the buttons on it including MMC.
0
 
LVL 14

Author Comment

by:Dhiraj Mutha
ID: 24247759
Any updates on this mate?
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 24247826
Hi, so if you use this as HTA 1 (to be able to run the second HTA with alternate credentials), is that right?

You need to change:
    strPSExecPath = Left(strHTAPath, InStrRev(strHTAPath, "\")) & "psexec.exe"
    strSecondHTAPath = Left(strHTAPath, InStrRev(strHTAPath, "\")) & "TestHTA2.hta"

to point to PSExec.exe, and the second HTA.

In the following post I'll post the HTA that strSecondHTAPath refers to.

Regards,

Rob.
<html>
<head>
<title>Run Program With Alternate Credentials</title>
<HTA:APPLICATION 
     APPLICATIONNAME="Run Program With Alternate Credentials"
     BORDER="thin"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
>
 
<script language="VBScript">
 
Dim strPSExecPath
Dim strComputer
Dim strSecondHTAPath
 
Sub Window_onLoad
	intWidth = 600
	intHeight = 480
	Me.ResizeTo intWidth, intHeight
    Me.MoveTo ((Screen.Width / 2) - (intWidth / 2)),((Screen.Height / 2) - (intHeight / 2))
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If Mid(document.location, 6, 3) = "///" Then
    	strHTAPath = Mid(Replace(Replace(document.location, "%20", " "), "/", "\"), 9)
    Else
    	strHTAPath = Mid(Replace(Replace(document.location, "%20", " "), "/", "\"), 6)
    End If
    strPSExecPath = Left(strHTAPath, InStrRev(strHTAPath, "\")) & "psexec.exe"
    strSecondHTAPath = Left(strHTAPath, InStrRev(strHTAPath, "\")) & "TestHTA2.hta"
    'strSecondHTAPath = "C:\cit.hta"
    If objFSO.FileExists(strPSExecPath) Then
    	strPSExecPath = objFSO.GetFile(strPSExecPath).ShortPath
    Else
    	MsgBox "Could not find PSExec at:" & VbCrLf & strPSExecPath
    	Window.Close
    End If
    Set objNetwork = CreateObject("WScript.Network")
    strComputer = objNetwork.ComputerName
    
    txt_username.Focus
End Sub
 
Sub Default_Buttons
	If Window.Event.KeyCode = 13 Then
		btn_submit.Click
	End If
End Sub
 
Sub Run_Second_HTA
	If txt_username.Value = "" Then
		MsgBox "Please enter a user name."
		txt_username.Focus
	ElseIf txt_password.Value = "" Then
		MsgBox "Please enter a password."
		txt_password.Focus
	Else
		Set objShell = CreateObject("WScript.Shell")
		strUser = txt_username.Value
		strPass = txt_password.Value
		If Right(LCase(strSecondHTAPath), 4) = ".hta" Then
			strCommand = strPSExecPath & " -accepteula -i -d -u " & strUser & " -p " & strPass & " \\" & strComputer & " mshta.exe """ & strSecondHTAPath & """"
		Else
			strCommand = strPSExecPath & " -accepteula -i -d -u " & strUser & " -p " & strPass & " \\" & strComputer & " """ & strSecondHTAPath & """"
		End If
		' MsgBox strCommand
		' Exit Code 1326 is invalid password from PSExec 1.85
		strExitCode = objShell.Run(strCommand, 0, True)
		If strExitCode = 1326 Then
			MsgBox "Username or Password invalid. Please verify your credentials."
			txt_password.Value = ""
			txt_password.Focus
		Else
			window.close
		End If
	End If
End Sub
 
</script>
</head>
<body style="background-color:#B0C4DE" onkeypress='vbs:Default_Buttons'>
	<table width='90%' height='100%' align='center' border='0'>
		<tr>
			<td align="center" style="font-family: arial; font-size: 24px; font-weight: bold;">
				Run Program With Alternate Credentials
			</td>
		</tr>
		<tr>
			<td align='center' style="font-family: arial; font-size: 16px; font-weight: bold;">
				Enter username: <input type="text" maxlength="30" size="40" id="txt_username" name="txt_username" style="font-size: 14px;"><BR><BR>
				Enter password: <input type="password" maxlength="30" size="40" id="txt_password" name="txt_password" style="font-size: 14px;"><BR>
				<br>Note: Username must be DOMAIN\UserName
			</td>
		</tr>
		<tr>
			<td align='center'>
				<input type="button" value="Run HTA" name="btn_submit"  onClick="vbs:Run_Second_HTA" style="font-size: 16px;"><br><br>
			</td>
		</tr>
	</table>
</body>
</html>

Open in new window

0
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 24247832
And with this second HTA running under those alternate credentials, the MMC should be able to run.

Regards,

Rob.
<html>
 
<head>
    <title>Easy Access Toolbar</title>
	<HTA:APPLICATION 
     APPLICATIONNAME="Easy Access Toolbar"
     SCROLL="no"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
     Icon="./Images/icon.ico"
     Maximizebutton="no"
     ContextMenu="no"
>
</head>
 
<Script Language="VBScript">
    Sub Window_Onload
	  intWidth = 500
      intHeight = 100
      Me.ResizeTo intWidth, intHeight
      Me.MoveTo ((Screen.Width) - (intWidth)),((Screen.Height / 11) - (intHeight))
        DellButton.Width = 64
        DellButton.Height = 64
        DellButton.Picture = LoadPicture("c:\dell.bmp")
    End Sub
   
    Sub Run_MMC
    	Set objFSO = CreateObject("Scripting.FileSystemObject")
    	Set objShell = CreateObject("WScript.Shell")
    	strCommand = "mmc c:\windows\system32\compmgmt.msc"
    	objShell.Run strCommand, 1, False
    End Sub
 
</Script>
 
<body topmargin="0" rightmargin="0" leftmargin="0">
 
<table width="100%" border="1" width="100%" bordercolorlight="buttonface" 
bordercolordark="buttonface" style="border-collapse:collapse">
   <tr>
        <td width="100%" bgcolor="buttonface">
            <object classid="clsid:D7053240-CE69-11CD-A777-00DD01143C57" id="DellButton"></object>
       </td>
       <td width="100%" bgcolor="buttonface" align="center">
            <input type="button" value="Run MMC" name="btn_runmmc"  onClick="vbs:Run_MMC" style="font-size: 16px;">
       </td>
 
    </tr>
<table>
 
<p>&nbsp;<p>
<blockquote>
 
<span id=DataArea></span>
 
</blockquote>
</body>
</html>

Open in new window

0
 
LVL 14

Author Closing Comment

by:Dhiraj Mutha
ID: 31572114
Excellent......... this worked super fine..... you a a super star...
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 24255920
Great. Thanks for the grade.

Rob.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Suggested Courses
Course of the Month16 days, 6 hours left to enroll

850 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