Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Win NT errors and says ActiveX can't CreateObject("WScript.Shell")

Status
Not open for further replies.

oltran

Technical User
Dec 26, 2002
19
US
Hi, I am tring to automate some tasks using vbscript at my job. Below is a simple version of the code I have so far.

The example code below is using notepad as a test application; it is to run and receive data from vbscript's sendkeys. The data that the vbscript function is sending is received from the javascript function generate().

This worked just fine on my home computer with Windows 2000 but when I opened it up with my work computer running Win NT 4.0 it only ran the FIRST time and then every time after that it generated an error like ActiveX can't CreateObject("WScript.Shell"). Actually, when I simplified the program to post on this site it worked a few times and then errored in the same way after.

Please Help!! Thanks,
Jason

<!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>
<TITLE>
Form
</TITLE>
<META content=&quot;text/html; charset=windows-1252&quot;>
<META content=&quot;Microsoft FrontPage 4.0&quot; name=&quot;GENERATOR&quot;>
<META content=&quot;FrontPage.Editor.Document&quot; name=&quot;ProgId&quot;>

<SCRIPT language=&quot;javascript&quot; type=&quot;text/javascript&quot;>
<!--

function generate(){

//Form field variables
Client_field_var = &quot;&quot;
AcctMgr_field_var = &quot;&quot;


//Variable to hold all form field variables
Form_1_content = &quot;&quot;


//If a value is entered in the form field, assign it to its variable
if(document.Form_1.Client_field.value != &quot;&quot;){Client_field_var = document.Form_1.Client_field.value}
if(document.Form_1.AcctMgr_field.value != &quot;&quot;){AcctMgr_field_var = document.Form_1.AcctMgr_field.value}


//Compile the 'Form_1_content' variable based on the variables that were assigned a value
if(Client_field_var != &quot;&quot;){Form_1_content += Client_field_var + &quot;\n&quot;}
if(AcctMgr_field_var != &quot;&quot;){Form_1_content += AcctMgr_field_var + &quot;\n&quot;}


//variables that will begin and end in the output
Form_1_start = &quot;Begin Stuff\n&quot;
Form_1_end = &quot;End Stuff&quot;


//Dump value into text area
document.Form_1.output.value = Form_1_start + Form_1_content + Form_1_end


}


//-->
</SCRIPT>

<SCRIPT language=&quot;vbscript&quot;>
function PassToNotepad
Dim strPassedValue
Dim ss
Dim starttime,waittime,currenttime
strPassedValue = document.Form_1.output.value
waittime = 5
Set ss = CreateObject(&quot;WScript.Shell&quot;)
ss.run &quot;C:\WINNT\NOTEPAD.EXE&quot;,1
starttime = Timer()
currenttime = starttime
Do Until currenttime-starttime > waittime
'Do nothing
currenttime = Timer()
Loop
ss.SendKeys strPassedValue
Set ss = nothing
end function
</SCRIPT>

</HEAD>
<BODY>
<CENTER>
<FORM name=&quot;Form_1&quot;>
<B>Create Job Request</B>
<BR><BR>
Client name: <INPUT size=&quot;10&quot; name=&quot;Client_field&quot; value=&quot;Client Name&quot;><BR>
Account Manager: <SELECT name=&quot;AcctMgr_field&quot; size=&quot;1&quot;>
<OPTION value=&quot;1&quot; selected>1 - John Doe</OPTION>
<OPTION value=&quot;2&quot;>2 - Jane Jones</OPTION>
</SELECT>
<BR><BR>
<INPUT name=&quot;button&quot; type=&quot;button&quot; onclick=&quot;generate()&quot; value=&quot;Generate&quot;><BR>
Output: <TEXTAREA name=&quot;output&quot; rows=&quot;4&quot; cols=&quot;25&quot;>
</TEXTAREA><BR>
<INPUT type=&quot;button&quot; value=&quot;Send to Notepad&quot; id=&quot;button2&quot; name=&quot;button2&quot; onclick=&quot;PassToNotepad()&quot;>
</FORM>
</CENTER>
</BODY>
</HTML>
 
To my mind, it's IE security issue problem. Did you check your activeX permissions ?
Another hint : did you run it the same way all the time ? ie : When I run this kind of HTML page with a &quot;File://C:\..&quot; like url (or a double-click on the HTML file in Explorer), IE doesn't consider it as an intranet. It's &quot;local machine&quot; and no security settings are aviable for that. If I run it with a &quot;File://\\machineName\shareName\...&quot; like url, the page is viewed by IE as an Intranet and, as is, I can set the security permissions for it. Water is not bad as long as it stays out human body ;-)
 
Perfect! I didn't realize that when it was running, it was on my local machine and when I started running it with the errors it was saved on my folder on in intranet! All I had to do was enable ActiveX on my IE intranet security!!!

Thanks !!!!! :)
 
you're welcome !!! Water is not bad as long as it stays out human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top