Windows Programming Question

S

Scott Nash

Hello,

My question has to do with Computer Management.

I know the command to open Computer Management to a specific computer is :
compmgmt.msc /computer:computer01

Can someone tell me how to be able to be prompted for a computer name and
then have Computer Management open with that computer? I'm sure it's some
type of script or bat file, but I have no idea how to proceed.

Basically, I'd like to be able to have the following happen:

From windows or command prompt, I run a program. It prompts me for a
computer name and then Computer Management opens with that computer.

Thanks everyone!
 
M

Mark Blain

I know the command to open Computer Management to a specific computer
is : compmgmt.msc /computer:computer01

Can someone tell me how to be able to be prompted for a computer name
and then have Computer Management open with that computer? I'm sure
it's some type of script or bat file, but I have no idea how to
proceed.

Basically, I'd like to be able to have the following happen:

From windows or command prompt, I run a program. It prompts me for a
computer name and then Computer Management opens with that computer.

Here's a sample batch file using the SET /P command to ask the question.
Save it as somename.BAT and double-click to run it:

@echo off
set /p computer=Which Computer?
echo I will now try to manage %computer%.
pause
compmgmt.msc /computer=%computer%


Here's a sample VBScript file using InputBox to ask the question.
Save it as somename.VBS and double-click to run it using Windows Scripting
Host:

strInput = InputBox ("Which computer")
MsgBox "I will now try to control " & strInput & "."
Set WshShell = WScript.CreateObject("WScript.Shell")
cmdline = "cmd.exe /c compmgmt.msc /computer=" & strInput
Set oExec = WshShell.Exec(cmdline)


Note: neither of the above has any error-checking. Search online for
tutorials and lessons to learn batch programming and VBScript/Windows
Scripting Host. One good place to start is
http://www.robvanderwoude.com/index.html
 
S

Scott Nash

Thanks a lot!! The VBS script worked perfectly!


Mark Blain said:
Here's a sample batch file using the SET /P command to ask the question.
Save it as somename.BAT and double-click to run it:

@echo off
set /p computer=Which Computer?
echo I will now try to manage %computer%.
pause
compmgmt.msc /computer=%computer%


Here's a sample VBScript file using InputBox to ask the question.
Save it as somename.VBS and double-click to run it using Windows Scripting
Host:

strInput = InputBox ("Which computer")
MsgBox "I will now try to control " & strInput & "."
Set WshShell = WScript.CreateObject("WScript.Shell")
cmdline = "cmd.exe /c compmgmt.msc /computer=" & strInput
Set oExec = WshShell.Exec(cmdline)


Note: neither of the above has any error-checking. Search online for
tutorials and lessons to learn batch programming and VBScript/Windows
Scripting Host. One good place to start is
http://www.robvanderwoude.com/index.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top