Difference between revisions of "Active Directory/Documentation/GUI for psexec"
Jump to navigation
Jump to search

m (New page: <center>Image:PSEXEC.png</center> <pre> <html> <head> <title>FE2PSExec</title> <HTA:APPLICATION ID="objTest" APPLICATIONNAME="FE2PSEXEC" SCROLL="no" SINGLEINSTAN...) |
m |
||
| Line 1: | Line 1: | ||
<center>[[Image:PSEXEC.png]]</center> | <center>[[Image:PSEXEC.png]]</center> | ||
| + | |||
| + | Save the code below as "psexec.hta". Update the strCommand variable (around line 190) to reflect the location of PSEXEC. | ||
<pre> | <pre> | ||
Latest revision as of 14:39, 31 March 2008

Save the code below as "psexec.hta". Update the strCommand variable (around line 190) to reflect the location of PSEXEC.
<html>
<head>
<title>FE2PSExec</title>
<HTA:APPLICATION
ID="objTest"
APPLICATIONNAME="FE2PSEXEC"
SCROLL="no"
SINGLEINSTANCE="yes"
>
<OBJECT ID="WindowsShell"
CLASSID="clsid:13709620-C279-11CE-A49E-444553540000">
</OBJECT></head>
<body STYLE="font:14 pt arial; color:white;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0, StartColorStr='#000000', EndColorStr='#3399ff')">
<style type="text/css">
.myclass {color:charcoal; font-family:arial; font-size:70%}
.myheader {color:charcoal; font-family:arial;font-weight:bold; font-size:100%}
</style>
<SCRIPT LANGUAGE="VBScript">
dim strRunThis, WshShell
Sub ChangeDiv
If prioritychooser.value <> "0" then
strPriority = " -" & priorityChooser.value
End if
If cbxUserCredentials.Checked = true and txtUser.value <> "" Then
cbxLoadProfile.disabled = false
cbxUserPassword.disabled = false
ElseIf cbxUserCredentials.Checked = false then
cbxLoadProfile.disabled = true
cbxUserPassword.disabled = true
End If
If cbxCopyFile.checked = true then
cbxForceCopy.disabled = false
Else
cbxForceCopy.disabled = true
End if
If cbxUserPassword.Checked = true and txtPassword.value = "" Then
txtPassword.disabled = false
txtPassword.focus
ElseIf cbxUserPassword.Checked = true then
txtPassword.disabled = true
End If
If cbxloadProfile.Checked Then
strSwitches = strSwitches & "-e "
Else
strSwitches = replace(strSwitches,"-i ","")
End If
If cbxInteractive.Checked Then
strSwitches = strSwitches & "-i "
Else
strSwitches = replace(strSwitches,"-i ","")
End If
If cbxCopyFile.Checked Then
strSwitches = strSwitches & "-c "
Else
strSwitches = replace(strSwitches,"-c ","")
End If
If cbxDontWait.Checked Then
strSwitches = strSwitches & "-d "
Else
strSwitches = replace(strSwitches,"-d ","")
End If
If cbxForceCopy.Checked Then
strSwitches = strSwitches & "-f "
Else
strSwitches = replace(strSwitches,"-f ","")
End If
If cbxVerCheck.Checked Then
strSwitches = strSwitches & "-v "
Else
strSwitches = replace(strSwitches,"-v ","")
End If
If cbxUserCredentials.Checked Then
strSwitches = strSwitches & "-u " & txtUser.value
Else
strSwitches = replace(strSwitches,"-u " & txtUser.value,"")
End If
If cbxUserPassword.Checked and txtPassword.value <> "" Then
strSwitches = strSwitches & " -p " & txtPassword.value
Else
strSwitches = replace(strSwitches,"-p " & txtPassword.value,"")
End If
strRunThis = strCommand & " " & strSwitches & strPriority & " \\" & replace(txtComputer.value,"\\","") & " " & txtCommand.value & " " & txtVariables.value
previewdiv.innerhtml = replace(strRunThis,txtPassword.value,"*******")
End Sub
Sub enablepw
with cbxUserPassword
.disabled = false
.checked = true
end with
End Sub
Sub Checkvars
If cbxUserPassword.Checked and txtPassword.value = "" Then
Msgbox "Alternate credentials password checkbox is checked, but no password was specified",48,"Specify password"
End If
End Sub
Sub RunProcess
msgbox strRunThis
Set objScriptExec = WshShell.Exec(strRunThis)
strisadminresult = replace(objScriptExec.StdOut.ReadAll,vbnewline,"<br>")
previewdiv.innerhtml = strisadminresult
'set WshShell = CreateObject("WScript.Shell")
'WshShell.run strRunThis,1,true
End Sub
</SCRIPT>
<body>
<p style class='myheader'>
PSEXEC front-end HTA
</style>
<br>
<table class='myclass' width='100%'>
<tr>
<td>Domain\User:</td>
<td><input type="text" name="txtUser" size="30"><br></td>
<td>Password:</td>
<td><input type="password" disabled="true" name="txtPassword" size="30" onclick="enablepw" onChange="Changediv"><br></td>
</tr>
<tr>
<td>Computer:</td>
<td><input type="text" name="txtComputer" size="30" onChange="ChangeDiv"><br></td></tr>
<td>Command:</td><td><input type="text" name="txtCommand" size="30" onChange="ChangeDiv"><br></td>
<td>Command variables:</td><td><input type="text" name="txtVariables" size="30" onChange="ChangeDiv"><br></td>
</tr>
</table>
<br>
<table><tr><td>
<table class='myclass'>
<tr valign="top">
<td><br></td>
</tr>
<tr valign="top">
<td><input type="checkbox" name="cbxInteractive" onClick="ChangeDiv"> Interactive</td>
<td><input type="checkbox" name="cbxLoadProfile" disabled="true" onClick="ChangeDiv"> Load user profile</td>
</tr>
<tr valign="top">
<td><input type="checkbox" name="cbxCopyFile" onClick="ChangeDiv"> Copy file to remote host</td>
<td><input type="checkbox" name="cbxForceCopy" disabled="true" onClick="ChangeDiv"> Force file copy</td>
</tr>
<tr valign="top">
<td><input type="checkbox" name="cbxDontWait" onClick="ChangeDiv"> Don't wait for process to complete</td>
<td><input type="checkbox" name="cbxVerCheck" onClick="ChangeDiv"> Copy only if version is newer</td>
</tr>
<tr valign="top">
<td><input type="checkbox" name="cbxUserCredentials" onClick="ChangeDiv"> Alternate user credentials</td>
<td><input type="checkbox" name="cbxUserPassword" disabled="true" onClick="ChangeDiv"> Alternate user password</td>
</tr>
<tr><td><br></td>
</tr>
<tr>
<td>
Priority
<select size="1" name="PriorityChooser" onChange="ChangeDiv">
<option value="0"></option>
<option value="low">Low</option>
<option value="belownormal">Below Normal</option>
<option value="abovenormal">Above Normal</option>
<option value="high">High</option>
<option value="realtime">Realtime</option>
</select></td>
</tr>
</table>
</td>
<td>
<table class='myclass'>
<tr>
<td>
Command Preview/Output:
<div id='previewdiv' align='left'align='left' style='background-color: black; color: white;width:400px;height: 220px;overflow:scroll';</div>
</td>
</tr>
</table>
</td></tr></table>
<br>
<input type="button" value="Run Command" name="run_button" onMouseOver="checkvars" onClick="runprocess"><p>
<SCRIPT LANGUAGE="VBScript">
strCommand = "\\server\path\psexec\psexec.exe"
strRunThis = strCommand
previewdiv.innerhtml = strCommand
Set WshShell = CreateObject("WScript.Shell")
strSourceDomain = WshShell.ExpandEnvironmentStrings("%userdomain%")
strSourceUser = WshShell.ExpandEnvironmentStrings("%username%")
txtUser.value = strSourceDomain & "\" & strSourceUser
</SCRIPT>
</body>