Helloo!!!
i would like to make a BATCH or a VBS which get the HOSTNAME, supress ALL the caracters after the 7th and to add AB at the end...
also i would like to connect a drive to it:
net use o: \\XXXXXXXAB\folder$
is it possible?
Page 1 of 1
batch get hostname supress 7th caracters...
#2
Posted 28 May 2010 - 04:32 AM
It depends on if you want to use the computername or the hostname (they are normally the same) though)
Here is a vbscript using the computername (run using cscript scriptname.vbs)
Here is a vbscript using the hostname from registry (run using cscript scriptname.vbs)
Here is a vbscript using the computername (run using cscript scriptname.vbs)
' get computer name Set oWshShell = CreateObject( "WScript.Shell" ) Set oWshNetwork = WScript.CreateObject( "WScript.Network" ) sComputerName = oWshNetwork.ComputerName sCmd = "net use O: \\" & Left(sComputerName,7) & "AB\folder$" wscript.echo "Executing commandline: " & sCmd oWshShell.run sCmd,0,True
Here is a vbscript using the hostname from registry (run using cscript scriptname.vbs)
' get hostname Set oWshShell = CreateObject( "WScript.Shell" ) sRegValue = "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname" sHostName = oWshShell.RegRead( sRegValue ) sCmd = "net use O: \\" & Left(sHostName,7) & "AB\folder$" wscript.echo "Executing commandline: " & sCmd oWshShell.run sCmd,0,True
#3
Posted 28 May 2010 - 06:35 AM
Using Windows Command Script
Example.cmd
@ECHO OFF&SETLOCAL
(SET H_=)
FOR /F %%# IN ('HOSTNAME') DO (SET H_=%%#)
IF DEFINED H_ (NET USE O: \\%H_:~,7%AB\folder$)
- ← Create a logging function for a WSF?
- Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
- Batch script Shift command. →
Share this topic:
Page 1 of 1



Help
Back to top









