Solved

Batch file to Launch cmd.exe

Posted on 2013-05-28
14
2,067 Views
Last Modified: 2013-06-16
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!!
0
Comment
Question by:bubaibhatta
  • 5
  • 4
  • 2
  • +2
14 Comments
 
LVL 15

Expert Comment

by:Jaroslav Mraz
Comment Utility
Hmm and what about if you publish CMD ? As exe file?
0
 

Author Comment

by:bubaibhatta
Comment Utility
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
 
LVL 15

Expert Comment

by:Jaroslav Mraz
Comment Utility
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
 
LVL 23

Expert Comment

by:Ayman Bakr
Comment Utility
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
 

Author Comment

by:bubaibhatta
Comment Utility
Hi Mutawadi,

Can you explain a bit more on that? I am talking about the second option...
0
 
LVL 11

Expert Comment

by:Venugopal N
Comment Utility
$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
 
LVL 23

Expert Comment

by:Ayman Bakr
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 15

Expert Comment

by:Jaroslav Mraz
Comment Utility
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
 

Author Comment

by:bubaibhatta
Comment Utility
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
 
LVL 11

Expert Comment

by:Venugopal N
Comment Utility
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
 
LVL 15

Expert Comment

by:Jaroslav Mraz
Comment Utility
Hi normaly you will publish powershell.exe with parameter

%windir%\system32\windowspowershell\v1.0\powershell.exe YOUR_SCRIPT_NAME.ps1
0
 
LVL 68

Expert Comment

by:Qlemo
Comment Utility
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
 

Accepted Solution

by:
bubaibhatta earned 0 total points
Comment Utility
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
 

Author Closing Comment

by:bubaibhatta
Comment Utility
The solution that I find is much more easier than that other's. I was expecting exactly the same.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
How to install and configure Citrix XenApp 6.5 - Part 1. In this video tutorial we have explained step by step installation of Citrix XenApp 6.5 Server on Windows Server 2008 R2 is explained in this video. We have explained the difference between…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now