Prev: WMI
Next: Loop folder
From: PokerFanatic on 5 Sep 2010 21:23 I have a 500 line vbscript I wrote years ago that now won't work on Windows 7. The reason is you can't perform a File Open/Browse in vbscript in Windows 7, I(I've tried all the suggestions I've found on the net but none of them work.) I was looking at running a Powershell mini script to do the file open for me then return the selected file back to the vbs script. I've got the Powershell script and it works fine. One twist. I don't want to call another script. I want to send all the Powershell commands at once. The problem I'm seeing is Powershell is reporting an error that is is missing a ")". The only changes I"ve made to the Powershell commands is to replace the doubl quotes with two double quotes so they are passed through to the Powershell command. Here's what I've got: Set objWSShell = CreateObject("Wscript.Shell") psCommand = "powershell -noexit -command {[System.Reflection.Assembly]::LoadWithPartialName(""System.windows.forms"") | Out-Null ; $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog ; $OpenFileDialog.initialDirectory = $initialDirectory ; $OpenFileDialog.filter = ""All files (*.*)| *.*"" ; $OpenFileDialog.ShowDialog() | Out-Null ; $OpenFileDialog.filename}" msgbox psCommand Path = objWSShell.Run(psCommand,,true) I put the -noexit command in there so I could see the error. Here's what Powershell reports: Missing ')' in method call. At line:1 char:52 + {[System.Reflection.Assembly]::LoadWithPartialName( <<<< System.windows.forms ) | Out-Null ; $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog ; $OpenFileDialog.initialDirectory = $initialDirectory ; $OpenFileDialog.filte r = All files (*.*)| *.* ; $OpenFileDialog.ShowDialog() | Out-Null ; $OpenFileD ialog.filename} + CategoryInfo : ParserError: (CloseParenToken:TokenId) [], Paren tContainsErrorRecordException + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall Anyone attempted this? Any ideas? Thanks.
From: Mayayana on 5 Sep 2010 21:42 See this download: http://www.jsware.net/jsware/scripts.php5#classpk Download the ZIP. Unpack it. In the "Choose FileFol" folder there are two methods to browse for a file. I'm pretty sure that both work in Vista/7. It looks like your PowerShell version will require at least the .Net Framework...not to mention PowerShell itself. But if you want to use it, try here for help: microsoft.public.windows.powershell ------------------------------------ |I have a 500 line vbscript I wrote years ago that now won't work on Windows | 7. The reason is you can't perform a File Open/Browse in vbscript in Windows | 7, I(I've tried all the suggestions I've found on the net but none of them | work.) I was looking at running a Powershell mini script to do the file open | for me then return the selected file back to the vbs script. I've got the | Powershell script and it works fine. | | One twist. I don't want to call another script. I want to send all the | Powershell commands at once. The problem I'm seeing is Powershell is | reporting an error that is is missing a ")". The only changes I"ve made to | the Powershell commands is to replace the doubl quotes with two double quotes | so they are passed through to the Powershell command. Here's what I've got: | | Set objWSShell = CreateObject("Wscript.Shell") | psCommand = "powershell -noexit -command | {[System.Reflection.Assembly]::LoadWithPartialName(""System.windows.forms"") || Out-Null ; $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog | ; $OpenFileDialog.initialDirectory = $initialDirectory ; | $OpenFileDialog.filter = ""All files (*.*)| *.*"" ; | $OpenFileDialog.ShowDialog() | Out-Null ; $OpenFileDialog.filename}" | msgbox psCommand | Path = objWSShell.Run(psCommand,,true) | | I put the -noexit command in there so I could see the error. | | Here's what Powershell reports: | Missing ')' in method call. | At line:1 char:52 | + {[System.Reflection.Assembly]::LoadWithPartialName( <<<< | System.windows.forms | ) | Out-Null ; $OpenFileDialog = New-Object | System.Windows.Forms.OpenFileDialog | ; $OpenFileDialog.initialDirectory = $initialDirectory ; | $OpenFileDialog.filte | r = All files (*.*)| *.* ; $OpenFileDialog.ShowDialog() | Out-Null ; | $OpenFileD | ialog.filename} | + CategoryInfo : ParserError: (CloseParenToken:TokenId) [], Paren | tContainsErrorRecordException | + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall | | Anyone attempted this? Any ideas? | | Thanks.
From: Kenneth A. Larsen on 6 Sep 2010 09:50 "Mayayana" <mayayana(a)invalid.nospam> wrote in message news:i61gqs$t31$1(a)news.eternal-september.org... > See this download: > > http://www.jsware.net/jsware/scripts.php5#classpk > > Download the ZIP. Unpack it. In the "Choose FileFol" folder > there are two methods to browse for a file. I'm pretty sure > that both work in Vista/7. > > It looks like your PowerShell version will require at least > the .Net Framework...not to mention PowerShell itself. But > if you want to use it, try here for help: > > microsoft.public.windows.powershell > > ------------------------------------ > > |I have a 500 line vbscript I wrote years ago that now won't work on > Windows > | 7. The reason is you can't perform a File Open/Browse in vbscript in > Windows > | 7, I(I've tried all the suggestions I've found on the net but none of > them > | work.) I was looking at running a Powershell mini script to do the file > open > | for me then return the selected file back to the vbs script. I've got > the > | Powershell script and it works fine. > | > | One twist. I don't want to call another script. I want to send all the > | Powershell commands at once. The problem I'm seeing is Powershell is > | reporting an error that is is missing a ")". The only changes I"ve made > to > | the Powershell commands is to replace the doubl quotes with two double > quotes > | so they are passed through to the Powershell command. Here's what I've > got: > | > | Set objWSShell = CreateObject("Wscript.Shell") > | psCommand = "powershell -noexit -command > | > {[System.Reflection.Assembly]::LoadWithPartialName(""System.windows.forms"") > || Out-Null ; $OpenFileDialog = New-Object > System.Windows.Forms.OpenFileDialog > | ; $OpenFileDialog.initialDirectory = $initialDirectory ; > | $OpenFileDialog.filter = ""All files (*.*)| *.*"" ; > | $OpenFileDialog.ShowDialog() | Out-Null ; $OpenFileDialog.filename}" > | msgbox psCommand > | Path = objWSShell.Run(psCommand,,true) > | > | I put the -noexit command in there so I could see the error. > | > | Here's what Powershell reports: > | Missing ')' in method call. > | At line:1 char:52 > | + {[System.Reflection.Assembly]::LoadWithPartialName( <<<< > | System.windows.forms > | ) | Out-Null ; $OpenFileDialog = New-Object > | System.Windows.Forms.OpenFileDialog > | ; $OpenFileDialog.initialDirectory = $initialDirectory ; > | $OpenFileDialog.filte > | r = All files (*.*)| *.* ; $OpenFileDialog.ShowDialog() | Out-Null ; > | $OpenFileD > | ialog.filename} > | + CategoryInfo : ParserError: (CloseParenToken:TokenId) [], > Paren > | tContainsErrorRecordException > | + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall > | > | Anyone attempted this? Any ideas? > | > | Thanks. > >Oh you are absolutely right about the ZIP working with Windows Vista and 7.
From: Kenneth A. Larsen on 6 Sep 2010 09:55 "PokerFanatic" <PokerFanatic(a)discussions.microsoft.com> wrote in message news:C48CB2DC-C8F2-4CA9-A436-E853ECA57732(a)microsoft.com... >I have a 500 line vbscript I wrote years ago that now won't work on Windows > 7. The reason is you can't perform a File Open/Browse in vbscript in > Windows > 7, I(I've tried all the suggestions I've found on the net but none of them > work.) I was looking at running a Powershell mini script to do the file > open > for me then return the selected file back to the vbs script. I've got the > Powershell script and it works fine. > > One twist. I don't want to call another script. I want to send all the > Powershell commands at once. The problem I'm seeing is Powershell is > reporting an error that is is missing a ")". The only changes I"ve made to > the Powershell commands is to replace the doubl quotes with two double > quotes > so they are passed through to the Powershell command. Here's what I've > got: > > Set objWSShell = CreateObject("Wscript.Shell") > psCommand = "powershell -noexit -command > {[System.Reflection.Assembly]::LoadWithPartialName(""System.windows.forms"") > | Out-Null ; $OpenFileDialog = New-Object > System.Windows.Forms.OpenFileDialog > ; $OpenFileDialog.initialDirectory = $initialDirectory ; > $OpenFileDialog.filter = ""All files (*.*)| *.*"" ; > $OpenFileDialog.ShowDialog() | Out-Null ; $OpenFileDialog.filename}" > msgbox psCommand > Path = objWSShell.Run(psCommand,,true) > > I put the -noexit command in there so I could see the error. > > Here's what Powershell reports: > Missing ')' in method call. > At line:1 char:52 > + {[System.Reflection.Assembly]::LoadWithPartialName( <<<< > System.windows.forms > ) | Out-Null ; $OpenFileDialog = New-Object > System.Windows.Forms.OpenFileDialog > ; $OpenFileDialog.initialDirectory = $initialDirectory ; > $OpenFileDialog.filte > r = All files (*.*)| *.* ; $OpenFileDialog.ShowDialog() | Out-Null ; > $OpenFileD > ialog.filename} > + CategoryInfo : ParserError: (CloseParenToken:TokenId) [], > Paren > tContainsErrorRecordException > + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall > > Anyone attempted this? Any ideas? > > Thanks. No! Sorry kid.
From: Al Dunbar on 6 Sep 2010 13:30
"Mayayana" <mayayana(a)invalid.nospam> wrote in message news:i61gqs$t31$1(a)news.eternal-september.org... > See this download: > > http://www.jsware.net/jsware/scripts.php5#classpk > > Download the ZIP. Unpack it. In the "Choose FileFol" folder > there are two methods to browse for a file. I'm pretty sure > that both work in Vista/7. Hopefully. The OP said he tried everything he has found and concludes that "none of them work". A more accurate conclusion might have been "I have so far been unable to get any of them to work"... > It looks like your PowerShell version will require at least > the .Net Framework...not to mention PowerShell itself. He must already have satisfied those prerequisites, otherwise Powershell itself would not have been able to report the error. Resolving mixed-language syntax issues can be confusing, and generally requires a good grasp of both languages- and mine is weak for powershell... ;-) If the problem is resulting from the doubled-double quotes, the OP could try: redouble them: LoadWithPartialName(""""System.windows.forms"""") replace with single quotes: LoadWithPartialName('System.windows.forms') If that doesn't work, he could try removing the pipe to Out-Null. If that doesn't work he could embed the powershell command within double quotes and use the invoke "&" operator by changing this: {... the long ps command ...} to: ""& {... the long ps command ...}"" The doubled quotes are there for the .run command, as the powershell command is embedded in a quoted string in vbscript. And if that doesn't work with the various quoting suggestions I gave above, is there perhaps a command line length limitation in operation here? /Al > But > if you want to use it, try here for help: > > microsoft.public.windows.powershell > > ------------------------------------ > > |I have a 500 line vbscript I wrote years ago that now won't work on > Windows > | 7. The reason is you can't perform a File Open/Browse in vbscript in > Windows > | 7, I(I've tried all the suggestions I've found on the net but none of > them > | work.) I was looking at running a Powershell mini script to do the file > open > | for me then return the selected file back to the vbs script. I've got > the > | Powershell script and it works fine. > | > | One twist. I don't want to call another script. I want to send all the > | Powershell commands at once. The problem I'm seeing is Powershell is > | reporting an error that is is missing a ")". The only changes I"ve made > to > | the Powershell commands is to replace the doubl quotes with two double > quotes > | so they are passed through to the Powershell command. Here's what I've > got: > | > | Set objWSShell = CreateObject("Wscript.Shell") > | psCommand = "powershell -noexit -command > | > {[System.Reflection.Assembly]::LoadWithPartialName(""System.windows.forms"") > || Out-Null ; $OpenFileDialog = New-Object > System.Windows.Forms.OpenFileDialog > | ; $OpenFileDialog.initialDirectory = $initialDirectory ; > | $OpenFileDialog.filter = ""All files (*.*)| *.*"" ; > | $OpenFileDialog.ShowDialog() | Out-Null ; $OpenFileDialog.filename}" > | msgbox psCommand > | Path = objWSShell.Run(psCommand,,true) > | > | I put the -noexit command in there so I could see the error. > | > | Here's what Powershell reports: > | Missing ')' in method call. > | At line:1 char:52 > | + {[System.Reflection.Assembly]::LoadWithPartialName( <<<< > | System.windows.forms > | ) | Out-Null ; $OpenFileDialog = New-Object > | System.Windows.Forms.OpenFileDialog > | ; $OpenFileDialog.initialDirectory = $initialDirectory ; > | $OpenFileDialog.filte > | r = All files (*.*)| *.* ; $OpenFileDialog.ShowDialog() | Out-Null ; > | $OpenFileD > | ialog.filename} > | + CategoryInfo : ParserError: (CloseParenToken:TokenId) [], > Paren > | tContainsErrorRecordException > | + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall > | > | Anyone attempted this? Any ideas? > | > | Thanks. > > |