Unable to open .jar file in qtp - jar

i have written a .vbs file with below code.
Set WshShell=WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd.exe"
WScript.Sleep 10000
WshShell.SendKeys "cd\"
WshShell.SendKeys "{ENTER}"
strUser = CreateObject("WScript.Network").UserName
WshShell.SendKeys "cd c:\users\"
WshShell.SendKeys strUser
WshShell.SendKeys "\desktop"
WshShell.SendKeys "{ENTER}"
WshShell.SendKeys "Java -jar "
fileName=inputbox("Please enter the .jar file name(without .jar extension)")
WScript.Sleep 10000
WshShell.SendKeys fileName
WshShell.SendKeys ".jar"
WshShell.SendKeys "{ENTER}"
and im trying to run this file using systemutil.run function in qtp. It is running properly but at the end it is showing "Unable to create java virtual machine".
if i try to double click the .vbs file it will open my .jar file.
Please help me.

Personally, I haven't tried but it should work. try:
fileName=inputbox("Please enter the .jar file name(without .jar extension)")
SystemUtil.Run "cmd","/c java -jar " & fileName & ".jar",""
Just change the path.
Check this link for more information.

You're running into this issue because Java is trying to use more ram than you have available. Try running the jar while allocating less ram "Java -Xmx512M -jar "

Related

How to launch .exe file with run

