Not able to run .vbs file from jenkins which is having excel script - jenkins

I’m new to Jenkins and now I'm doing basic level of execution. And I need your help resolve my issue. Issue Description: I’m trying to run the .VBS file by using jenkins and getting below error:
C:\Users\Amar\Desktop\Test_Sample.vbs(3, 2) Microsoft Excel: Microsoft Excel cannot access the file ‘C:\Users\Amar\Desktop\New.xlsx’.
There are several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently
open workbook.
I have not opened any excel file and path also correct.
please find below batch command : CScript “C:\Users\Amar\Desktop\Test_Sample.vbs”
And in Test_Sample.vbs file having:
Dim ExcelObj, WbookObj, mysheet
Set ExcelObj= CreateObject("excel.application")
Set WbookObj= ExcelObj.workbooks.open("C:\Users\Amar\Desktop\New.xlsx")
Set mysheet= ExcelObj.ActiveWorkbook.Worksheets("Sheet1")
ExcelObj.Visible = False
ExcelRowCount = mysheet.UsedRange.Rows.Count
For Iterator = 2 To ExcelRowCount
ModuleName = Ucase(Trim(mysheet.Cells(Iterator,1)))
ExecutionFlag = Ucase(Trim(mysheet.Cells(Iterator,2)))
if (moduleName="Raj") Then
Set qtApp = CreateObject("QuickTest.Application")
If qtApp.launched True then
qtApp.Launch
End If
qtApp.Visible = True
qtApp.Open "F:\Jenkins_Jobs\OnCall_Sanity_Automation\DriverScript\Sample", False
Set QTPTest=qtApp.Test
QTPTest.Run 'Run the Test QTPTest.Close
qtApp.quit
Set qtApp = Nothing
else
MsgBox "Name not exists"
End If
Next
Please help me to resolve the issue.
Thanks, Amar
Update
Console Output:
Building in workspace C:\Program Files
(x86)\Jenkins\workspace\Excel_Test [Excel]
$ cmd /c call C:\WINDOWS\TEMP\jenkin02.bat (C:\Program Files
(x86)\Jenkins\workspace\Excel_Test>CScript )
C:\Users\Admin\Desktop\Test_Sample.vbs"
C:\Users\Admin\Desktop\Test_Sample.vbs(3, 2) Microsoft Excel:
Microsoft Excel cannot access the file
C:\Users\Admin\Desktop\New.xlsx. There are several possible reasons:
** The file name or path does not exist.** The file is being used by another program. The workbook you are trying to save has the same
name as a currently open workbook.

If you are working on 64-bit Windows Operating System.
Then go to
C:\Windows\SysWOW64\config\systemProfile
Above Folder and create an empty Folder, and name it "Desktop" inside "systemProfile".
For doing this, you need system admin access
After creating the folder as mentioned, then run your build in Jenkins.

Run the jenkins job in command prompt on a slave,it will work!

Set Full control permissions for below path "Desktop" directory
"C:\Windows\SysWOW64\config\systemprofile\Desktop " (for 64 bit Windows) or "C:\Windows\System32\config\systemprofile\Desktop " (for 32 bit Windows)
If Desktop directory in present please create and give Full control permissions

Related

How to integrate Hybris Custom and Config folder to local installation?

