Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Odd VBS Behaviour Executing Batch On a Single Machine

14 views
Skip to first unread message

ssauser

unread,
May 7, 2012, 10:17:51 AM5/7/12
to
hi -

I'm hoping someone's run into this problem before and can advise.

I have a script I use to execute a batch file depending on a certain
condition. The script works fine on most of my machines, but for some odd
reason on my laptop instead of executing the batch file it opens the
batch file up in TextPad.

To ensure it isn't something else in the script causing this, I've
reduced the script to the following lines:

'Create shell object to run batch file:
Set oWSH = CreateObject("WScript.Shell")

oWSH.run "myBatch.bat"

set oWSH = nothing

and, even so, the batch file is executed on all machines except my laptop
where it opens myBatch.bat in Textpad.

The laptop in question is running Windows 7 Enterprise Editions. The
other machines are either Win 7 home edition or Win Vista. Is it possible
there's some security setting I don't know about that may be causing
this?

Thanks,

Lou
[for direct email transpose optonline and big57arf]

ralph

unread,
May 7, 2012, 11:28:55 AM5/7/12
to
On Mon, 07 May 2012 09:17:51 -0500, ssauser <opto...@big57arf.net>
wrote:
Need to repair the file associations.

Run regedit.exe

1) Go to:
HKLM\SOFTWARE\Classes\batfile\shell\open\command
Check that the default Reg_Sz value is "%1" %*
If not change it.

2) Then go to:
HKLM\SOFTWARE\Classes\batfile\shell\edit\command
Check the default value Reg_Expand_Sz is ...
"%SystemRoot%\System32\NOTEPAD.EXE %1"
(no quotes)

3) May also need to go to:
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts
Look for a ".bat" key and delete it.


-ralph

ssauser

unread,
May 7, 2012, 11:52:17 AM5/7/12
to
Hi Ralph -

I can't thank you enough. It was the third item on the list - at some
time I must have used "open with" on a batch file to open it with TextPad
and forgot to uncheck the "always use the selected programme" box.

Cleared that item and my script works on all my machines.

thanks again,

Lou

Tom Lavedas

unread,
May 7, 2012, 4:03:49 PM5/7/12
to
On May 7, 11:52 am, ssauser <optonl...@big57arf.net> wrote:
> On Mon, 07 May 2012 10:28:55 -0500, ralph wrote:
> > On Mon, 07 May 2012 09:17:51 -0500, ssauser <optonl...@big57arf.net>
> Lou- Hide quoted text -
>
> - Show quoted text -

Another approach not mentioned above is to explicitly name the command
processor, like this ...

oWSH.run "%comspec% /c myBatch.bat"

Then your script avoids the file association dependence and will work
properly regardless of how someone has changed them on other machines.
___________________________
Tom Lavedas
0 new messages