0

Im using Sharepoint 2013 .Net 4.5 and I need run VB script in code behind(C#). This script should scanning my subnet and save new xml with devices in subnet. The script runs and xml file is created but inside I don't have any devices. When I run this script in cmd is ok.

This is my c# code:

    string scriptName = "audit_subnet.vbs";
    string create_file = "create_file=y";
    string submit_online = "submit_online=n";
    string subnet = "subnet=" + StartIP.Text + "-" + EndIP.Text;
    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.FileName = @"cscript";
    startInfo.WorkingDirectory = @"C:\xml";
    startInfo.Arguments = string.Format("\"{0}\" \"{1}\" \"{2}\" \"{3}\"", scriptName,create_file, submit_online, subnet);
        startInfo.WindowStyle = ProcessWindowStyle.Normal;
    using (Process exeProcess = Process.Start(startInfo))
    {
      exeProcess.WaitForExit();
    }

In debug:

   startInfo.Arguments = "\"audit_subnet.vbs\" \"create_file=y\" \"submit_online=n\" \"subnet=10.70.77.1-10.70.77.1\""

Here is this script(example): https://github.com/ethanhann/open-awesome/blob/master/bin/audit_subnet.vbs

I changed the script myself and it works when I run it in cmd.

Why when I start this script in c# is created file but won't scan subnet?

kol1991
  • 65
  • 3
  • 13
  • similiar question to SO: http://stackoverflow.com/questions/200422/how-to-call-a-vbscript-file-in-a-c-sharp-application.. so, to be clear.. the vbscript is not executing? Is it possbily a permission issue, are you giving the Application the rights to execute the file? – Brett Caswell Dec 03 '14 at 15:21
  • if you are looking for a vbscript answer, best to use that tag rather than vb.net – Ňɏssa Pøngjǣrdenlarp Dec 03 '14 at 15:28
  • Brett Caswell, My vbscript is executing but he dont scan subnet. exeProcess.WaitForExit(); is waiting for end and script is ending. Script is creating new file in folder but in file I dont have and devices. When I executing script in cmd in new file I have more nodes with devices. It is xml file. – kol1991 Dec 03 '14 at 16:39
  • I think it is a problem with permission but I don't know what permissions to give? – kol1991 Dec 03 '14 at 16:46

0 Answers0