Forum Discussion
19 Replies
Sort By
- OfervSuper ContributorHi Irina,
Thanks for clarify that but, if we'll take for example the following script:TargetFolder = "C:\Logs"
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("Print")
Next
and try and convert it to c#script it will fail.
this is what i did so far but it fail:
TargetFolder = ProjectSuite["Variables"]["TextFile"]
var objShell = Sys.OleObject("Shell.Application")
var objFolder = objShell.Namespace(TargetFolder)
var colItems = objFolder.Items
for (i = 0 ; i < colItems.Count - 1 ; i++)
colItems.Item(i).InvokeVerbEx("Print")
Next
would be happy if you can help me solve that one,the purpose is to print all files in a folder one by one
Thanks - irina_lukinaSuper Contributor
Hi Ofer,
I've corrected your code a little bit, and it works fine:
var TargetFolder = "C:\\Logs";
var objShell = new ActiveXObject("Shell.Application");
var objFolder = objShell["Namespace"](TargetFolder);
var colItems = objFolder["Items"]();
for (var i = 0; i < colItems["Count"]; i++)
colItems["Item"](i)["InvokeVerbEx"]("Print");FYI, the CreateObject object in VBScript corresponds to the new ActiveXObject statement in C#Script. Also, there is no need to specify Next at the end of the For statement. I hope this information helps :)
- OfervSuper ContributorThanks,You are great
Where can i read about all the objects purposes? like OleObject,ActiveXObject,etc i want to know how to convert this kind of code line by myself
Thanks - OfervSuper ContributorIrina,
How can i tell the system to use specific printer for printing the documents?the printer i want to use is the default one but somehow it doesn't use it for printing.
Thanks - irina_lukinaSuper Contributor
Hi Ofer,
Where can i read about all the objects purposes? like OleObject,ActiveXObject,etc
You can find descriptions for all of these objects in MSDN (http://msdn.microsoft.com/).i want to know how to convert this kind of code line by myself
I've found one useful article (it contains instructions on how to convert JScript code to VBScript code). I recommend that you read it and use some of the mentioned tips vice-versa.
Tips for Converting Samples to VBScriptHow can i tell the system to use specific printer for printing the documents? the printer i want to use is the default one but somehow it doesn't use it for printing.
Please clarify one thing: does the script fail to print the selected files, or does it print them using another printer (not the default one)? - OfervSuper ContributorHi Irina,
The document does printed but as you said it is using the wrong printer.
I'm using a script who install the printer and as it installed it becomes the default printer.once the script finish installing the printer it start printing list of document located in specific folder but,it start printing using the wrong printer.
Thanks - irina_lukinaSuper Contributor
Hi Ofer,
Are you sure that the installed printer is recognized as the default one when you try using it for printing? I recommend that you try using Sys.Refresh() before printing the documents. Does this help?
- OfervSuper ContributorHi Irina,
Yes it does.no need to refresh,once it appear after the installation it has the green V mark,says it's the default.
I'm trying to install that printer using command line and when type this command line in the command prompt window it does install the printer's driver but,when trying to run it in TC i'm getting an error message:
here is the code:
var cmdLine = rundll32.exe printui.dll,PrintUIEntry /ia /m "Printer Name" /v "Windows 7" /f "C:\\Users\\<USER>\\Downloads\\Drivers\\v3-x64\\xxx.inf"
var WshShell = Sys.OleObject("WScript.Shell")
WshShell.Run(cmdLine)
Still need to solve the printing to default issue but it can wait for later,this one is more important for me right now.
Thanks - OfervSuper ContributorHi Irina,
Well,i solved the command line issue.
and with regarding the sys.refresh,it looks like it's working as well.
Thanks for the help
Related Content
- 6 years agocmbdnne
- 8 years agom_essaid
- 5 years agodjvakarjoshi1
Recent Discussions
- 12 hours agosimonaferrara
- 21 hours agoSubhraDas