I tried to launch a program with Run & Runwait but the program don't appear
Run & Runwait command
Run('R:\Windows\Bureau\Hoop Bot\lib\scrcpy-win64\scrcpy-noconsole.exe')
Or
Run('#Scriptdir\lib\scrcpy-win64\scrcpy-noconsole.exe')
same with runwait
No error messages
Try setting the working dir for the program.
Run('R:\Windows\Bureau\Hoop Bot\lib\scrcpy-win64\scrcpy-noconsole.exe', 'R:\Windows\Bureau\Hoop Bot\lib\scrcpy-win64\')
And if you are using #ScriptDir it should go like this:
Run(#Scriptdir & '\lib\scrcpy-win64\scrcpy-noconsole.exe', 'R:\Windows\Bureau\Hoop Bot\lib\scrcpy-win64\')

Classic ASP migration to Windows 2016 Chilkat Zip Activex issue with temdir

This is as much a note for myself as to help anyone else.
We migrated a Classic ASP application to Window 2016. Everything worked in the end. Then an issue surfaced with some zip & download functionality for which we use a Zip component from Chilkat.
Initially, all looked well - the software component was installed and responded to instantiation, but the zip files did not appear on disk where expected.
What could it be? Modifying the code as:
Set oZip = Server.CreateObject(CHILLKAT_ZIP_OBJECT_NAME)
oZip.UnlockComponent(<the license code>)
oZip.WriteZipAndClose()
Response.Write "<pre>" & Server.HTMLEncode( ozip.LastErrorText) & "</pre>"'
response.end
Produced
ChilkatLog:
WriteZipAndClose:
DllDate: Mar 1 2011
UnlockPrefix: *******
Username: *******
Architecture: Little Endian; 32-bit
Language: ActiveX
tempFile: .\ckz_40NT.tmp
Encryption: 0
PasswordProtected: 0
Failed to open file (2)
filename: .\ckz_40NT.tmp
currentWorkingDirectory: C:\Windows\SysWoW64\inetsrv
osErrorInfo: Access is denied.
Filename: .\ckz_40NT.tmp
Failed to open output Zip file
zipFilename: .\ckz_40NT.tmp
Retrying with a new temp filename
Encryption: 0
PasswordProtected: 0
Failed to open file (2)
filename: .\ckz2_I473.tmp
currentWorkingDirectory: C:\Windows\SysWoW64\inetsrv
osErrorInfo: Access is denied.
Filename: .\ckz2_I473.tmp
Failed to open output Zip file
zipFilename: .\ckz2_I473.tmp
tempFileName: .\ckz2_I473.tmp
Cannot open temporary file
Failed.
What could the prolem be ?
The issue was with chilkat's tempdir setting. On our version of Chilkat Tempdir defaulted to the IIS home folder which is unlikely ever to be happy having random files written to it. Adding a line to set tempdir to something more sensible, as below, cured the issue.
Set oZip = Server.CreateObject(CHILLKAT_ZIP_OBJECT_NAME)
oZip.UnlockComponent(<the license code>)
' added the next line !
oZip.TempDir = Server.MapPath("/some accessible folder path")
oZip.WriteZipAndClose()
Response.Write "<pre>" & Server.HTMLEncode( ozip.LastErrorText) & "</pre>"'
Useful info. I'm a Classic ASP programmer and at some point will need to move from Windows 2012 to Windows 2016. Been putting it off!

Why cant I run my application with a default file like that of notepad?

Why cant I run my application with a default file like that of Notepad ?
AutoIt sample code below :
Example()
Func Example()
; Run Notepad
Run("Notepad.exe " & "C:\Users\judith_francis\Desktop\dd.txt")
Run("C:\Program Files (x86)\abc\abc.exe" & "C:\Users\xyz\Desktop\test_image.tif")
EndFunc
This line:
Run("C:\Program Files (x86)\abc\abc.exe" & "C:\Users\xyz\Desktop\test_image.tif")
Runs the command
C:\Program Files (x86)\abc\abc.exeC:\Users\xyz\Desktop\test_image.tif
Which Windows will interpret as
C:\Program
Try instead
Run('"C:\Program Files (x86)\abc\abc.exe" ' & '"C:\Users\xyz\Desktop\test_image.tif"')
Which adds the necessary space & quotes & will be executed as
"C:\Program Files (x86)\abc\abc.exe" "C:\Users\xyz\Desktop\test_image.tif"

Zipping a folder using 7-Zip from an asp page

I am trying to zip a folder from an asp page. This is my code:
zipFolderName=folderName &"Zipped.zip"
command="cd C:\Program Files\7-Zip & "
command = command & "7z a -tzip " & zipFolderName & " """ & folderName & """"
Response.Write command
set objshell = Server.CreateObject("WScript.shell")
objShell.exec (command)
set objshell=nothing
The command that is written in the Response.Write is
cd C:\Program Files\7-Zip & 7z a -tzip D:/saveAll/DocumentsZipped.zip "D:/saveAll/Documents"
When I run this command in a cmd window it works just fine. But my asp page shows an error:
WshShell.Exec error '80070002'
The system cannot find the file specified.
The error is on the objShell.exe command-line.
What am I doing wrong? Please help!
You need to put C:\Program Files\7-Zip between double quotes, because the path contains a space. Also, cd and & are CMD-builtins, so you need to run the command line in CMD.
Change this:
command="cd C:\Program Files\7-Zip & "
into this:
command = "%COMSPEC% /c cd ""C:\Program Files\7-Zip"" & "

Excel VBA errors only when saving non-XL files, to network, from virtual server

We are using a new box to run our VBA
I’m getting some unexpected errors when saving non-excel files, from Excel, to the network.
In one program it fails on the following
.SaveAs "\\fileserve\department$\x\yyy\xxx\" & RepOperName & FileName & strdate & ".msg", olMSG
Showing a run-time error '-2147287008(80030020)'
In another the following just stops on the line Excel.ActiveSheet.ExportAsFixedFormat... with a alert saying document not saved - these are pdf docs it is attempting to save:
Dim FullPath_pdf As String
FullPath_pdf = "\\fileserve\department$\x\Statistics\Reporting\zzz\yyy\kkk\Daily Summary.pdf"
Excel.ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
FileName:=FullPath_pdf, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
From:=1, _
To:=2, _
OpenAfterPublish:=False
Is this likely to be down to the configuration of Excel on the server?
Or will it be more in connection with the configuration of the virtual server and its relationship to the network?
Had the same problem.
I found out I can’t save non-xls files directly to a network path from Excel.
So, my work around was:
Export the file locally to any directory
Use ROBOCOPY (since you are using Windows 7) to transfer the file
across the network
That should work.
Another tip is to make Excel delete the old file before creating a new one.
You could use a Macro like this:
Sub DeleteExample()
'You can use this to delete all xml? files in the folder Test
On Error Resume Next
Kill "C:\Users\Neo\*.xml*"
On Error GoTo 0
End Sub

Resources