I installed Hybris 1905 out of the box locally on my machine and I would like to include the custom code which our project stores on bitbucket.
To track the progress of the commits, I installed earlier Sourcetree and have integrated the repository. The repo is stored locally in directory
C:\git\projectname
How can I now get the folders custom and config into my local installation to be able to run always the latest code in my local machine? Thanks!
You can create a symlink or directory junction.
Assuming your custom config is stored in C:\git\projectname\config and your custom code is stored in C:\git\projectname\bin\custom
In hybrisHomeDirectory, open command prompt then type :
mklink /J config C:\git\projectname\config
this will create a directory junction that link your config to hybris installation folder.
In hybrisHomeDirectory/bin, open command prompt then type :
mklink /J custom C:\git\projectname\bin\custom
This will create a directory junction that link your custom code.
If you want to create a symlink instead of directory junction (requires admin), then open cmd as administrator and type mklink /D instead of mlink /J
Config folder
In order to refer a config folder(other than the default one) you can edit your hybris\bin\platform\setantenv.bat. For example please have a look at my setantenv.bat that I used in the past:
#echo off
set ANT_OPTS=-Xmx2g -Dfile.encoding=UTF-8 -Djdk.util.jar.enableMultiRelease=force
set ANT_HOME=%~dp0apache-ant
set PATH=%ANT_HOME%\bin;%PATH%
rem deleting CLASSPATH as a workaround for PLA-8702
set CLASSPATH=
Rem Custom zone start
set HYBRIS_RUNTIME_PROPERTIES=%~dp0local_custom.properties
chcp 65001
set HYBRIS_CONFIG_DIR=%~dp0..\..\..\gitrepo\config
echo -------CustomChanges--------
echo CustomChanges: configFolder: %HYBRIS_CONFIG_DIR%
echo CustomChanges: runTimeProperties: %HYBRIS_RUNTIME_PROPERTIES%
echo -------CustomChanges--------
Rem Custom zone end
echo ant home: %ANT_HOME%
echo ant opts: %ANT_OPTS%
ant -version
Between Rem Custom zone start and Rem Custom zone end there is the Custom section that, among other things, sets the path to the config folder.
In my case, hybris folder and gitrepo folder are right next to eachother(in the same parent folder) and that is why the following path(also mentioned above) works:
set HYBRIS_CONFIG_DIR=%~dp0..\..\..\gitrepo\config
Keeping these two folders next to each other makes it easier to use relatives paths in order to easily use resources from git Repo into Hybris.
Custom folder
In order for Hybris to take into consideration the custom extensions, their folder needs to be specified in the localextensions.xml as exemplified below:
<path autoload="true" dir="${HYBRIS_BIN_DIR}/../../gitRepo/extensions"/>
Again, above relative path works for me because hybris and gitrepo folders are next to each other.

Jenkins Error "Microsoft Excel cannot access the file"

I am using jenkins to run a .bat file that is in location
C:\Users\foo\Desktop\xxx.bat
which internally
copies from another machine an excel
calls a vbs script found in D:
D:\foo\Newtask.vbs
that opens a file:
C:\Users\foo\Desktop\xxx\xxx\xxx\New.xlsm
The error I am getting is
For the first excel: The system cannot find the path specified
For the second New.xlsm:
D:\foo\Newtask.vbs(14, 1) Microsoft Excel: Microsoft Excel cannot access the file 'C:\Users\foo\Desktop\xxx\xxx\xxx\New.xlsm'. There are several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open workbook
I find it odd that jenkins can access and run .bat in foo user's directory while it cannot find C:\Users\foo\Desktop\xxx\xxx\xxx\New.xlsm --> I checked it exists.
When running the .bat manually i have no problem.
Any ideas?
I had the same issue. Solution from this page worked https://techcommunity.microsoft.com/t5/sql-server-support-blog/error-8216-microsoft-office-excel-cannot-access-the-file-8217/ba-p/317477
...x64: Create the following directory:
C:\Windows\SysWOW64\config\systemprofile\Desktop
x86: Create the following directory:
C:\Windows\System32\config\systemprofile\Desktop...

Essbase Error 1241109 Unable to Open file

I am automating the process to run a report script. The batch script is located on Windows and the Essbase server is on UNIX.
Getting an error while executing the below statement
export database App.DB using server_file 'Report1.rep' to data_file '/apps/AppName/FileName.txt';
TIA
is the path correct?
Essbase does not create directories, so maybe /apps/Appname does not exist.
I would also suggest to put the Files under Appname/Database but thats a personal thing.

Pyinstaller adding data files

