Solved

Batch file to Launch cmd.exe

Posted on 2013-05-28
14
2,089 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
ID: 39203647
Hmm and what about if you publish CMD ? As exe file?
0
 

Author Comment

by:bubaibhatta
ID: 39203651
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
ID: 39203680
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
ID: 39203683
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
ID: 39203689
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
ID: 39203702
$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
ID: 39203733
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 15

Expert Comment

by:Jaroslav Mraz
ID: 39203801
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
ID: 39203802
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
ID: 39203860
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
ID: 39203882
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
ID: 39208605
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
ID: 39238300
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
ID: 39251056
The solution that I find is much more easier than that other's. I was expecting exactly the same.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Business Broadband for Small Office in Dubai 2 66
Computer software inventory 5 77
Auto Login Script 3 16
SBS 2003 RWW Login 3 16
#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
Learn about cloud computing and its benefits for small business owners.
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.

911 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

23 Experts available now in Live!

Get 1:1 Help Now