Batch file to Launch cmd.exe

Hi all,

I want to publish an app in Xenapp 5.0 (Windows 2003) through which I can launch command prompt on any of the server. Here is the idea:

1. user clicks on the icon from webpage (Citrix Web Interface)
2. application launches, it asks for the server for which it need to connect.
3. connects to server and command prompt launches.

I dont want to use any third party software for that.

How do I do that? Please help!!
bubaibhattaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
bubaibhattaConnect With a Mentor Author Commented:
Hi Everyone,

I solved the issue. I used Talha Tariq's RemCom(here) . This is a small tool written to run command prompt on any remote machine. I just published that tool.
0
 
Jaroslav MrazCTOCommented:
Hmm and what about if you publish CMD ? As exe file?
0
 
bubaibhattaAuthor Commented:
Hi Jeremyno,

I can do that. But the issue here is that I have to publish 50 appliactions for that to connect each server in the farm.

Naturally I thought of somekind of batch file which will ask me a choice of the server and accordingly connect me to the particular server of my choice.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Jaroslav MrazCTOCommented:
Ok,

i whose thinking litle bit about and the solution is powershell

here is simple script for something like you need

http://stackoverflow.com/questions/11130336/run-mstsc-exe-with-powershell

powershell understand CMD commands and can be used remotly without publishing or you can publish script.

Is this what you looking for?
0
 
Ayman BakrSenior ConsultantCommented:
If you have session sharing then as JEREMYNO said you can publish CMD and launch it after you have launched the application.

Alternatively, you can publish a batch file (.bat or .cmd) instead of the application; where it has two commands: one to launch the application and the second after sleeping for several seconds launch cmd.
0
 
bubaibhattaAuthor Commented:
Hi Mutawadi,

Can you explain a bit more on that? I am talking about the second option...
0
 
Venugopal NCommented:
$computername = read-host "Enter the computer name"

invoke-command -filepath c:\windows\system32\cmd.exe -computerName $computername

You can use the above line for powersheel scirpts..
0
 
Ayman BakrSenior ConsultantCommented:
On a batch file it would be something like this:

Start "C:\bla\bla\bla\<your app execution>"
Timeout /T 3
Start "C:\Windows\System32\cmd.exe"

Open in new window

0
 
Jaroslav MrazCTOCommented:
Yes or you can use this script with manual edit of computer name with conditions if you want
list of servers just with numbers 1. SERVER1, 2.SERVER2

see here
http://technet.microsoft.com/en-us/library/ff730939.aspx
0
 
bubaibhattaAuthor Commented:
Hi Venurajav,

whenever I try to run c:\windows\system32\cmd.exe -computerName $computername it runs on the same system, not on the remote system. Is there ant way to do that? I installed powershell on the server where I am running the script.
0
 
Venugopal NCommented:
Copy 2 line in the notepad and save it with ext ps1.Run the the file, first it will prompt for the computer name and then it run the cmd from that computer.

But i am not sure how you can use this to publish :(.
0
 
Jaroslav MrazCTOCommented:
Hi normaly you will publish powershell.exe with parameter

%windir%\system32\windowspowershell\v1.0\powershell.exe YOUR_SCRIPT_NAME.ps1
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
With PowerShell, you will need the  invoke-command   cmdlet, as shown in http:#a39203702. cmd.exe does not know of a -Computername switch. Further, you need to have Remoting (WinRM) active and configured on each target to allow for PS to execute commands.

http:#a39203733  is wrong. start doesn't run remotely, and the first parameter enclosed in double quotes is used as title, and not as command to execute.
0
 
bubaibhattaAuthor Commented:
The solution that I find is much more easier than that other's. I was expecting exactly the same.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.