Visual Studio 2017 C# launching powershell script -


hope right place ask new site :)

i created gui in visual studio new user creation. part of code calls powershell script have been using user creation.

so gui works can add users csv file creates , launches powershell script.

the problem part of powershell script loads exchange 2007 snapin. reason when running script via gui have created comes error saying unable find plugin.

so code launching powershell follows. not coder @ going wrong way , might bit of mess hehe :)

process p = new process();  p.outputdatareceived += new datareceivedeventhandler(outputhandler);  // redirect output stream of child process. p.startinfo.createnowindow = false; (false testing) p.startinfo.useshellexecute = false; p.startinfo.redirectstandardinput = false; //(false testing) p.startinfo.redirectstandardoutput = false; //(false testing) p.startinfo.redirectstandarderror = false; //(false testing) p.startinfo.loaduserprofile = true; p.startinfo.filename = "this points file on network share" @"\\server\folder\file";  p.start(); p.beginoutputreadline(); 

the above happens after button click , outputting text box within gui once have working. have side of things disabled can see errors in powershell.

so error message in powershell follows

'microsoft.exchange.management.powershell.admin' not installed on computer

but again if run script manually without gui works fine. gui launching in closed environment has no access computer running on. prob missing simple have no idea creating c# apps.

ok think have solved problem.

i should have explained better on doing launch powershell script. using above code launch .bat file , doing way whatever reason when bat file ran not work , above error.

so used little program convert bat file exe , set run admin. resolved issue , script runs correctly.

not sure why launch bat file did not have access local user profile not load powershell exchange snap-in details stored in local users registry.

so solution change bat file gui launched powershell script exe file. not sure why works :)

thanks michael smith


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -