dunk6 Posted October 7, 2009 Share Posted October 7, 2009 I have this code running using VBsEdit TargetFolder = "C:\temp" Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(TargetFolder) Set colItems = objFolder.Items For i = 0 to colItems.Count - 1 colItems.Item(i).InvokeVerbEx("Open") Next When i try to run it using AutoIt, i do this: Option Explicit Dim oShell Dim oAutoIt Set oShell = WScript.CreateObject("WScript.Shell") Set oAutoIt = WScript.CreateObject("AutoItX3.Control") Dim TargetFolder set TargetFolder = "C:\Archive" ;//ERROR HERE Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(TargetFolder) Set colItems = objFolder.Items For i = 0 to colItems.Count - 1 colItems.Item(i).InvokeVerbEx("Open") Next WScript.Quit I receive error at TargetFolder = "C:\Archive" Can anybody tell me what i did wrong? thank you Link to comment Share on other sites More sharing options...
Inverted Posted October 7, 2009 Share Posted October 7, 2009 (edited) There is no "set" command in AutoIt, you assign values to variables like this : $ex1 = 45 So put a dollar sign in front of all variables. Edited October 7, 2009 by Inverted Link to comment Share on other sites More sharing options...
FuryCell Posted October 7, 2009 Share Posted October 7, 2009 (edited) Are you trying to run as an AutoIt script, or are you trying to use the com object? If your trying to run it as an AutoIt Script use this. $TargetFolder = "C:\temp" $objShell = ObjCreate("Shell.Application") $objFolder = $objShell.Namespace($TargetFolder) $colItems = $objFolder.Items For $i = 0 to $colItems.Count - 1 $colItems.Item($i).InvokeVerbEx("Open") Next Edited October 7, 2009 by P5ych0Gigabyte HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
FuryCell Posted October 7, 2009 Share Posted October 7, 2009 (edited) It can also be done without COM using AutoIt functions like this:#Include<File.au3> $TargetFolder = "C:\temp" $Files=_FileListToArray($TargetFolder) For $i = 1 to $Files[0] ShellExecute($TargetFolder&"\"&$Files[$i],default,default,"Open") NextEdit: Also your VBS code appears to be flawed. It does not appear to have anything to do with AutoIt. This works fine.TargetFolder = "C:\Archive" Set oAutoIt = WScript.CreateObject("AutoItX3.Control") Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(TargetFolder) Set colItems = objFolder.Items For i = 0 to colItems.Count - 1 colItems.Item(i).InvokeVerbEx("Open") Next Edited October 7, 2009 by P5ych0Gigabyte HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
jvanegmond Posted October 7, 2009 Share Posted October 7, 2009 (edited) Agh, it's an AutoItX error. (Edit: Not really, but.. It's not a VBScript to AutoIt conversion error). That was confusing. Edited October 7, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
dunk6 Posted October 7, 2009 Author Share Posted October 7, 2009 Sorry for the confusion, when i go tru again, this code is called AutoItX. Link to comment Share on other sites More sharing options...
dunk6 Posted October 7, 2009 Author Share Posted October 7, 2009 the error fix, but new problem arised. Sorry really nd ur guyz help again.What i want the program do:1) read source, destination, folder path and password from textfile2) function execute() -> select from context menu and do some execution and new file *.pac will created.3) function moveToDest() ->once execution finish, move all *.pac files to destination folder.ERROR here: after finish no.2, the operation stop and cause this errorremote server has been paused or is in the process of been startup.runtime error: permission is denied.What does it mean. How to fix this?expandcollapse popup... Call Execute() oAutoIt.Sleep(1000) Call moveToDest() //ERROR HERE, AFTER FINISH CALL Encrypt(), IT SEEMS IT CANNOT INVOKE THIS FUNCTION 'Encrypt the content in the source folder Sub Execute() Dim objShell: Set objShell = CreateObject("Shell.Application") Dim objFolder : Set objFolder = objShell.Namespace(source) Dim colItems: Set colItems = objFolder.Items Dim i For i = 0 to colItems.Count - 1 colItems.Item(i).InvokeVerbEx("Encrypt") oAutoIt.Sleep(500) oAutoIt.Send("!w") oAutoIt.Send("{TAB}") oAutoIt.Send(pass) oAutoIt.Send("{TAB}") oAutoIt.Send(pass) oAutoIt.Send("{ENTER}") 'oAutoIt.Sleep(500) Next End Sub 'Once the file being executed, move the file to destination folder 'move the .pac into dest folder Sub moveToDest() dim newfolder Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject") If Not filesys.FolderExists(dir) Then newfolder = objFSO.CreateFolder (dir) WScript.Echo "A new folder '" & newfolder & "' has been created" End If objFSO.MoveFile source & "*.pac" , dest End Sub WScript.Quit Link to comment Share on other sites More sharing options...
jvanegmond Posted October 7, 2009 Share Posted October 7, 2009 By the way, I have never used VBS in my life but a quick Google said that the Set command is used for assigning a object to a variable (possibly creating an instance of the class). A string is not an object..Dim TargetFolderTargetFolder = "C:\Archive" ;//Fix3d github.com/jvanegmond 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