Scripts Thread, Script to call another based on machine name in Coding and Web Development; Hey all, I've a question on how it could be made that a script .vbs or .bat that runs on ...
2nd April 2008, 04:10 PM #1
Script to call another based on machine name
Hey all, I've a question on how it could be made that a script .vbs or .bat that runs on longon, checks the name of the computer and based on that calls another script. I think this can be done along with the custom start menu .adm file i found on this site ages ago (sorry can't give credit) to map an appropiate start menu to the user. This drive can then be hidden using Hidecalc and with a slight modification to the .adm it creates restrict it to. this means that all shortcuts can be stored on the server without the common problem of users being able to browse the network throught double clicking. I assume some case statements may be made but I've no idea how to piece such a script together. Any help would be greeatly appreciated.
2nd April 2008, 04:32 PM #2
- Rep Power
IF %COMPUTERNAME%==ITROOM1-01 GOTO IT1
IF %COMPUTERNAME%==ITROOM2-01 GOTO IT2
etc etc, you get the jist
%computername% is an environment variable, you can do echo %computername% in cmd.exe to see how it works.
3rd April 2008, 10:30 AM #3
Thanks working great now (thanks button has disappeared for me atm)
3rd April 2008, 12:07 PM #4
- Rep Power
Lol, dont worry, nobody ever thanks me
2nd May 2008, 12:27 PM #5
Oldish thread i know, but this tickled my fancy. I wondered if you could do a wildcard type thing with this to test against multiple computers without having to list each one in the script - so the script runs a command for all
ICT1-xx computers, but not ICT2-xx computers, for example.
Turns out wildcards aren't supported, but a work around is possible as long as you have a specific and regular naming system for your suites:
For example computer name ICT1-01, the set commands pick out the first three characters (ICT) and the last three characters (-01), and fasten them together with a digit specified in the code specific to that variable.
if %part_name_ict1%==%computername% goto test1
if %part_name_ict2%==%computername% goto test2
echo It works! ICT1 set
echo It works! ICT set!
So, part_name_ict1 would generate ICT1-01, but part_name_ict2 would generate ICT2-01.
The script goes on to compare the constructed part_name variables against the actual computer name, redirecting accordingly. This can then be used to run specific commands for individual rooms, without having to have multiple different scripts. You could do all this through setting logon scripts in group policy, i realise, or using Kixtart, but maybe someone can find a use for this!
2nd May 2008, 01:04 PM #6
- Rep Power
May be of interest, - also useful stuff you can do in vb (I wish I could do everything in batch files but they are not poweful enough). I setup printer, add shortcuts etc..
ie quick script to jump to other vb in case statement..
Here I have capitalised the characters of the machine name, and then used the first 3 characters to make case checks. Useful for setting up whole rooms, as I name machines with with room-machine# ie. R13-01 R13-02
On Error Resume Next
Set wshshell = WScript.CreateObject("WScript.Shell")
Select Case Left(Ucase(wshnet.ComputerName),3)
Case "R16" ie. (all machines in Room 16)
By webman in forum MIS Systems
Last Post: 7th March 2009, 07:10 PM
By Jobos in forum Windows
Last Post: 15th June 2007, 12:18 PM
By GrumbleDook in forum Courses and Training
Last Post: 20th March 2007, 12:47 PM
By garibaldi in forum General Chat
Last Post: 13th March 2006, 11:18 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)