Prev: Right Click FTP
Next: match computers in 2 text files
From: harrykrishna.nospam on 9 Sep 2010 15:41 Maw <maw81maw(a)gmail.com> wrote: >On Sep 9, 3:04�pm, harrykrishna.nos...(a)online.ie wrote: >> Why not add the following line to your code, then copy that text deom >> C:\creatembx\debug.txt and place it in a command prompt to see if you >> get the desired results.. >> >> That would eliminate any miss-typing since it is exactly the same line >> that is contained in your command variable: >> >> WSHshell.run "CMD /c ECHO " & command & "> C:\creatembx\debug.txt" >> >> I am assuming you are running this with the same credentials (elevated >> or not) as you did with the original script. >> >> HTH >> >> Maw <maw81...(a)gmail.com> wrote: >> >On Sep 9, 1:05�am, "Al Dunbar" <aland...(a)hotmail.com> wrote: >> >> "Maw" <maw81...(a)gmail.com> wrote in message >> >> >>news:6914506a-147c-4177-95b8-537259f089af(a)b34g2000yqm.googlegroups.com... >> >> >> > Hi to all, >> >> > i had wirte a HTA script and that run a exchange ps1 script but that >> >> > doesn't start. >> >> >> When you say that your ps1 script doesn't start, what is it that actually >> >> happens at that point? Hint: is an error message displayed? >> >> >no message is displayed, i can see only the black screnn appear for 1 >> >sec. >> >> >> > Code below: >> >> >> > command = "powershell.exe -PSConsoleFile ""c:\Program Files\Microsoft >> >> > \Exchange Server\Bin\exshell.psc1"" -command C:\creatembx\" & file & >> >> > " �" & first.value & "." & last.value & �"@" & domain.value & " " & >> >> > first.value & " " & last.value >> >> > set WSHShell = CreateObject("Wscript.Shell") >> >> > WSHshell.run command >> >> > msgBox command >> >> >> > The msgbox show the correct command line. >> >> > If i type the command showed by msgbox that work. >> >> >> What is the name of your ps1 script file, "excshell.psc1" (as shown in your >> >> vbscript above), or "excshell.psc1" (which seems more likely)? >> >> >my ps1 change name. The script select the correct scrit to run. >> >> >> Given how fully integrated powershell is in how Exchange is managed, why are >> >> you using vbscript at all? >> >> >> /Al >> >> >All script code: >> >> ><html> >> ><head> >> ><title>HTA Test</title> >> ><HTA:APPLICATION >> > � � ID="objTest" >> > � � APPLICATIONNAME="HTATest" >> > � � SCROLL="yes" >> > � � SINGLEINSTANCE="yes" >> >> ></head> >> >> ><SCRIPT LANGUAGE="VBScript"> >> >flag = "true" >> > � �Sub TestSub >> > � � � � � �MsgBox first.Value & vbNewLine & last.Value >> > � �End Sub >> >> >Sub composeidmail () >> >loginid=Mid(first.value, 1,1) & Mid(last.value, 1,7) >> >lung=Len(loginid) >> >Do While (lung<8) >> >loginid = loginid & "0" >> >lung=Len(loginid) >> >Loop >> >'MsgBox first.value >> >idad.value=loginid >> >mail.value=first.value & "." & last.value & "@marsh.com" >> >End Sub >> >> >Sub check () >> >Select Case (multi.value) >> >Case "false" >> >Case "user" >> >Case "MULTIBOX" >> >End select >> >If multi.value = "false" then >> > � �MsgBox "Selezionare la tipologia di mailbox da creare." >> >elseif multi.value = "user" then >> > � �flag1 = multi.value >> > � �call creatembx >> >elseif multi.value = "MULTIBOX" then >> > � �flag1 = multi.value >> > � �call createmultimbx >> >end if >> >End Sub >> >> >Sub creatembx () >> >Select Case (domain.value) >> >Case "dominio1" >> >Case "dominio2" >> >Case "dominio3" >> >Case "dominio4" >> >Case "dominio5" >> >End select >> >If domain.value = "false" then >> > � �MsgBox "Selezionare il dominio dell'utenza." >> > � �flag = "false" >> >elseIf domain.value = "dominio1" then >> > � �file = "dom1.ps1" >> >elseIf domain.value = "dominio2" then >> > � �file = "dom2.ps1" >> >elseIf domain.value = "dominio3" then >> > � �file = "dom3.ps1" >> >elseIf domain.value = "dominio4" then >> > � �file = "dom4.ps1" >> >elseIf domain.value = "dominio5" then >> > � �file = "dom5.ps1" >> >end if >> >If flag = "true" then >> > � �if first.value <> "" and last.value <> "" then >> > � � � � � �command = "powershell.exe -PSConsoleFile ""c:\Program Files\Microsoft >> >\Exchange Server\Bin\exshell.psc1"" -command C:\creatembx\" & file >> >' & " �" & first.value & "." & last.value & �"@" & domain.value & " " >> >& first.value & " " & last.value >> > � � � � � �'command = "powershell.exe Add-PSSnapin >> >Microsoft.Exchange.Management.PowerShell.Admin ; C:\creatembx\" & file >> >& " " & first.value & "." & last.value & �"@" & domain.value & " " & >> >first.value & " " & last.value >> > � � � � � �set WSHShell = CreateObject("Wscript.Shell") >> > � � � � � �WSHshell.run command >> > � � � � � �msgBox command >> > � �else >> > � � � � � �MsgBox "I campi Nome e Cogneme non possono essere Vuoti." >> > � �end if >> >end if >> >flag = "true" >> >End Sub >> >> >Sub createmultimbx () >> >Select Case (domain.value) >> >Case "dominio1" >> >Case "dominio2" >> >Case "dominio3" >> >Case "dominio4" >> >Case "dominio5" >> >End select >> >If domain.value = "false" then >> > � �MsgBox "Selezionare il dominio della MULTIBOX." >> > � �flag = "false" >> >elseIf domain.value = "dominio1" then >> > � �file = "dom1multy.ps1" >> >elseIf domain.value = "dominio2" then >> > � �file = "dom2multy.ps1" >> >elseIf domain.value = "dominio3" then >> > � �file = "dom3multy.ps1" >> >elseIf domain.value = "dominio4" then >> > � �file = "dom4multy.ps1" >> >elseIf domain.value = "dominio5" then >> > � �file = "dom5multy.ps1" >> >end if >> >If flag = "true" then >> > � �if first.value = "" and last.value <> "" then >> > � � � � � �set WSHShell = CreateObject("Wscript.Shell") >> > � � � � � �WSHshell.run ("C:\WINDOWS\system32\windowspowershell >> >\v1.0\powershell.exe -PSConsoleFile ""C:\Program Files\Microsoft >> >\Exchange Server\bin\exshell.psc1"" -noexit -command "". 'C:\creatembx >> >\" & file & "'" �& "" & " " & last.value & �"@" & domain.value & " " & >> >last.value) >> >' � � � � � msgBox ("C:\tmp\" & file & " " & last.value & �"@" & domain.value & >> >" " & last.value) >> > � �else >> > � � � � � �MsgBox "Solo il campo 'Cognome o Nome della mail Multibox' deve >> >essere compilato." >> > � �end if >> >end if >> >flag = "true" >> >End Sub >> >> >Sub quit >> > Window.Close >> >End Sub >> >> ></SCRIPT> >> >> ><body> >> ><table �border="1"> >> ><tr> >> ><td colspan="2" align="center"> >> >INTERFACCIA PER CREAZIONE MAILBOX PER UTENTI DEI DOMINI: <BR> >> >(adban01; adcal01; adcrc01; adhol01; hphone; monetica) <BR> >> ><BR> >> ></td> >> ></tr> >> ><tr> >> > � �<td colspan="2"> >> > � �Selezionare la tipologia di mailbox da creare >> > � �</td> >> ></tr> >> ><tr> >> > � �<td align="center" colspan="2"> >> > � �<SELECT NAME="multi"> >> > � �<OPTION value="false">SELECT TYPE</OPTION> >> > � �<OPTION value="user">USER</OPTION> >> > � �<OPTION value="MULTIBOX">MULTIBOX</OPTION> >> > � �</SELECT><P> >> > � �</td> >> ></tr> >> ><tr> >> > � �<td> >> > � �Selezionare il Dominio (Es.:adban01) >> > � �</td> >> > � �<td> >> > � �<SELECT NAME="domain"> >> > � �<OPTION value="false">SELECT DOMAIN</OPTION> >> > � �<OPTION value="dominio1">dominio1</OPTION> >> > � �<OPTION value="dominio2">dominio2</OPTION> >> > � �<OPTION value="dominio3">dominio3</OPTION> >> > � �<OPTION value="dominio4">dominio4</OPTION> >> > � �<OPTION value="monetica.res.local">MONETICA</OPTION> >> > � �</SELECT><P> >> > � �</td> >> ></tr> >> ><tr> >> > � �<td> >> > � �Cognome o Nome della mail Multibox >> > � �</td> >> > � �<td> >> > � �Nome: >> > � �</td> >> ></tr> >> ><tr> >> > � �<td> >> > � �<input type="text" name="last" size="30"><P> >> > � �</td> >> > � �<td> >> > � �<input type="text" name="first" size="30"><P> >> > � �</td> >> ></tr> >> ><tr> >> > � �<td> >> > � �<input id=runbutton �type="button" value="Run Script" >> >name="run_button" �onClick="check"> >> > � �</td> >> > � �<td> >> > � �<input id=runbutton �type="button" value="Quit" name="quit_button" >> >onClick="quit"> >> > � �</td> >> ></tr> >> >> >THANKS >> ></table> >> >> ></body> > >Thanks harrykrishna, >i have try your suggestion and the command that i find in the txt file >it's correct: >powershell.exe -PSConsoleFile "c:\Program Files\Microsoft\Exchange >Server\Bin\exshell.psc1" -command C:\creatembx\ban.ps1 > >If i run this command form START-->Run it's work fine. > >What's happenig???? > > >THX a lot > >Maw Sorry, don't know. Maybe you need to create a test VBS and run it (i.e. CSCRIPT "TEST.VBS") and see if you can see any error. I'd suggest this as the script since the command variable would be the same as you mentioned above. Note that the line starting "command =" wraps here but is all one line: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx set WSHShell = CreateObject("Wscript.Shell") command = "powershell.exe -PSConsoleFile " & """c:\Program Files\Microsoft\ExchangeServer\Bin\exshell.psc1""" & " -command C:\creatembx\ban.ps1" Return = WshShell.Run("cmd /k " & command, 1, true) wscript.echo "Return=" & Return xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Good luck. If nothing shows up that's all I can think of. Sorry... |