Cyri Posted May 6, 2011 Share Posted May 6, 2011 I have a COM object that works great in VBScript because two of the parameters on the method call require the vbDate format. So all the VBScript date functions work great. You can see where I'm going with this. AutoIT date functions are based on the string datatype which won't work with the COM method. Am I out of luck in using this COM object with AutoIT? Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 6, 2011 Share Posted May 6, 2011 (edited) Are you defining the to specify the vbDate format, or trying to create the actual value? Post a short demo script to illustrate what you are trying to do. Edited May 6, 2011 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...
Bowmore Posted May 6, 2011 Share Posted May 6, 2011 This function returns a date in vbDate format which is basically the number of days since 1900/01/01 00:00:00 as a variant data type. There is probably a WinAPI function that does this somewhere. #include <date.au3> $Date = vbDate() MsgBox(262144,"",'$Date' & @lf & @lf & 'Return:' & @lf & $Date) ;### Debug MSGBOX Func vbDate() Local $vbDate $vbDate = _DateDiff("D","1900/01/01",_NowCalc()) + ((_DateDiff("s",_NowCalcDate() & " 00:00:00",_NowCalc())+(@MSEC/1000)) / (24*60*60)) Return $vbDate EndFunc "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Cyri Posted May 7, 2011 Author Share Posted May 7, 2011 This function returns a date in vbDate format which is basically the number of days since 1900/01/01 00:00:00 as a variant data type. There is probably a WinAPI function that does this somewhere. #include <date.au3> $Date = vbDate() MsgBox(262144,"",'$Date' & @lf & @lf & 'Return:' & @lf & $Date) ;### Debug MSGBOX Func vbDate() Local $vbDate $vbDate = _DateDiff("D","1900/01/01",_NowCalc()) + ((_DateDiff("s",_NowCalcDate() & " 00:00:00",_NowCalc())+(@MSEC/1000)) / (24*60*60)) Return $vbDate EndFunc I'm actually trying to assign the start and end date/time values. I'm assigning the values in the following format: 5/6/2011 4:00:00 PM Currently this is how I'm assigning the values. #include <date.au3> $Start = _Now() $Expire = _DateTimeFormat(_DateAdd("M", 15, _NowCalc()), 0) I'm pretty sure it's an issue with the date values because I have another method in the COM object that works fine via AutoIT. The only difference is that this method uses date values. I also went back to the working VBScript and changed the date values into strings which caused the same COM error that AutoIT showed. Error 80020009, The parameter is incorrect. Which lead me down the datatype issue. Link to comment Share on other sites More sharing options...
Juvigy Posted May 9, 2011 Share Posted May 9, 2011 Put a msgbox in the vbscript and print the date and we will see what is the format of the parameter. Also keep in mind that your date formats may and will be dependant on your computer regional settings. Link to comment Share on other sites More sharing options...
DaleHohm Posted May 9, 2011 Share Posted May 9, 2011 Haven't tested, but I expect the method descripbed here will work for you and will give you an AutoIt variable that can be used in your COM function call. "Nothing (VB/VBScript constant) in AutoIt " Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
Cyri Posted May 9, 2011 Author Share Posted May 9, 2011 Haven't tested, but I expect the method descripbed here will work for you and will give you an AutoIt variable that can be used in your COM function call. "Nothing (VB/VBScript constant) in AutoIt " Dale I already validated that the VBScript date/time format is exactly the same as my AutoIT (date) string counterpart using msgbox. The only difference is the datatype. I had also found that link about the VBScript Nothing constant and tried something similar with no luck. Here is the code I used to try and get the date/time using ScriptControl. Local $oVBS = ObjCreate("ScriptControl") $oVBS.language = "VBScript" Global Const $VBNow = $oVBS.eval("Now") $oVBS = 0 Then using $VBNow in both the start and expire parameters but it still tells me incorrect parameter. I also tried using "Now+30" for the expire just in case it didn't like being the same date/time for both start and expire but it didn't help. I doubt anyone has experience with this COM but it's actually the tsmediaapi.dll from the SCCM 2007 SDK and the method I'm calling is CreateBootMedia(). Here is an excerpt from the SDK help documentation on the two date params CertValidStart and CertValidEnd. CertValidStart Data type: VARIANT Qualifiers: [in] Pointer to the time when a newly created certificate starts being valid. CertValidEnd Data type: VARIANT Qualifiers: [in] Pointer to the time when the newly created certificate stops being valid. Link to comment Share on other sites More sharing options...
Juvigy Posted May 9, 2011 Share Posted May 9, 2011 Can you show us the VBS ? The script control example works for me - i get "20110509181728" for example. Link to comment Share on other sites More sharing options...
trancexx Posted May 9, 2011 Share Posted May 9, 2011 (edited) @Cyri, you misunderstood parameters. Pass pointer to variant with the time. Edited May 9, 2011 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Cyri Posted May 9, 2011 Author Share Posted May 9, 2011 Can you show us the VBS ? The script control example works for me - i get "20110509181728" for example. Happy to include the working VBScript though you'll need an SCCM 2007 infrastructure for the code to work. This Sub is straight out of the SDK help documentation. The example they give uses "Now" and "Now+30" for the start and expire. expandcollapse popupCreateBootMedia "SCCMSiteServerName", "SCCMSiteCode", "SCCMDistributionPoint", "", "SCCM", "CD", "C:\test.iso", "SCCMBootImagePackageID", "p@ssword" Sub CreateBootMedia (providerName, _ siteCode, _ distributionPoints, _ connectionOptions, _ mediaLabel, _ mediaType, _ destinationPath, _ bootImageID, _ mediaPassword) Dim tsmedia Dim hr Set tsmedia = CreateObject("Microsoft.ConfigMgr.TsMedia") ' Change these properties according to your configuration. tsmedia.ProviderName = providerName tsmedia.SiteCode = siteCode tsmedia.DistributionPoints = distributionPoints tsmedia.ConnectionOptions = connectionOptions tsmedia.MediaLabel = mediaLabel hr = tsmedia.CreateBootMedia( mediaType, _ destinationPath, _ bootImageID, _ mediaPassword, _ Null, _ Null, _ Now, _ Now+30, _ true) While tsmedia.Status = 0 WScript.Echo tsmedia.CurrentStep & "/" & tsmedia.NumSteps & _ " (" & tsmedia.StepProgress & ") " & tsmedia.StepInfo WScript.Sleep 1000 Wend WScript.Echo "Boot media creation finished with result = " & tsmedia.ExitCode End Sub Originally I thought it was the Null values that were throwing the exception and perhaps they still are. I've tried "", Chr(0), 0, Default, and the ScriptControl method above for the VBScript "Null" but I still receieved the same exception so I started looking at the date values instead. Link to comment Share on other sites More sharing options...
Cyri Posted May 9, 2011 Author Share Posted May 9, 2011 @Cyri, you misunderstood parameters. Pass pointer to variant with the time.I've tried different combinations using Ptr() to convert the date/time expression into a pointer variant with no success. Odd thing is that even the mediaPassword (see VBS example) parameter is listed as a pointer variant in the SDK help, but a string value works fine there. Link to comment Share on other sites More sharing options...
trancexx Posted May 9, 2011 Share Posted May 9, 2011 I've tried different combinations using Ptr() to convert the date/time expression into a pointer variant with no success. Odd thing is that even the mediaPassword (see VBS example) parameter is listed as a pointer variant in the SDK help, but a string value works fine there.That's because you don't know what VBS engine does with your parameters internally. Besides, saying VARIANT pretty much covers everything. You'll learn. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JohnOne Posted May 9, 2011 Share Posted May 9, 2011 I've tried different combinations using Ptr() to convert the date/time expression into a pointer variant with no success. Odd thing is that even the mediaPassword (see VBS example) parameter is listed as a pointer variant in the SDK help, but a string value works fine there.I may be wrong, but as far as I can tell Ptr() function might return the expression as a pointer vairiant but it does noy actually return a pointer to the value of the expression (if that makes sense)You may have to create a DllStruct, add the data, get a pointer to it. AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Juvigy Posted May 10, 2011 Share Posted May 10, 2011 I cant test to see if it works but you need to do something like this: $time = DllStructCreate( "dword;dword" ) DllStructSetData($time, 1 ,DllStructGetSize($time)) $timepointer = DllStructGetPtr($time) And then pass the $timepointer as parameter to the 'CreateBootMedia'. Link to comment Share on other sites More sharing options...
trancexx Posted May 10, 2011 Share Posted May 10, 2011 It wouldn't work. Type is VARIANT*. Where is it there? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Juvigy Posted May 10, 2011 Share Posted May 10, 2011 Well . prev post didnt had full example. Here is one: $time = DllStructCreate("char var[128]") DllStructSetData($time,"var",_Now()) $timepointer = DllStructGetPtr($time) $major = DllStructGetData($time,1) ConsoleWrite($major&@CRLF) ConsoleWrite($timepointer&@CRLF) So i think passing $timepointer to the function should work. Link to comment Share on other sites More sharing options...
Cyri Posted May 10, 2011 Author Share Posted May 10, 2011 Well . prev post didnt had full example. Here is one: $time = DllStructCreate("char var[128]") DllStructSetData($time,"var",_Now()) $timepointer = DllStructGetPtr($time) $major = DllStructGetData($time,1) ConsoleWrite($major&@CRLF) ConsoleWrite($timepointer&@CRLF) So i think passing $timepointer to the function should work. I tried passing in $timepointer but now I'm getting 80020008, Bad variable type. When you guys start going into DllStruct's I get lost so I'm araid I can't be much help here. Link to comment Share on other sites More sharing options...
JohnOne Posted May 10, 2011 Share Posted May 10, 2011 Well I dont know what a VARIANT type is, but if it were me, My next attempt would be to use that Ptr() Function on the $timepointer variable. It might turn out to be a ridiculous suggestion but it cant hurt. AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Cyri Posted May 10, 2011 Author Share Posted May 10, 2011 Well I dont know what a VARIANT type is, but if it were me, My next attempt would be to use that Ptr() Function on the $timepointer variable.It might turn out to be a ridiculous suggestion but it cant hurt.I'm willing to try anything at this point, but sadly I get the same bad variable type message when using Ptr($timepointer). One thing I found interesting, now that I'm getting the bad variable type message I'm getting 4 seperate COM exceptions with that same message. Does that mean 4 of the parameters are bad type? Link to comment Share on other sites More sharing options...
ProgAndy Posted May 10, 2011 Share Posted May 10, 2011 This is how the date will be created with WinAPI, but I don't know if it will work. #include<Date.au3> Dim $aDate, $aTime _DateTimeSplit(_NowCalc(), $aDate, $aTime) $tSystemTime = _Date_Time_EncodeSystemTime($adate[2], $aDate[3], $aDate[1], $aTime[1], $aTime[2], $aTime[3]) $pSystemTime = DllStructGetPtr($tSystemTime) $aVarTime = DllCall("oleaut32.dll", "int", "SystemTimeToVariantTime", "ptr", $pSystemTime, "double*", 0) $nTimeAsDouble = $aVarTime[2] ... $tsmedia.CreateBootMedia( mediaType, _ destinationPath, _ bootImageID, _ mediaPassword, _ Null, _ Null, _ $nTimeAsDouble, _ ..., _ true) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes 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