Jump to content

Recommended Posts

Posted
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.
Posted

IF %COMPUTERNAME%==ITROOM1-01 GOTO IT1

IF %COMPUTERNAME%==ITROOM2-01 GOTO IT2

 

:IT1

call \\server1\netlogon\it1.bat

:IT2

call \\server1\netlogon\it2.bat

 

 

etc etc, you get the jist

 

%computername% is an environment variable, you can do echo %computername% in cmd.exe to see how it works.

  • 5 weeks later...
Posted

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:

 

set part_name_ict1=%computername:~0,3%1%computername:~4,3%
set part_name_ict2=%computername:~0,3%2%computername:~4,3%

if %part_name_ict1%==%computername% goto test1
if %part_name_ict2%==%computername% goto test2
goto broke

:test1
echo It works! ICT1 set
goto end

:test2
echo It works! ICT set!
goto end

:broke
echo broke!
goto end

:end
exit

 

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.

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!

Guest blacksheep
Posted

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

 

Dim wshshell,

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)

setup_r16

Case "LIB"

setup_Library

End Select

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...