Kriti
Kriti

Reputation: 191

Executing VBS via batch script in Jenkins

I have to execute the script on Window Server 2008. I use Jenkins for doing that. The batch code (MainCode.bat) is

cd "C:\temp"
cscript install.vbs

The install.vbs just installs the application in particular directory. The extract of the code is:

Set wshshell = wscript.CreateObject("WScript.Shell") 
strCmd = "cmd /K C:\temp\InstallApp.exe -c -dir C:\ProductDir"
Wshshell.run (strCmd)
WScript.Sleep 2000
' choice of languages
WshShell.SendKeys "1"
WshShell.SendKeys "~"
    ...

To test this scripts I ran MainCode.bat on Window Server 2008 directly and it worked like a charm.
While running via Jenkins, the script doesn't execute. No error message and the installation is not done.

Via Jenkins the code to call MainCode.bat is

call "C:\temp\MainCode.bat".

Upvotes: 2

Views: 10540

Answers (1)

Andy Chen
Andy Chen

Reputation: 361

As you are using SendKeys I assume the process you run is GUI application. You are probably running Jenkins slave under headless mode as windows service, in this case GUI application will have problems. You should run Jenkins slave agent as jnlp.

Upvotes: 4

Related Questions