Angelo55 Posted November 18, 2008 Share Posted November 18, 2008 Hi all, as I have the intention to continously use my old VBS script file running on many PCs in my company, I have the issue on autoIt to load and execute any VBS script istruction made up of an istance of WScript. For example, if you create a au3 file like this : $vbs = ObjCreate("ScriptControl") $vbs.language = "vbscript" $vbs.timeout = -1 ; $code="WScript.Sleep 5000" $vbs.addCode($code) $vbs.executeStatement ($code) ; It does not work !! It is not simply for a Sleep, ANY WScript.something sems not be working on my AutoIt3. As I have ta huge amount of VBS script to load in , I kindly request your precious help.. Anybody ready there ? Bye.. Angelo55 ====================================================================================== Link to comment Share on other sites More sharing options...
Airwolf Posted November 18, 2008 Share Posted November 18, 2008 This article explains the problem - http://support.microsoft.com/kb/279164Why not convert all of the VBS to AutoIt? Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt Link to comment Share on other sites More sharing options...
Angelo55 Posted November 18, 2008 Author Share Posted November 18, 2008 This article explains the problem - http://support.microsoft.com/kb/279164Why not convert all of the VBS to AutoIt?Hi Airwolf,thanks a lot !By the way, if you run an autoit file with others VBS command, you will see in the task manager both process : AutoIt AND WSCRIPT.exeIt seems that you could instanciate a wscript some how ...Furthermore, as I have istantiated a 'scriptcontrol' object trying then use the sleep, do you know any workaround to execute a sleep or others similar WSCRIPT dependent command, in a autoit3 file ?Consider I have plenty of VBs to manage and I would not like to rewrite every thing ... ok ??Bye !Angelo55 =================================================================================== Link to comment Share on other sites More sharing options...
Airwolf Posted November 18, 2008 Share Posted November 18, 2008 Hi Airwolf, thanks a lot ! By the way, if you run an autoit file with others VBS command, you will see in the task manager both process : AutoIt AND WSCRIPT.exe It seems that you could instanciate a wscript some how ... Furthermore, as I have istantiated a 'scriptcontrol' object trying then use the sleep, do you know any workaround to execute a sleep or others similar WSCRIPT dependent command, in a autoit3 file ? Consider I have plenty of VBs to manage and I would not like to rewrite every thing ... ok ?? Bye ! Angelo55 =================================================================================== The Microsoft article explains that you cannot use the following properties or methods outside of an actual script run with WScript: The following properties and methods are dependent on WSH to be running and will cause an error if they are accessed outside of the context of WSH: Properties ApplicationArgumentsFullNameNamePathScriptFullNameScriptNameVersionMethods Echo (for Visual Basic applications, use the MsgBox function or Debug.Print)Sleep (for Visual Basic applications, use the Sleep() Win32 API or SetWaitbleTimer() Win32 API [see "References"]).Popup (for Visual Basic applications, use the MsgBox function) You can replace the entire program you posted in your original post with 1 line in AutoIt: Sleep(5000) This is why I would recommend converting the VBS to AutoIt. Even if you've got quite a few scripts, it is a fairly quick process to convert them to AutoIt. You'll also alleviate the many problems I'm sure you'll run into trying to execute the VBS in AutoIt. Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 18, 2008 Share Posted November 18, 2008 (edited) Hi Airwolf, thanks a lot ! By the way, if you run an autoit file with others VBS command, you will see in the task manager both process : AutoIt AND WSCRIPT.exe It seems that you could instanciate a wscript some how ... Furthermore, as I have istantiated a 'scriptcontrol' object trying then use the sleep, do you know any workaround to execute a sleep or others similar WSCRIPT dependent command, in a autoit3 file ? Consider I have plenty of VBs to manage and I would not like to rewrite every thing ... ok ?? I think the link Airwolf already gave you indicates you are out of luck on certain properties and methods: The following properties and methods are dependent on WSH to be running and will cause an error if they are accessed outside of the context of WSH: Properties Application Arguments FullName Name Path ScriptFullName ScriptName Version Methods Echo (for Visual Basic applications, use the MsgBox function or Debug.Print) Sleep (for Visual Basic applications, use the Sleep() Win32 API or SetWaitbleTimer() Win32 API [see "References"]). Popup (for Visual Basic applications, use the MsgBox function) These are all easily replaced with other AutoIt functions, but you'll have to do the work. Edit: Oops, Airwolf was already on it... Edited November 18, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Angelo55 Posted November 19, 2008 Author Share Posted November 19, 2008 I think the link Airwolf already gave you indicates you are out of luck on certain properties and methods: These are all easily replaced with other AutoIt functions, but you'll have to do the work. Edit: Oops, Airwolf was already on it...Hi all ,thanks for quick reply .. Yes, I understand that no workaround is available.I guess I will have to parse all the source VBS code when loaded in au3 and change all the WS.SCRIPT commandswith the similar basic function available out of the WSCRIPT object.Thanks a lot and keep in touch !Ciao !Angelo55 Link to comment Share on other sites More sharing options...
RDSchaefer Posted November 21, 2008 Share Posted November 21, 2008 Angelo, You can use the attached script to do most of the work for you.VBS2AU3.zip Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now