Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Script
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Pegasus [MVP]  
View profile  
 More options Nov 5 2009, 11:10 pm
Newsgroups: microsoft.public.scripting.vbscript
From: "Pegasus [MVP]" <n...@microsoft.com>
Date: Fri, 6 Nov 2009 00:10:52 +0100
Local: Thurs, Nov 5 2009 11:10 pm
Subject: Re: Script

"PaulM" <N...@NONO.COM> wrote in message

news:OORp6rmXKHA.220@TK2MSFTNGP02.phx.gbl...

> Why does this script work:

> ' Description: Demonstration script that uses the FileSystemObject to
> delete a file. Local computer
> ' For Vista

> Set WSHShell = WScript.CreateObject("WScript.Shell")
> Set objFSO = CreateObject("Scripting.FileSystemObject")

> objFSO.DeleteFile("F:\Users\TestUser\AppData\Local\test.vbs")

> And this script does not work:

> ' Description: Demonstration script that uses the FileSystemObject to
> delete a file. Local computer
> ' For Vista

> Dim Windir
> Dim Users
> Dim UserProfile
> Dim AppData
> Dim Local

> Set WSHShell = WScript.CreateObject("WScript.Shell")
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Windir = WshShell.ExpandEnvironmentStrings("%SystemRoot%")
> Users =  WshShell.ExpandEnvironmentStrings("%Users%")
> UserProfile = WshShell.ExpandEnvironmentStrings("%UserProfile%")
> AppData = WshShell.ExpandEnvironmentStrings("%AppData%")
> Local = WshShell.ExpandEnvironmentStrings("%Local%")

> objFSO.DeleteFile("%SystemRoot%\%Users%\%UserProfile%\%AppData%\%Local%\tes t.vbs")

If you replace the line
objFSO.DeleteFile("%SystemRoot%\%Users%\%UserProfile%\%AppData%\%Local%\tes t.vbs")
with this line
wscript.echo "%SystemRoot%\%Users%\%UserProfile%\%AppData%\%Local%\test.vbs"
then you will see immediately why it cannot possibly work. Neither
objFSO.DeleteFile nor wscript.echo can resolve environmental variables such
as %SystemRoot%. How about something like this?

objFSO.DeleteFile(Local & "\test.vbs")

I also urge you to open a Command Prompt (click Start / Run / cmd {OK} and
type this command:

echo %SystemRoot%\%Users%\%UserProfile%\%AppData%\%Local%

I took it right from your own code. As you see, it produces nonsense.


    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google