0

I am trying to execute a vbs file using C# code. The vbs file has the code to invoke an application on my machine. I am able to run the vbs script file when i run the C# code locally, but when i deploy my code to SharePoint environment it looks like it is not even executing the file. I dont receive any error message or any message i added in the vbs script file. Below is the C# code i am using to run the vbs script file. Can someone please tell me if i am missing anything here?

C# Code:

  Process scriptProc = new Process();
    scriptProc.StartInfo.FileName = @"cscript";
    scriptProc.StartInfo.Arguments = @"//B //Nologo C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\template\layouts\segmentationtools\test1.vbs";
    scriptProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    scriptProc.Start();
    scriptProc.WaitForExit();
    scriptProc.Close();

VBS Code:

Dim qtApp 
Set qtApp = CreateObject("QuickTest.Application","Server IP address")
MsgBox("Hello world")
qtApp.Launch
qtApp.Visible = True 
7
  • "asp.net" in sense of trying to run application that shows UI from under service account? Commented Jul 2, 2013 at 23:55
  • Hi Alexei, Sorry i dint follow your question. Can you please brief what you are asking here?
    – user545359
    Commented Jul 3, 2013 at 0:00
  • Where do you try to run that C# code? Console app/from some random service/IIS/... and what account this code runs under? Commented Jul 3, 2013 at 0:50
  • I am running this code on SharePoint web application. Normally i deploy the aspx pages in _layouts folder and .dll related to the code is deployed in the bin folder of web application. I am not sure whether the code is running on system account or any other account because i do not have the permissions to the server and we have been given access to the deployment folder on server.Can you please let me know if there is any way to see on which account the code is running and does it really matter to see on what account the code is running? Sorry i am new to this vbs file running. Thanks
    – user545359
    Commented Jul 3, 2013 at 0:57
  • Your sample script obviously not going to do anything sane as it tries to show UI, but launching command line tools/scripts that only output to console should be ok. You may need to use RunWithElevatePrivileges method to be able to run anything/access file system... Configuring you local SharePoint properly and accessing with non-admin/non-local account will go long way in helping to debug the issue. Commented Jul 3, 2013 at 1:05

1 Answer 1

1

If what you are trying to do is start a UFT/QTP test using a C# application, then the following example will help you:

http://www.codeproject.com/Answers/288214/How-to-Automate-Qtp-with-C-sharp#answer4

It is a bit different way from what you tried to do in your code (Run a C# app that runs a vbs file that runs a QTP test), the following code is directly running a QTP test straight from the C# application.

I used that code to develop an app that is scheduling and control QTP tests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.