I'm struggling with pyinstaller. Whenever I build this specific script with a kivy GUI and a .kv file, and run the .exe after the build, I get a fatal error:
IOError: [Errno 2] No such file or directory: 'main.kv'
I've tried adding the .kv file, as well as a mdb and dsn file (for pypyodbc) using --add-data, but I get an error: unrecognized arguments: --add-data'main.kv'. (There were more --add-data arguments for the other files mentioned.)
Are there any solutions for this or maybe alternative methods?
As others (#Anson Chan, #schlimmchen) have said:
If you want to add some extra files, you should use Adding Data Files.
Two ways to implement
Command Line: add parameter to --add-data
Spec file: add parameter to datas=
Generated when running pyinstaller the first time.
Then later you can edit your *.spec file.
Then running pyinstaller will directly use your *.spec file.
Parameter Logic
Parameter in --add-data or datas=:
--add-data:
format: {source}{os_separator}{destination}
os_separator:
Windows: ;
Mac/Linux/Unix: :
source and destination
Logic:
source: path to single or multiple files, supporting glob syntax. Tells PyInstaller where to find the file(s).
destination
file or files: destination folder which will contain your source files at run time.
* NOTE: NOT the destination file name.
folder: destination folder path, which is RELATIVE to the destination root, NOT an absolute path.
Examples:
Single file: 'src/README.txt:.'
multiple files: '/mygame/sfx/*.mp3:sfx'
folder: '/mygame/data:data'
datas=
Format: list or tuple.
Examples: see the following.
added_files = [
( 'src/README.txt', '.' ),
( '/mygame/data', 'data' ),
( '/mygame/sfx/*.mp3', 'sfx' )
]
a = Analysis(...
datas = added_files,
...
)
Your case
For your (Windows OS) here is:
--add-data in command line
pyinstaller -F --add-data "main.kv;." yourtarget.py
OR:
datas= in yourtarget.spec file, see following:
a = Analysis(...
datas = ["main.kv", "."],
...
)
If you check pyinstaller -h for help, you can find --add-data option works like this [--add-data <SRC;DEST or SRC:DEST>]. So in your case try
pyinstaller -F --add-data "main.kv;main.kv" yourtarget.py
The solution is to run: pyi-makespec yourscript.py
Then edit the yourscript.spec script and add the files under datas in a= Analysis.
datas=[ ( '/pathToYourFile/main.kv', '.' )]
then run pyinstaller yourscript.spec
should be good after that.
Next -F or --onefile option is assumed when running pyinstaller.
Note that (MacOS Monterey, 12.2 here) the expected folder hierarchy w/in you .app file will be similar to this,
pyinstaller does not add files nor create necessary folders into any of the folders of this folder structure; at least not in any apparent way. You won't find them.
However, when the application runs, a temporary folder is used under /var/folders which is very different from the folder structure in point 1. above. print(os.path.dirname(__file__)) while running the application will reveal which exact temporary folder is used each time it runs. For convenience, let's call it my_app_tmp_folder i.e. your app runs under the folder /var/folder/my_app_tmp_folder
Then, pyinstaller adds data files or creates necessary directories w/in this temporary folder. In other words, when the application runs, all added files will be there and according to the specified folder structure (through --add-data option). print(os.listdir(os.path.dirname(__file__))) will show system and application needed files and folders.
Bottom line: Files specified w/ --add-data option will be visible w/in /var/folder/my_app_tmp_folder when running and not w/in the *.app folder.
Some useful links from documentation:
https://pyinstaller.readthedocs.io/en/stable/runtime-information.html#using-file
https://pyinstaller.readthedocs.io/en/stable/spec-files.html#adding-files-to-the-bundle
https://pyinstaller.readthedocs.io/en/stable/operating-mode.html#bundling-to-one-file
My application had this issue and a subsequent issue that is likely, if not inevitable.
1. --add-data for a kv file
Use --add-data as in the answer by crifan.
2. Kivy still can't find the file
Once PyInstaller has the kv file in the correct directory, Kivy still can't find the file.
Possible Symptoms:
GUI launches, but screen is black and empty.
An AttributeError error that depends on the application code.
AttributeError Examples:
This question
My own case:
AttributeError: 'NoneType' object has no attribute 'ids'
Fortunately, this answer solves the problem.

SSIS not writing file while executing from different user

I have developed SSIS package to export data to excel file. below are the steps executed by the package
1.Send mail of starting package
2.Copy excel Template to Source folder ( This is Temporary file )
3. Retrieve data (In this step we are retrieve data from 6-7 tables)
4.create folder structure to export i.e First check folder for year and month if not exist dot create
5.Copy the source folder file (Step2) to above create folder.
The problem here is when I deploy and execute package through my account its run perfectly. But same package with same setting if I run through different account its not writing file ie. Its copies source file at the end. but in execution it shows its executed successfully at the start. click for excution Report
Based on your description, please check your account permission for the one you failed to run the package. The account to execute to package should have the full permission to read from database and also make sure that account could visit, read and write to windows directory.

Resources