Author Posts

January 1, 2012 at 12:00 am

by kdn242 at 2013-03-29 08:42:19

$html = @"

Type some text (if you like):

Please specify a file, or a set of files:





"@

$ie = new-object -com "InternetExplorer.Application"
$ie.navigate2("about:blank")
$ie.AddressBar = $false
$ie.MenuBar = $false
$ie.StatusBar = $false

$ie.document.body.innerHTML = $html
$ie.Visible = $true
$doc = $ie.document

while ($doc.getElementByID("finished").value -ne 1) {
start-sleep -m 500
}

$ie.Visible = $false
$f= $doc.getElementByID("datafile").value
$p= $doc.getElementByID("textline").value

get-content "$f" | Foreach-Object {
$k= "$_" -replace '^Development', 'C:\ClearCase\kdnguyen_view\Development_Vob\Development'
copy-item $k $p >> $x
echo $x
}

$ie.quit()

###################################################################

I found out a way to using the HTLM code for the GUI and input, then use Powershell to generate and the output.

The problem is I want to use the browse button feature, but my way of handling the input is using the directory path to specify the file for the get-content (build_file.txt)

What do I need to change to make it work?

Please advices,

kdn

by DonJ at 2013-03-29 11:18:17

Please consider using the CODE button to format code listings. Makes them a lot easier to read.

The button you are using is intended to work with a back-end server application. It isn't intended to be used entirely client-side as you are doing. Consider reading http://www.cs.tut.fi/~jkorpela/forms/file.html, which describes the element in more detail. According to http://www.w3schools.com/jsref/dom_obj_fileupload.asp, you should be able to access the Value attribute of the element client-side to get the filename/path.

by kdn242 at 2013-04-01 08:21:12

Hi Jon,

Thanks for relying on my topic!!!

Do you know a way how to using html with a browse button and grab a file then use that file as a input for powershell to perform a job ?

kdn242